diff --git a/package.json b/package.json index b6902ac15b..35b2d078d9 100644 --- a/package.json +++ b/package.json @@ -48,9 +48,9 @@ "@swc/helpers": "~0.5.15", "@types/babel__core": "^7.20.5", "@types/node": "^22.10.7", - "@vitest/coverage-v8": "^3.0.3", + "@vitest/coverage-v8": "^3.0.4", "@vitest/eslint-plugin": "^1.1.25", - "@vitest/ui": "^3.0.3", + "@vitest/ui": "^3.0.4", "bytes": "^3.1.2", "es-module-lexer": "^1.6.0", "eslint": "9.18.0", @@ -71,7 +71,7 @@ "tslib": "^2.8.1", "typescript": "5.4.5", "typescript-eslint": "8.20.0", - "vitest": "^3.0.3" + "vitest": "^3.0.4" }, "lint-staged": { "*.{js,mjs,ts}": "eslint --cache", diff --git a/packages/@lwc/babel-plugin-component/src/__tests__/index.spec.ts b/packages/@lwc/babel-plugin-component/src/__tests__/index.spec.ts index 2a0ccc41ec..963e81d814 100644 --- a/packages/@lwc/babel-plugin-component/src/__tests__/index.spec.ts +++ b/packages/@lwc/babel-plugin-component/src/__tests__/index.spec.ts @@ -7,7 +7,8 @@ import path from 'node:path'; import { describe } from 'vitest'; import { transformSync } from '@babel/core'; -import { LWC_VERSION, HIGHEST_API_VERSION } from '@lwc/shared'; +import { HIGHEST_API_VERSION } from '@lwc/shared/api-version'; +import { LWC_VERSION } from '@lwc/shared/meta'; import { testFixtureDir } from '@lwc/test-utils-lwc-internals'; import plugin from '../index'; diff --git a/packages/@lwc/babel-plugin-component/src/compiler-version-number.ts b/packages/@lwc/babel-plugin-component/src/compiler-version-number.ts index 9c3cf020a9..d402cf6d7d 100644 --- a/packages/@lwc/babel-plugin-component/src/compiler-version-number.ts +++ b/packages/@lwc/babel-plugin-component/src/compiler-version-number.ts @@ -4,7 +4,7 @@ * SPDX-License-Identifier: MIT * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT */ -import { LWC_VERSION_COMMENT } from '@lwc/shared'; +import { LWC_VERSION_COMMENT } from '@lwc/shared/meta'; import type { types, Visitor } from '@babel/core'; import type { BabelAPI, LwcBabelPluginPass } from './types'; diff --git a/packages/@lwc/babel-plugin-component/src/component.ts b/packages/@lwc/babel-plugin-component/src/component.ts index 5ce17a8da1..a2ad493dff 100644 --- a/packages/@lwc/babel-plugin-component/src/component.ts +++ b/packages/@lwc/babel-plugin-component/src/component.ts @@ -6,7 +6,8 @@ */ import { basename, extname } from 'path'; import { addDefault, addNamed } from '@babel/helper-module-imports'; -import { generateCustomElementTagName, getAPIVersionFromNumber } from '@lwc/shared'; +import { getAPIVersionFromNumber } from '@lwc/shared/api-version'; +import { generateCustomElementTagName } from '@lwc/shared/custom-element'; import { COMPONENT_NAME_KEY, LWC_PACKAGE_ALIAS, diff --git a/packages/@lwc/babel-plugin-component/src/decorators/index.ts b/packages/@lwc/babel-plugin-component/src/decorators/index.ts index 58eb422141..2457b97196 100644 --- a/packages/@lwc/babel-plugin-component/src/decorators/index.ts +++ b/packages/@lwc/babel-plugin-component/src/decorators/index.ts @@ -6,7 +6,7 @@ */ import { addNamed } from '@babel/helper-module-imports'; import { DecoratorErrors } from '@lwc/errors'; -import { APIFeature, getAPIVersionFromNumber, isAPIFeatureEnabled } from '@lwc/shared'; +import { APIFeature, getAPIVersionFromNumber, isAPIFeatureEnabled } from '@lwc/shared/api-version'; import { DECORATOR_TYPES, LWC_PACKAGE_ALIAS, REGISTER_DECORATORS_ID } from '../constants'; import { generateError, isClassMethod, isGetterClassMethod, isSetterClassMethod } from '../utils'; import api from './api'; diff --git a/packages/@lwc/compiler/src/options.ts b/packages/@lwc/compiler/src/options.ts index 576a3eb62e..64fb80fa92 100755 --- a/packages/@lwc/compiler/src/options.ts +++ b/packages/@lwc/compiler/src/options.ts @@ -5,13 +5,9 @@ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT */ import { CompilerValidationErrors, invariant } from '@lwc/errors'; -import { - isUndefined, - isBoolean, - getAPIVersionFromNumber, - DEFAULT_SSR_MODE, - type CompilationMode, -} from '@lwc/shared'; +import { DEFAULT_SSR_MODE, type CompilationMode } from '@lwc/shared/ssr'; +import { isBoolean, isUndefined } from '@lwc/shared/language'; +import { getAPIVersionFromNumber } from '@lwc/shared/api-version'; import type { InstrumentationObject } from '@lwc/errors'; import type { CustomRendererConfig } from '@lwc/template-compiler'; diff --git a/packages/@lwc/compiler/src/transformers/__tests__/transform-html.spec.ts b/packages/@lwc/compiler/src/transformers/__tests__/transform-html.spec.ts index 0c85880de9..14f3717095 100644 --- a/packages/@lwc/compiler/src/transformers/__tests__/transform-html.spec.ts +++ b/packages/@lwc/compiler/src/transformers/__tests__/transform-html.spec.ts @@ -5,7 +5,8 @@ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT */ import { vi, describe, it, expect } from 'vitest'; -import { APIVersion, noop } from '@lwc/shared'; +import { noop } from '@lwc/shared/language'; +import { APIVersion } from '@lwc/shared/api-version'; import { transformSync } from '../transformer'; import type { TransformOptions } from '../../options'; diff --git a/packages/@lwc/compiler/src/transformers/__tests__/transform-javascript.spec.ts b/packages/@lwc/compiler/src/transformers/__tests__/transform-javascript.spec.ts index a2a21e7e3f..2db51e2d51 100644 --- a/packages/@lwc/compiler/src/transformers/__tests__/transform-javascript.spec.ts +++ b/packages/@lwc/compiler/src/transformers/__tests__/transform-javascript.spec.ts @@ -5,7 +5,7 @@ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT */ import { vi, describe, it, expect } from 'vitest'; -import { noop } from '@lwc/shared'; +import { noop } from '@lwc/shared/language'; import { transform, transformSync } from '../transformer'; import type { TransformOptions } from '../../options'; diff --git a/packages/@lwc/compiler/src/transformers/javascript.ts b/packages/@lwc/compiler/src/transformers/javascript.ts index 724c503145..f956e39ec7 100755 --- a/packages/@lwc/compiler/src/transformers/javascript.ts +++ b/packages/@lwc/compiler/src/transformers/javascript.ts @@ -12,7 +12,7 @@ import babelObjectRestSpreadPlugin from '@babel/plugin-transform-object-rest-spr import lockerBabelPluginTransformUnforgeables from '@locker/babel-plugin-transform-unforgeables'; import lwcClassTransformPlugin, { type LwcBabelPluginOptions } from '@lwc/babel-plugin-component'; import { normalizeToCompilerError, TransformerErrors } from '@lwc/errors'; -import { isAPIFeatureEnabled, APIFeature } from '@lwc/shared'; +import { isAPIFeatureEnabled, APIFeature } from '@lwc/shared/api-version'; import type { NormalizedTransformOptions } from '../options'; import type { TransformResult } from './shared'; diff --git a/packages/@lwc/compiler/src/transformers/transformer.ts b/packages/@lwc/compiler/src/transformers/transformer.ts index 6b44113d40..1df98bc3bc 100755 --- a/packages/@lwc/compiler/src/transformers/transformer.ts +++ b/packages/@lwc/compiler/src/transformers/transformer.ts @@ -6,7 +6,7 @@ */ import * as path from 'path'; -import { isString } from '@lwc/shared'; +import { isString } from '@lwc/shared/language'; import { TransformerErrors, generateCompilerError, invariant } from '@lwc/errors'; import { compileComponentForSSR, compileTemplateForSSR } from '@lwc/ssr-compiler'; diff --git a/packages/@lwc/engine-core/src/framework/api.ts b/packages/@lwc/engine-core/src/framework/api.ts index 6386375b78..660629c90a 100644 --- a/packages/@lwc/engine-core/src/framework/api.ts +++ b/packages/@lwc/engine-core/src/framework/api.ts @@ -5,13 +5,10 @@ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT */ import { - APIFeature, ArrayPush, - assert, create as ObjectCreate, forEach, freeze as ObjectFreeze, - isAPIFeatureEnabled, isArray, isFalse, isFunction, @@ -23,10 +20,12 @@ import { isUndefined, StringReplace, toString, - sanitizeHtmlContent, - normalizeClass, -} from '@lwc/shared'; +} from '@lwc/shared/language'; +import * as assert from '@lwc/shared/assert'; +import { sanitizeHtmlContent } from '@lwc/shared/overridable-hooks'; +import { normalizeClass } from '@lwc/shared/normalize-class'; +import { isAPIFeatureEnabled, APIFeature } from '@lwc/shared/api-version'; import { logError } from '../shared/logger'; import { invokeEventListener } from './invoker'; diff --git a/packages/@lwc/engine-core/src/framework/base-bridge-element.ts b/packages/@lwc/engine-core/src/framework/base-bridge-element.ts index 727cb22aef..f48eef1ef6 100644 --- a/packages/@lwc/engine-core/src/framework/base-bridge-element.ts +++ b/packages/@lwc/engine-core/src/framework/base-bridge-element.ts @@ -8,21 +8,22 @@ * This module is responsible for creating the base bridge class BaseBridgeElement * that represents the HTMLElement extension used for any LWC inserted in the DOM. */ + import { - ArraySlice, ArrayIndexOf, + ArraySlice, create, defineProperties, defineProperty, freeze, - getOwnPropertyNames, getOwnPropertyDescriptors, + getOwnPropertyNames, + isNull, isUndefined, - seal, keys, - htmlPropertyToAttribute, - isNull, -} from '@lwc/shared'; + seal, +} from '@lwc/shared/language'; +import { htmlPropertyToAttribute } from '@lwc/shared/html-attributes'; import { ariaReflectionPolyfillDescriptors } from '../libs/reflection'; import { logWarn } from '../shared/logger'; import { getAssociatedVM } from './vm'; diff --git a/packages/@lwc/engine-core/src/framework/base-lightning-element.ts b/packages/@lwc/engine-core/src/framework/base-lightning-element.ts index 836ea6ba82..d245048d01 100644 --- a/packages/@lwc/engine-core/src/framework/base-lightning-element.ts +++ b/packages/@lwc/engine-core/src/framework/base-lightning-element.ts @@ -18,18 +18,17 @@ import { defineProperty, entries, freeze, - isAPIFeatureEnabled, isFunction, isNull, isObject, isUndefined, - KEY__SYNTHETIC_MODE, keys, setPrototypeOf, - APIFeature, - assert, -} from '@lwc/shared'; +} from '@lwc/shared/language'; +import { KEY__SYNTHETIC_MODE } from '@lwc/shared/keys'; +import { APIFeature, isAPIFeatureEnabled } from '@lwc/shared/api-version'; +import * as assert from '@lwc/shared/assert'; import { logError, logWarnOnce } from '../shared/logger'; import { getComponentTag } from '../shared/format'; import { @@ -54,7 +53,8 @@ import { applyShadowMigrateMode } from './shadow-migration-mode'; import type { HTMLElementConstructor } from './base-bridge-element'; import type { Template } from './template'; import type { RefVNodes, ShadowSupportMode, VM } from './vm'; -import type { Stylesheets, AccessibleElementProperties } from '@lwc/shared'; +import type { Stylesheets } from '@lwc/shared/style'; +import type { AccessibleElementProperties } from '@lwc/shared/aria'; /** * This operation is called with a descriptor of an standard html property diff --git a/packages/@lwc/engine-core/src/framework/check-version-mismatch.ts b/packages/@lwc/engine-core/src/framework/check-version-mismatch.ts index a8821a5f62..50548b52ae 100644 --- a/packages/@lwc/engine-core/src/framework/check-version-mismatch.ts +++ b/packages/@lwc/engine-core/src/framework/check-version-mismatch.ts @@ -4,14 +4,15 @@ * SPDX-License-Identifier: MIT * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT */ -import { isNull, LWC_VERSION, LWC_VERSION_COMMENT_REGEX } from '@lwc/shared'; +import { isNull } from '@lwc/shared/language'; +import { LWC_VERSION, LWC_VERSION_COMMENT_REGEX } from '@lwc/shared/meta'; import { logError } from '../shared/logger'; import { report, ReportingEventId } from './reporting'; import type { Template } from './template'; import type { LightningElementConstructor } from './base-lightning-element'; -import type { Stylesheet } from '@lwc/shared'; +import type { Stylesheet } from '@lwc/shared/style'; let warned = false; diff --git a/packages/@lwc/engine-core/src/framework/component.ts b/packages/@lwc/engine-core/src/framework/component.ts index c3fc10e7fc..246a9535a8 100644 --- a/packages/@lwc/engine-core/src/framework/component.ts +++ b/packages/@lwc/engine-core/src/framework/component.ts @@ -4,7 +4,9 @@ * SPDX-License-Identifier: MIT * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT */ -import { assert, isFalse, isFunction, isUndefined, LOWEST_API_VERSION } from '@lwc/shared'; +import { isFalse, isFunction, isUndefined } from '@lwc/shared/language'; +import { LOWEST_API_VERSION } from '@lwc/shared/api-version'; +import * as assert from '@lwc/shared/assert'; import { createReactiveObserver, unsubscribeFromSignals } from './mutation-tracker'; @@ -18,7 +20,7 @@ import type { LightningElementConstructor } from './base-lightning-element'; import type { Template } from './template'; import type { VNodes } from './vnodes'; import type { ReactiveObserver } from './mutation-tracker'; -import type { APIVersion } from '@lwc/shared'; +import type { APIVersion } from '@lwc/shared/api-version'; type ComponentConstructorMetadata = { tmpl: Template; diff --git a/packages/@lwc/engine-core/src/framework/decorators/api.ts b/packages/@lwc/engine-core/src/framework/decorators/api.ts index 663df2ae00..e620de560b 100644 --- a/packages/@lwc/engine-core/src/framework/decorators/api.ts +++ b/packages/@lwc/engine-core/src/framework/decorators/api.ts @@ -4,7 +4,8 @@ * SPDX-License-Identifier: MIT * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT */ -import { assert, isFunction, isNull, toString } from '@lwc/shared'; +import { isFunction, isNull, toString } from '@lwc/shared/language'; +import * as assert from '@lwc/shared/assert'; import { logError } from '../../shared/logger'; import { isInvokingRender, isBeingConstructed } from '../invoker'; import { componentValueObserved, componentValueMutated } from '../mutation-tracker'; diff --git a/packages/@lwc/engine-core/src/framework/decorators/register.ts b/packages/@lwc/engine-core/src/framework/decorators/register.ts index 5c3ee03970..9aae60e090 100644 --- a/packages/@lwc/engine-core/src/framework/decorators/register.ts +++ b/packages/@lwc/engine-core/src/framework/decorators/register.ts @@ -12,7 +12,7 @@ import { defineProperty, getOwnPropertyDescriptor, isFalse, -} from '@lwc/shared'; +} from '@lwc/shared/language'; import { assertNotProd, EmptyObject } from '../utils'; import { logError } from '../../shared/logger'; diff --git a/packages/@lwc/engine-core/src/framework/decorators/track.ts b/packages/@lwc/engine-core/src/framework/decorators/track.ts index ab42ba6f6b..5c3bba9bb3 100644 --- a/packages/@lwc/engine-core/src/framework/decorators/track.ts +++ b/packages/@lwc/engine-core/src/framework/decorators/track.ts @@ -4,7 +4,8 @@ * SPDX-License-Identifier: MIT * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT */ -import { assert, toString } from '@lwc/shared'; +import { toString } from '@lwc/shared/language'; +import * as assert from '@lwc/shared/assert'; import { trackTargetForMutationLogging } from '../mutation-logger'; import { componentValueObserved } from '../mutation-tracker'; import { isInvokingRender } from '../invoker'; diff --git a/packages/@lwc/engine-core/src/framework/decorators/wire.ts b/packages/@lwc/engine-core/src/framework/decorators/wire.ts index 7abb57b1f3..13a73b51cd 100644 --- a/packages/@lwc/engine-core/src/framework/decorators/wire.ts +++ b/packages/@lwc/engine-core/src/framework/decorators/wire.ts @@ -4,7 +4,7 @@ * SPDX-License-Identifier: MIT * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT */ -import { assert } from '@lwc/shared'; +import * as assert from '@lwc/shared/assert'; import { componentValueObserved } from '../mutation-tracker'; import { getAssociatedVM } from '../vm'; import { updateComponentValue } from '../update-component-value'; diff --git a/packages/@lwc/engine-core/src/framework/def.ts b/packages/@lwc/engine-core/src/framework/def.ts index 4262264a8d..8e7202d93f 100644 --- a/packages/@lwc/engine-core/src/framework/def.ts +++ b/packages/@lwc/engine-core/src/framework/def.ts @@ -19,12 +19,11 @@ import { defineProperties, freeze, getPrototypeOf, - htmlPropertyToAttribute, isFunction, isNull, isUndefined, keys, -} from '@lwc/shared'; +} from '@lwc/shared/language'; import { RenderMode } from '../framework/vm'; import { @@ -49,6 +48,7 @@ import type { PropType } from './decorators/register'; import type { LightningElementConstructor } from './base-lightning-element'; import type { Template } from './template'; import type { ShadowSupportMode } from '../framework/vm'; +import { htmlPropertyToAttribute } from '@lwc/shared/html-attributes'; export interface ComponentDef { name: string; diff --git a/packages/@lwc/engine-core/src/framework/fragment-cache.ts b/packages/@lwc/engine-core/src/framework/fragment-cache.ts index 7cdb79d8f6..28a7c13fe0 100644 --- a/packages/@lwc/engine-core/src/framework/fragment-cache.ts +++ b/packages/@lwc/engine-core/src/framework/fragment-cache.ts @@ -4,7 +4,7 @@ * SPDX-License-Identifier: MIT * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT */ -import { ArrayFrom } from '@lwc/shared'; +import { ArrayFrom } from '@lwc/shared/language'; export const enum FragmentCacheKey { HAS_SCOPED_STYLE = 1, diff --git a/packages/@lwc/engine-core/src/framework/freeze-template.ts b/packages/@lwc/engine-core/src/framework/freeze-template.ts index d32c05f3c6..b8efe44721 100644 --- a/packages/@lwc/engine-core/src/framework/freeze-template.ts +++ b/packages/@lwc/engine-core/src/framework/freeze-template.ts @@ -19,13 +19,12 @@ import { getOwnPropertyDescriptor, isArray, isUndefined, - KEY__SCOPED_CSS, - KEY__NATIVE_ONLY_CSS, -} from '@lwc/shared'; +} from '@lwc/shared/language'; +import { KEY__NATIVE_ONLY_CSS, KEY__SCOPED_CSS } from '@lwc/shared/keys'; import { logWarnOnce } from '../shared/logger'; import { onReportingEnabled, report, ReportingEventId } from './reporting'; import type { Template } from './template'; -import type { Stylesheet, Stylesheets } from '@lwc/shared'; +import type { Stylesheet, Stylesheets } from '@lwc/shared/style'; // See @lwc/engine-core/src/framework/template.ts const TEMPLATE_PROPS = [ diff --git a/packages/@lwc/engine-core/src/framework/get-component-constructor.ts b/packages/@lwc/engine-core/src/framework/get-component-constructor.ts index 46f1f737df..6c6261cd82 100644 --- a/packages/@lwc/engine-core/src/framework/get-component-constructor.ts +++ b/packages/@lwc/engine-core/src/framework/get-component-constructor.ts @@ -5,7 +5,7 @@ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT */ -import { isUndefined } from '@lwc/shared'; +import { isUndefined } from '@lwc/shared/language'; import { getAssociatedVMIfPresent } from './vm'; import type { LightningElement } from './base-lightning-element'; diff --git a/packages/@lwc/engine-core/src/framework/hot-swaps.ts b/packages/@lwc/engine-core/src/framework/hot-swaps.ts index 2bd5ea00e5..c748cfedcb 100644 --- a/packages/@lwc/engine-core/src/framework/hot-swaps.ts +++ b/packages/@lwc/engine-core/src/framework/hot-swaps.ts @@ -5,7 +5,8 @@ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT */ -import { isFalse, isNull, isUndefined, flattenStylesheets } from '@lwc/shared'; +import { isFalse, isNull, isUndefined } from '@lwc/shared/language'; +import { flattenStylesheets, type Stylesheet, type Stylesheets } from '@lwc/shared/style'; import { scheduleRehydration, forceRehydration } from './vm'; import { isComponentConstructor } from './def'; import { markComponentAsDirty } from './component'; @@ -16,7 +17,6 @@ import { WeakMultiMap } from './weak-multimap'; import type { Template } from './template'; import type { LightningElementConstructor } from './base-lightning-element'; import type { VM } from './vm'; -import type { Stylesheet, Stylesheets } from '@lwc/shared'; let swappedTemplateMap: WeakMap = /*@__PURE__@*/ new WeakMap(); let swappedComponentMap: WeakMap = diff --git a/packages/@lwc/engine-core/src/framework/html-properties.ts b/packages/@lwc/engine-core/src/framework/html-properties.ts index 383272495b..823801bd67 100644 --- a/packages/@lwc/engine-core/src/framework/html-properties.ts +++ b/packages/@lwc/engine-core/src/framework/html-properties.ts @@ -4,16 +4,10 @@ * SPDX-License-Identifier: MIT * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT */ -import { - AriaPropNameToAttrNameMap, - create, - forEach, - getPropertyDescriptor, - isUndefined, - keys, - REFLECTIVE_GLOBAL_PROPERTY_SET, -} from '@lwc/shared'; +import { create, forEach, getPropertyDescriptor, isUndefined, keys } from '@lwc/shared/language'; +import { AriaPropNameToAttrNameMap } from '@lwc/shared/aria'; +import { REFLECTIVE_GLOBAL_PROPERTY_SET } from '@lwc/shared/html-attributes'; import { HTMLElementPrototype } from './html-element'; /** diff --git a/packages/@lwc/engine-core/src/framework/hydration-utils.ts b/packages/@lwc/engine-core/src/framework/hydration-utils.ts index 3447c68b91..da21b3c656 100644 --- a/packages/@lwc/engine-core/src/framework/hydration-utils.ts +++ b/packages/@lwc/engine-core/src/framework/hydration-utils.ts @@ -4,7 +4,14 @@ * SPDX-License-Identifier: MIT * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT */ -import { ArrayPush, ArrayJoin, ArraySort, ArrayFrom, isNull, isUndefined } from '@lwc/shared'; +import { + ArrayPush, + ArrayJoin, + ArraySort, + ArrayFrom, + isNull, + isUndefined, +} from '@lwc/shared/language'; import { assertNotProd } from './utils'; diff --git a/packages/@lwc/engine-core/src/framework/hydration.ts b/packages/@lwc/engine-core/src/framework/hydration.ts index 4a0dfec12a..4be7591722 100644 --- a/packages/@lwc/engine-core/src/framework/hydration.ts +++ b/packages/@lwc/engine-core/src/framework/hydration.ts @@ -8,23 +8,23 @@ import { isUndefined, ArrayJoin, arrayEvery, - assert, keys, isNull, isArray, isTrue, isString, StringToLowerCase, - APIFeature, - isAPIFeatureEnabled, isFalse, StringSplit, - parseStyleText, ArrayFrom, ArrayFilter, ArrayMap, -} from '@lwc/shared'; +} from '@lwc/shared/language'; +import { parseStyleText } from '@lwc/shared/style'; +import * as assert from '@lwc/shared/assert'; + +import { APIFeature, isAPIFeatureEnabled } from '@lwc/shared/api-version'; import { queueHydrationError, flushHydrationErrors, diff --git a/packages/@lwc/engine-core/src/framework/invoker.ts b/packages/@lwc/engine-core/src/framework/invoker.ts index fa0877a514..1d9b9f8900 100644 --- a/packages/@lwc/engine-core/src/framework/invoker.ts +++ b/packages/@lwc/engine-core/src/framework/invoker.ts @@ -4,7 +4,8 @@ * SPDX-License-Identifier: MIT * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT */ -import { assert, isFunction, isUndefined, noop } from '@lwc/shared'; +import { isFunction, isUndefined, noop } from '@lwc/shared/language'; +import * as assert from '@lwc/shared/assert'; import { addErrorComponentStack } from '../shared/error'; diff --git a/packages/@lwc/engine-core/src/framework/main.ts b/packages/@lwc/engine-core/src/framework/main.ts index fee61e3f23..e4ba2b73b8 100644 --- a/packages/@lwc/engine-core/src/framework/main.ts +++ b/packages/@lwc/engine-core/src/framework/main.ts @@ -38,7 +38,7 @@ export { getComponentDef, isComponentConstructor } from './def'; export { profilerControl as __unstable__ProfilerControl } from './profiler'; export { reportingControl as __unstable__ReportingControl } from './reporting'; export { swapTemplate, swapComponent, swapStyle } from './hot-swaps'; -export { setHooks } from '@lwc/shared'; +export { setHooks } from '@lwc/shared/overridable-hooks'; export { freezeTemplate } from './freeze-template'; export { getComponentAPIVersion } from './component'; export { shouldBeFormAssociated } from './utils'; @@ -73,5 +73,5 @@ export { default as wire } from './decorators/wire'; export { readonly } from './readonly'; export { setFeatureFlag, setFeatureFlagForTest } from '@lwc/features'; -export { setTrustedSignalSet } from '@lwc/shared'; -export type { Stylesheet, Stylesheets } from '@lwc/shared'; +export { setTrustedSignalSet } from '@lwc/shared/signals'; +export type { Stylesheet, Stylesheets } from '@lwc/shared/style'; diff --git a/packages/@lwc/engine-core/src/framework/modules/attrs.ts b/packages/@lwc/engine-core/src/framework/modules/attrs.ts index 0041efcd52..3b48906338 100644 --- a/packages/@lwc/engine-core/src/framework/modules/attrs.ts +++ b/packages/@lwc/engine-core/src/framework/modules/attrs.ts @@ -4,14 +4,9 @@ * SPDX-License-Identifier: MIT * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT */ -import { - isNull, - isUndefined, - StringCharCodeAt, - XML_NAMESPACE, - XLINK_NAMESPACE, - kebabCaseToCamelCase, -} from '@lwc/shared'; +import { isNull, isUndefined, StringCharCodeAt } from '@lwc/shared/language'; +import { kebabCaseToCamelCase } from '@lwc/shared/html-attributes'; +import { XML_NAMESPACE, XLINK_NAMESPACE } from '@lwc/shared/namespaces'; import { EmptyObject } from '../utils'; import { safelySetProperty } from '../sanitized-html-content'; import type { RendererAPI } from '../renderer'; diff --git a/packages/@lwc/engine-core/src/framework/modules/computed-class-attr.ts b/packages/@lwc/engine-core/src/framework/modules/computed-class-attr.ts index ccadde7eae..7f588fd5ae 100644 --- a/packages/@lwc/engine-core/src/framework/modules/computed-class-attr.ts +++ b/packages/@lwc/engine-core/src/framework/modules/computed-class-attr.ts @@ -12,7 +12,7 @@ import { isUndefined, StringCharCodeAt, StringSlice, -} from '@lwc/shared'; +} from '@lwc/shared/language'; import { EmptyObject, SPACE_CHAR } from '../utils'; import type { RendererAPI } from '../renderer'; diff --git a/packages/@lwc/engine-core/src/framework/modules/computed-style-attr.ts b/packages/@lwc/engine-core/src/framework/modules/computed-style-attr.ts index 37b0fc9a8c..46914bc3f7 100644 --- a/packages/@lwc/engine-core/src/framework/modules/computed-style-attr.ts +++ b/packages/@lwc/engine-core/src/framework/modules/computed-style-attr.ts @@ -4,7 +4,7 @@ * SPDX-License-Identifier: MIT * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT */ -import { isNull, isString, isUndefined } from '@lwc/shared'; +import { isNull, isString, isUndefined } from '@lwc/shared/language'; import { logError } from '../../shared/logger'; import type { RendererAPI } from '../renderer'; import type { VBaseElement, VStaticPartElement } from '../vnodes'; diff --git a/packages/@lwc/engine-core/src/framework/modules/events.ts b/packages/@lwc/engine-core/src/framework/modules/events.ts index 84c35da9a8..9b19bdfe6b 100644 --- a/packages/@lwc/engine-core/src/framework/modules/events.ts +++ b/packages/@lwc/engine-core/src/framework/modules/events.ts @@ -4,7 +4,7 @@ * SPDX-License-Identifier: MIT * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT */ -import { isUndefined } from '@lwc/shared'; +import { isUndefined } from '@lwc/shared/language'; import type { RendererAPI } from '../renderer'; import type { VBaseElement, VStaticPartElement } from '../vnodes'; diff --git a/packages/@lwc/engine-core/src/framework/modules/props.ts b/packages/@lwc/engine-core/src/framework/modules/props.ts index e9f534b5cb..6142bb5d09 100644 --- a/packages/@lwc/engine-core/src/framework/modules/props.ts +++ b/packages/@lwc/engine-core/src/framework/modules/props.ts @@ -4,7 +4,8 @@ * SPDX-License-Identifier: MIT * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT */ -import { htmlPropertyToAttribute, isNull, isUndefined } from '@lwc/shared'; +import { isNull, isUndefined } from '@lwc/shared/language'; +import { htmlPropertyToAttribute } from '@lwc/shared/html-attributes'; import { logWarn } from '../../shared/logger'; import { EmptyObject } from '../utils'; import { safelySetProperty } from '../sanitized-html-content'; diff --git a/packages/@lwc/engine-core/src/framework/modules/refs.ts b/packages/@lwc/engine-core/src/framework/modules/refs.ts index 3c2cb98766..731d8b7a0e 100644 --- a/packages/@lwc/engine-core/src/framework/modules/refs.ts +++ b/packages/@lwc/engine-core/src/framework/modules/refs.ts @@ -4,7 +4,7 @@ * SPDX-License-Identifier: MIT * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT */ -import { isUndefined } from '@lwc/shared'; +import { isUndefined } from '@lwc/shared/language'; import type { RefVNodes, VM } from '../vm'; import type { VBaseElement, VStaticPartElement } from '../vnodes'; diff --git a/packages/@lwc/engine-core/src/framework/modules/static-class-attr.ts b/packages/@lwc/engine-core/src/framework/modules/static-class-attr.ts index 6925f2d644..8079fa7fa6 100644 --- a/packages/@lwc/engine-core/src/framework/modules/static-class-attr.ts +++ b/packages/@lwc/engine-core/src/framework/modules/static-class-attr.ts @@ -4,7 +4,7 @@ * SPDX-License-Identifier: MIT * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT */ -import { isUndefined } from '@lwc/shared'; +import { isUndefined } from '@lwc/shared/language'; import type { RendererAPI } from '../renderer'; import type { VBaseElement } from '../vnodes'; diff --git a/packages/@lwc/engine-core/src/framework/modules/static-parts.ts b/packages/@lwc/engine-core/src/framework/modules/static-parts.ts index 522f4f4323..a6f43ae49b 100644 --- a/packages/@lwc/engine-core/src/framework/modules/static-parts.ts +++ b/packages/@lwc/engine-core/src/framework/modules/static-parts.ts @@ -5,7 +5,8 @@ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT */ -import { isNull, isUndefined, assert } from '@lwc/shared'; +import { isNull, isUndefined } from '@lwc/shared/language'; +import * as assert from '@lwc/shared/assert'; import { isVStaticPartElement, isVStaticPartText } from '../vnodes'; import { applyEventListeners } from './events'; import { applyRefs } from './refs'; diff --git a/packages/@lwc/engine-core/src/framework/modules/static-style-attr.ts b/packages/@lwc/engine-core/src/framework/modules/static-style-attr.ts index cfe4adae45..d045e10b7c 100644 --- a/packages/@lwc/engine-core/src/framework/modules/static-style-attr.ts +++ b/packages/@lwc/engine-core/src/framework/modules/static-style-attr.ts @@ -4,7 +4,7 @@ * SPDX-License-Identifier: MIT * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT */ -import { isUndefined } from '@lwc/shared'; +import { isUndefined } from '@lwc/shared/language'; import type { RendererAPI } from '../renderer'; import type { VBaseElement } from '../vnodes'; diff --git a/packages/@lwc/engine-core/src/framework/modules/text.ts b/packages/@lwc/engine-core/src/framework/modules/text.ts index 3f3b6bd773..49004477f0 100644 --- a/packages/@lwc/engine-core/src/framework/modules/text.ts +++ b/packages/@lwc/engine-core/src/framework/modules/text.ts @@ -4,7 +4,7 @@ * SPDX-License-Identifier: MIT * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT */ -import { isNull } from '@lwc/shared'; +import { isNull } from '@lwc/shared/language'; import { lockDomMutation, unlockDomMutation } from '../restrictions'; import type { RendererAPI } from '../renderer'; import type { VComment, VStaticPartText, VText } from '../vnodes'; diff --git a/packages/@lwc/engine-core/src/framework/mutation-logger.ts b/packages/@lwc/engine-core/src/framework/mutation-logger.ts index 1482b0a87e..eda41d29d6 100644 --- a/packages/@lwc/engine-core/src/framework/mutation-logger.ts +++ b/packages/@lwc/engine-core/src/framework/mutation-logger.ts @@ -18,7 +18,7 @@ import { getOwnPropertyNames, getOwnPropertySymbols, isString, -} from '@lwc/shared'; +} from '@lwc/shared/language'; import { assertNotProd } from './utils'; import type { ReactiveObserver } from '../libs/mutation-tracker'; import type { VM } from './vm'; diff --git a/packages/@lwc/engine-core/src/framework/mutation-tracker.ts b/packages/@lwc/engine-core/src/framework/mutation-tracker.ts index d179ea9d88..9d4d588d6f 100644 --- a/packages/@lwc/engine-core/src/framework/mutation-tracker.ts +++ b/packages/@lwc/engine-core/src/framework/mutation-tracker.ts @@ -4,7 +4,9 @@ * SPDX-License-Identifier: MIT * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT */ -import { isFunction, isNull, isObject, isTrustedSignal } from '@lwc/shared'; +import { isFunction, isNull, isObject } from '@lwc/shared/language'; +import { isTrustedSignal } from '@lwc/shared/signals'; + import { ReactiveObserver, valueMutated, valueObserved } from '../libs/mutation-tracker'; import { subscribeToSignal } from '../libs/signal-tracker'; import { safeHasProp } from './utils'; diff --git a/packages/@lwc/engine-core/src/framework/profiler.ts b/packages/@lwc/engine-core/src/framework/profiler.ts index 1f07e597e8..89fe3fa6b2 100644 --- a/packages/@lwc/engine-core/src/framework/profiler.ts +++ b/packages/@lwc/engine-core/src/framework/profiler.ts @@ -4,7 +4,7 @@ * SPDX-License-Identifier: MIT * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT */ -import { ArrayJoin, ArrayMap, ArrayPush, ArraySort, isUndefined, noop } from '@lwc/shared'; +import { ArrayJoin, ArrayMap, ArrayPush, ArraySort, isUndefined, noop } from '@lwc/shared/language'; import { getComponentTag } from '../shared/format'; import { RenderMode, ShadowMode } from './vm'; diff --git a/packages/@lwc/engine-core/src/framework/rendering.ts b/packages/@lwc/engine-core/src/framework/rendering.ts index e7f11b9497..3544dc0059 100644 --- a/packages/@lwc/engine-core/src/framework/rendering.ts +++ b/packages/@lwc/engine-core/src/framework/rendering.ts @@ -8,19 +8,18 @@ import { ArrayPop, ArrayPush, ArraySome, - assert, create, isArray, isFalse, isNull, isTrue, isUndefined, - KEY__SHADOW_RESOLVER, - KEY__SHADOW_STATIC, keys, - SVG_NAMESPACE, -} from '@lwc/shared'; +} from '@lwc/shared/language'; +import * as assert from '@lwc/shared/assert'; +import { KEY__SHADOW_RESOLVER, KEY__SHADOW_STATIC } from '@lwc/shared/keys'; +import { SVG_NAMESPACE } from '@lwc/shared/namespaces'; import { logError } from '../shared/logger'; import { getComponentTag } from '../shared/format'; import { EmptyArray, shouldBeFormAssociated } from './utils'; diff --git a/packages/@lwc/engine-core/src/framework/reporting.ts b/packages/@lwc/engine-core/src/framework/reporting.ts index 35423756d7..503250addf 100644 --- a/packages/@lwc/engine-core/src/framework/reporting.ts +++ b/packages/@lwc/engine-core/src/framework/reporting.ts @@ -4,7 +4,7 @@ * SPDX-License-Identifier: MIT * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT */ -import { noop } from '@lwc/shared'; +import { noop } from '@lwc/shared/language'; import type { RenderMode, ShadowMode, ShadowSupportMode } from './vm'; diff --git a/packages/@lwc/engine-core/src/framework/restrictions.ts b/packages/@lwc/engine-core/src/framework/restrictions.ts index 6a3f750771..4999475efd 100644 --- a/packages/@lwc/engine-core/src/framework/restrictions.ts +++ b/packages/@lwc/engine-core/src/framework/restrictions.ts @@ -13,7 +13,7 @@ import { getPrototypeOf, isUndefined, setPrototypeOf, -} from '@lwc/shared'; +} from '@lwc/shared/language'; import { logError, logWarn } from '../shared/logger'; diff --git a/packages/@lwc/engine-core/src/framework/runtime-instrumentation.ts b/packages/@lwc/engine-core/src/framework/runtime-instrumentation.ts index 3928460d67..57ce2758d5 100644 --- a/packages/@lwc/engine-core/src/framework/runtime-instrumentation.ts +++ b/packages/@lwc/engine-core/src/framework/runtime-instrumentation.ts @@ -4,7 +4,7 @@ * SPDX-License-Identifier: MIT * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT */ -import { noop } from '@lwc/shared'; +import { noop } from '@lwc/shared/language'; export const instrumentDef = (globalThis as any).__lwc_instrument_cmp_def ?? noop; export const instrumentInstance = (globalThis as any).__lwc_instrument_cmp_instance ?? noop; diff --git a/packages/@lwc/engine-core/src/framework/sanitized-html-content.ts b/packages/@lwc/engine-core/src/framework/sanitized-html-content.ts index c432542e58..9c47d5f5ae 100644 --- a/packages/@lwc/engine-core/src/framework/sanitized-html-content.ts +++ b/packages/@lwc/engine-core/src/framework/sanitized-html-content.ts @@ -5,7 +5,7 @@ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT */ -import { create as ObjectCreate, isNull, isObject, isUndefined } from '@lwc/shared'; +import { create as ObjectCreate, isNull, isObject, isUndefined } from '@lwc/shared/language'; import { logWarn } from '../shared/logger'; import type { RendererAPI } from './renderer'; diff --git a/packages/@lwc/engine-core/src/framework/stylesheet.ts b/packages/@lwc/engine-core/src/framework/stylesheet.ts index 1f65b40591..87789bb3f5 100644 --- a/packages/@lwc/engine-core/src/framework/stylesheet.ts +++ b/packages/@lwc/engine-core/src/framework/stylesheet.ts @@ -4,16 +4,8 @@ * SPDX-License-Identifier: MIT * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT */ -import { - ArrayMap, - ArrayPush, - isArray, - isNull, - isTrue, - isUndefined, - KEY__NATIVE_ONLY_CSS, - KEY__SCOPED_CSS, -} from '@lwc/shared'; +import { ArrayMap, ArrayPush, isArray, isNull, isTrue, isUndefined } from '@lwc/shared/language'; +import { KEY__NATIVE_ONLY_CSS, KEY__SCOPED_CSS } from '@lwc/shared/keys'; import { logError } from '../shared/logger'; @@ -27,7 +19,7 @@ import { assertNotProd, EmptyArray } from './utils'; import type { VCustomElement, VNode } from './vnodes'; import type { Template } from './template'; import type { VM } from './vm'; -import type { Stylesheet, Stylesheets } from '@lwc/shared'; +import type { Stylesheet, Stylesheets } from '@lwc/shared/style'; // These are only used for HMR in dev mode // The "pure" annotations are so that Rollup knows for sure it can remove these from prod mode diff --git a/packages/@lwc/engine-core/src/framework/template.ts b/packages/@lwc/engine-core/src/framework/template.ts index 1b2ecc9d76..304dd2c577 100644 --- a/packages/@lwc/engine-core/src/framework/template.ts +++ b/packages/@lwc/engine-core/src/framework/template.ts @@ -5,20 +5,20 @@ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT */ import { - assert, create, - htmlEscape, isArray, isNull, isString, isTrue, isUndefined, - KEY__SCOPED_CSS, keys, StringCharAt, - STATIC_PART_TOKEN_ID, toString, -} from '@lwc/shared'; +} from '@lwc/shared/language'; +import * as assert from '@lwc/shared/assert'; +import { htmlEscape } from '@lwc/shared/html-escape'; +import { STATIC_PART_TOKEN_ID } from '@lwc/shared/static-part-tokens'; +import { KEY__SCOPED_CSS } from '@lwc/shared/keys'; import { logError } from '../shared/logger'; import { getComponentTag } from '../shared/format'; @@ -36,7 +36,7 @@ import type { RendererAPI } from './renderer'; import type { VNodes, VStaticPart, VStaticPartElement, VStaticPartText } from './vnodes'; import type { SlotSet, TemplateCache, VM } from './vm'; import type { RenderAPI } from './api'; -import type { Stylesheets } from '@lwc/shared'; +import type { Stylesheets } from '@lwc/shared/style'; export interface Template { (api: RenderAPI, cmp: object, slotSet: SlotSet, cache: TemplateCache): VNodes; diff --git a/packages/@lwc/engine-core/src/framework/utils.ts b/packages/@lwc/engine-core/src/framework/utils.ts index 2bc586e4fd..c4e033dac2 100644 --- a/packages/@lwc/engine-core/src/framework/utils.ts +++ b/packages/@lwc/engine-core/src/framework/utils.ts @@ -4,15 +4,8 @@ * SPDX-License-Identifier: MIT * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT */ -import { - ArrayPush, - create, - isFunction, - keys, - seal, - isAPIFeatureEnabled, - APIFeature, -} from '@lwc/shared'; +import { ArrayPush, create, isFunction, keys, seal } from '@lwc/shared/language'; +import { isAPIFeatureEnabled, APIFeature } from '@lwc/shared/api-version'; import { logWarnOnce } from '../shared/logger'; import { getComponentAPIVersion, getComponentRegisteredName } from './component'; import type { LightningElementConstructor } from './base-lightning-element'; diff --git a/packages/@lwc/engine-core/src/framework/vm.ts b/packages/@lwc/engine-core/src/framework/vm.ts index a309c71c91..2017234b2b 100644 --- a/packages/@lwc/engine-core/src/framework/vm.ts +++ b/packages/@lwc/engine-core/src/framework/vm.ts @@ -8,7 +8,6 @@ import { ArrayPush, ArraySlice, ArrayUnshift, - assert, create, defineProperty, getOwnPropertyNames, @@ -19,8 +18,9 @@ import { isObject, isTrue, isUndefined, - flattenStylesheets, -} from '@lwc/shared'; +} from '@lwc/shared/language'; +import * as assert from '@lwc/shared/assert'; +import { flattenStylesheets } from '@lwc/shared/style'; import { addErrorComponentStack } from '../shared/error'; import { logError, logWarnOnce } from '../shared/logger'; @@ -59,7 +59,8 @@ import type { import type { ComponentDef } from './def'; import type { Template } from './template'; import type { HostNode, HostElement, RendererAPI } from './renderer'; -import type { Stylesheet, Stylesheets, APIVersion } from '@lwc/shared'; +import type { Stylesheet, Stylesheets } from '@lwc/shared/style'; +import type { APIVersion } from '@lwc/shared/api-version'; type ShadowRootMode = 'open' | 'closed'; diff --git a/packages/@lwc/engine-core/src/framework/weak-multimap.ts b/packages/@lwc/engine-core/src/framework/weak-multimap.ts index 0044be5921..ae05ae2c04 100644 --- a/packages/@lwc/engine-core/src/framework/weak-multimap.ts +++ b/packages/@lwc/engine-core/src/framework/weak-multimap.ts @@ -5,7 +5,7 @@ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT */ -import { ArrayPush, ArraySplice, isUndefined } from '@lwc/shared'; +import { ArrayPush, ArraySplice, isUndefined } from '@lwc/shared/language'; const supportsWeakRefs = typeof WeakRef === 'function' && typeof FinalizationRegistry === 'function'; diff --git a/packages/@lwc/engine-core/src/framework/wiring/context.ts b/packages/@lwc/engine-core/src/framework/wiring/context.ts index 6e7c6d690a..9ffaf94922 100644 --- a/packages/@lwc/engine-core/src/framework/wiring/context.ts +++ b/packages/@lwc/engine-core/src/framework/wiring/context.ts @@ -4,7 +4,7 @@ * SPDX-License-Identifier: MIT * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT */ -import { isUndefined, ArrayPush } from '@lwc/shared'; +import { isUndefined, ArrayPush } from '@lwc/shared/language'; import { guid } from '../utils'; import type { VM } from '../vm'; import type { diff --git a/packages/@lwc/engine-core/src/framework/wiring/wiring.ts b/packages/@lwc/engine-core/src/framework/wiring/wiring.ts index 04020b33e3..de6792c4f7 100644 --- a/packages/@lwc/engine-core/src/framework/wiring/wiring.ts +++ b/packages/@lwc/engine-core/src/framework/wiring/wiring.ts @@ -5,7 +5,8 @@ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT */ -import { assert, create, isUndefined, ArrayPush, defineProperty, noop } from '@lwc/shared'; +import { create, isUndefined, ArrayPush, defineProperty, noop } from '@lwc/shared/language'; +import * as assert from '@lwc/shared/assert'; import { associateReactiveObserverWithVM } from '../mutation-logger'; import { createReactiveObserver } from '../mutation-tracker'; import { runWithBoundaryProtection, VMState, getAssociatedVM } from '../vm'; diff --git a/packages/@lwc/engine-core/src/libs/mutation-tracker/index.ts b/packages/@lwc/engine-core/src/libs/mutation-tracker/index.ts index 2e15c92e5d..7ad412400c 100644 --- a/packages/@lwc/engine-core/src/libs/mutation-tracker/index.ts +++ b/packages/@lwc/engine-core/src/libs/mutation-tracker/index.ts @@ -4,7 +4,7 @@ * SPDX-License-Identifier: MIT * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT */ -import { create, isUndefined, ArrayIndexOf, ArrayPush, ArrayPop } from '@lwc/shared'; +import { create, isUndefined, ArrayIndexOf, ArrayPush, ArrayPop } from '@lwc/shared/language'; import { logMutation } from '../../framework/mutation-logger'; const TargetToReactiveRecordMap: WeakMap = new WeakMap(); diff --git a/packages/@lwc/engine-core/src/libs/reflection/aria-reflection.ts b/packages/@lwc/engine-core/src/libs/reflection/aria-reflection.ts index e524825c1b..39a4847834 100644 --- a/packages/@lwc/engine-core/src/libs/reflection/aria-reflection.ts +++ b/packages/@lwc/engine-core/src/libs/reflection/aria-reflection.ts @@ -4,14 +4,8 @@ * SPDX-License-Identifier: MIT * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT */ -import { - AriaPropNameToAttrNameMap, - isNull, - isUndefined, - create, - getPropertyDescriptor, - entries, -} from '@lwc/shared'; +import { isNull, isUndefined, create, getPropertyDescriptor, entries } from '@lwc/shared/language'; +import { AriaPropNameToAttrNameMap } from '@lwc/shared/aria'; import { HTMLElementPrototype } from '../../framework/html-element'; // Apply ARIA string reflection behavior to a prototype. diff --git a/packages/@lwc/engine-core/src/libs/reflection/attr-reflection.ts b/packages/@lwc/engine-core/src/libs/reflection/attr-reflection.ts index e2856a14a2..a063adf9f9 100644 --- a/packages/@lwc/engine-core/src/libs/reflection/attr-reflection.ts +++ b/packages/@lwc/engine-core/src/libs/reflection/attr-reflection.ts @@ -5,7 +5,8 @@ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT */ -import { entries, isNull, toString, AriaAttrNameToPropNameMap } from '@lwc/shared'; +import { entries, isNull, toString } from '@lwc/shared/language'; +import { AriaAttrNameToPropNameMap } from '@lwc/shared/aria'; import type { LightningElement } from '../../framework/base-lightning-element'; /** diff --git a/packages/@lwc/engine-core/src/libs/signal-tracker/index.ts b/packages/@lwc/engine-core/src/libs/signal-tracker/index.ts index 4a6d04745b..363d329c7e 100644 --- a/packages/@lwc/engine-core/src/libs/signal-tracker/index.ts +++ b/packages/@lwc/engine-core/src/libs/signal-tracker/index.ts @@ -4,7 +4,7 @@ * SPDX-License-Identifier: MIT * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT */ -import { isFalse, isFunction, isUndefined } from '@lwc/shared'; +import { isFalse, isFunction, isUndefined } from '@lwc/shared/language'; import { logWarnOnce } from '../../shared/logger'; import type { Signal } from '@lwc/signals'; diff --git a/packages/@lwc/engine-core/src/patches/detect-non-standard-aria.ts b/packages/@lwc/engine-core/src/patches/detect-non-standard-aria.ts index 96470f3e8d..64db83a92f 100644 --- a/packages/@lwc/engine-core/src/patches/detect-non-standard-aria.ts +++ b/packages/@lwc/engine-core/src/patches/detect-non-standard-aria.ts @@ -5,7 +5,12 @@ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT */ -import { defineProperty, getOwnPropertyDescriptor, isNull, isUndefined } from '@lwc/shared'; +import { + defineProperty, + getOwnPropertyDescriptor, + isNull, + isUndefined, +} from '@lwc/shared/language'; import { onReportingEnabled, report, ReportingEventId } from '../framework/reporting'; import { logWarnOnce } from '../shared/logger'; import { getAssociatedVMIfPresent } from '../framework/vm'; diff --git a/packages/@lwc/engine-core/src/patches/detect-synthetic-cross-root-aria.ts b/packages/@lwc/engine-core/src/patches/detect-synthetic-cross-root-aria.ts index 62201b1ef2..8924b8d4a2 100644 --- a/packages/@lwc/engine-core/src/patches/detect-synthetic-cross-root-aria.ts +++ b/packages/@lwc/engine-core/src/patches/detect-synthetic-cross-root-aria.ts @@ -7,20 +7,22 @@ import { assign, isTrue, - KEY__NATIVE_GET_ELEMENT_BY_ID, - KEY__NATIVE_QUERY_SELECTOR_ALL, isNull, isUndefined, getOwnPropertyDescriptor, defineProperty, - ID_REFERENCING_ATTRIBUTES_SET, isString, isFunction, StringSplit, ArrayFilter, hasOwnProperty, +} from '@lwc/shared/language'; +import { + KEY__NATIVE_GET_ELEMENT_BY_ID, + KEY__NATIVE_QUERY_SELECTOR_ALL, KEY__SHADOW_TOKEN, -} from '@lwc/shared'; +} from '@lwc/shared/keys'; +import { ID_REFERENCING_ATTRIBUTES_SET } from '@lwc/shared/aria'; import { onReportingEnabled, report, ReportingEventId } from '../framework/reporting'; import { getAssociatedVMIfPresent } from '../framework/vm'; import { logWarnOnce } from '../shared/logger'; diff --git a/packages/@lwc/engine-core/src/shared/circular-module-dependencies.ts b/packages/@lwc/engine-core/src/shared/circular-module-dependencies.ts index 5848a488d1..cbfd7ba32a 100644 --- a/packages/@lwc/engine-core/src/shared/circular-module-dependencies.ts +++ b/packages/@lwc/engine-core/src/shared/circular-module-dependencies.ts @@ -5,7 +5,7 @@ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT */ -import { isFunction, hasOwnProperty } from '@lwc/shared'; +import { isFunction, hasOwnProperty } from '@lwc/shared/language'; interface MaybeModule { __esModule?: boolean; diff --git a/packages/@lwc/engine-core/src/shared/error.ts b/packages/@lwc/engine-core/src/shared/error.ts index 618aee7ab2..7c105025f7 100644 --- a/packages/@lwc/engine-core/src/shared/error.ts +++ b/packages/@lwc/engine-core/src/shared/error.ts @@ -5,7 +5,7 @@ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT */ -import { defineProperty, isFrozen, isUndefined } from '@lwc/shared'; +import { defineProperty, isFrozen, isUndefined } from '@lwc/shared/language'; import { getErrorComponentStack } from './format'; import type { VM } from '../framework/vm'; diff --git a/packages/@lwc/engine-core/src/shared/format.ts b/packages/@lwc/engine-core/src/shared/format.ts index daef8b604a..9825859d59 100644 --- a/packages/@lwc/engine-core/src/shared/format.ts +++ b/packages/@lwc/engine-core/src/shared/format.ts @@ -4,7 +4,7 @@ * SPDX-License-Identifier: MIT * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT */ -import { isNull, ArrayJoin, ArrayPush, StringToLowerCase } from '@lwc/shared'; +import { isNull, ArrayJoin, ArrayPush, StringToLowerCase } from '@lwc/shared/language'; import type { VM } from '../framework/vm'; diff --git a/packages/@lwc/engine-core/src/shared/logger.ts b/packages/@lwc/engine-core/src/shared/logger.ts index 75cbda3f67..a2bc9736e2 100644 --- a/packages/@lwc/engine-core/src/shared/logger.ts +++ b/packages/@lwc/engine-core/src/shared/logger.ts @@ -4,7 +4,7 @@ * SPDX-License-Identifier: MIT * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT */ -import { isUndefined } from '@lwc/shared'; +import { isUndefined } from '@lwc/shared/language'; import { getComponentStack } from './format'; import type { VM } from '../framework/vm'; diff --git a/packages/@lwc/engine-dom/src/apis/build-custom-element-constructor.ts b/packages/@lwc/engine-dom/src/apis/build-custom-element-constructor.ts index 69bd97842b..56031ec4fe 100644 --- a/packages/@lwc/engine-dom/src/apis/build-custom-element-constructor.ts +++ b/packages/@lwc/engine-dom/src/apis/build-custom-element-constructor.ts @@ -19,7 +19,7 @@ import { runFormStateRestoreCallback, BaseBridgeElement, } from '@lwc/engine-core'; -import { isNull } from '@lwc/shared'; +import { isNull } from '@lwc/shared/language'; import { renderer } from '../renderer'; import type { LightningElement, FormRestoreState, FormRestoreReason } from '@lwc/engine-core'; diff --git a/packages/@lwc/engine-dom/src/apis/create-element.ts b/packages/@lwc/engine-dom/src/apis/create-element.ts index 2dac8fa7e6..3c703dd9a9 100644 --- a/packages/@lwc/engine-dom/src/apis/create-element.ts +++ b/packages/@lwc/engine-dom/src/apis/create-element.ts @@ -5,7 +5,6 @@ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT */ import { - assert, assign, isFunction, isNull, @@ -13,7 +12,8 @@ import { isUndefined, toString, StringToLowerCase, -} from '@lwc/shared'; +} from '@lwc/shared/language'; +import * as assert from '@lwc/shared/assert'; import { createVM, connectRootElement, diff --git a/packages/@lwc/engine-dom/src/apis/hydrate-component.ts b/packages/@lwc/engine-dom/src/apis/hydrate-component.ts index 99c7d3f749..2efaa4e773 100644 --- a/packages/@lwc/engine-dom/src/apis/hydrate-component.ts +++ b/packages/@lwc/engine-dom/src/apis/hydrate-component.ts @@ -12,7 +12,7 @@ import { getAssociatedVMIfPresent, shouldBeFormAssociated, } from '@lwc/engine-core'; -import { StringToLowerCase, isFunction, isNull, isObject } from '@lwc/shared'; +import { StringToLowerCase, isFunction, isNull, isObject } from '@lwc/shared/language'; import { renderer } from '../renderer'; import type { LightningElement } from '@lwc/engine-core'; diff --git a/packages/@lwc/engine-dom/src/apis/is-node-from-template.ts b/packages/@lwc/engine-dom/src/apis/is-node-from-template.ts index fdeb85ebd9..c46054fbd2 100644 --- a/packages/@lwc/engine-dom/src/apis/is-node-from-template.ts +++ b/packages/@lwc/engine-dom/src/apis/is-node-from-template.ts @@ -5,13 +5,8 @@ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT */ -import { - getPrototypeOf, - hasOwnProperty, - isFalse, - isUndefined, - KEY__SHADOW_RESOLVER, -} from '@lwc/shared'; +import { getPrototypeOf, hasOwnProperty, isFalse, isUndefined } from '@lwc/shared/language'; +import { KEY__SHADOW_RESOLVER } from '@lwc/shared/keys'; import { renderer } from '../renderer'; // TODO [#2472]: Remove this workaround when appropriate. diff --git a/packages/@lwc/engine-dom/src/apis/lightning-element.ts b/packages/@lwc/engine-dom/src/apis/lightning-element.ts index e4b73f2128..e3ffc595f3 100644 --- a/packages/@lwc/engine-dom/src/apis/lightning-element.ts +++ b/packages/@lwc/engine-dom/src/apis/lightning-element.ts @@ -4,7 +4,7 @@ * SPDX-License-Identifier: MIT * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT */ -import { defineProperty, freeze, isUndefined, seal } from '@lwc/shared'; +import { defineProperty, freeze, isUndefined, seal } from '@lwc/shared/language'; import { LightningElement } from '@lwc/engine-core'; import { buildCustomElementConstructor } from './build-custom-element-constructor'; diff --git a/packages/@lwc/engine-dom/src/custom-elements/create-custom-element.ts b/packages/@lwc/engine-dom/src/custom-elements/create-custom-element.ts index 5819ca14cd..a8987e1ebd 100644 --- a/packages/@lwc/engine-dom/src/custom-elements/create-custom-element.ts +++ b/packages/@lwc/engine-dom/src/custom-elements/create-custom-element.ts @@ -4,7 +4,7 @@ * SPDX-License-Identifier: MIT * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT */ -import { isUndefined, isTrue } from '@lwc/shared'; +import { isUndefined, isTrue } from '@lwc/shared/language'; import { connectRootElement, disconnectRootElement, diff --git a/packages/@lwc/engine-dom/src/formatters/__tests__/component.spec.ts b/packages/@lwc/engine-dom/src/formatters/__tests__/component.spec.ts index 975a17c77d..6e27d86873 100644 --- a/packages/@lwc/engine-dom/src/formatters/__tests__/component.spec.ts +++ b/packages/@lwc/engine-dom/src/formatters/__tests__/component.spec.ts @@ -12,7 +12,7 @@ import { registerTemplate, registerDecorators, } from '@lwc/engine-dom'; -import { LOWEST_API_VERSION } from '@lwc/shared'; +import { LOWEST_API_VERSION } from '@lwc/shared/api-version'; // it needs to be imported from the window, otherwise the checks for associated vms is done against "@lwc/engine-core" const LightningElementFormatter = (globalThis as any)['devtoolsFormatters'].find((f: any) => { diff --git a/packages/@lwc/engine-dom/src/formatters/component.ts b/packages/@lwc/engine-dom/src/formatters/component.ts index cb0d14decd..92edd8c503 100644 --- a/packages/@lwc/engine-dom/src/formatters/component.ts +++ b/packages/@lwc/engine-dom/src/formatters/component.ts @@ -6,7 +6,7 @@ */ import { getAssociatedVMIfPresent } from '@lwc/engine-core'; -import { isUndefined, keys } from '@lwc/shared'; +import { isUndefined, keys } from '@lwc/shared/language'; import type { LightningElement } from '@lwc/engine-core'; /** diff --git a/packages/@lwc/engine-dom/src/formatters/index.ts b/packages/@lwc/engine-dom/src/formatters/index.ts index 26825ab299..161561c629 100644 --- a/packages/@lwc/engine-dom/src/formatters/index.ts +++ b/packages/@lwc/engine-dom/src/formatters/index.ts @@ -5,7 +5,7 @@ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT */ -import { ArrayPush } from '@lwc/shared'; +import { ArrayPush } from '@lwc/shared/language'; import { LightningElementFormatter } from './component'; function init() { diff --git a/packages/@lwc/engine-dom/src/language.ts b/packages/@lwc/engine-dom/src/language.ts index 7dad880067..647698234f 100644 --- a/packages/@lwc/engine-dom/src/language.ts +++ b/packages/@lwc/engine-dom/src/language.ts @@ -5,7 +5,7 @@ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT */ -import { getOwnPropertyDescriptors } from '@lwc/shared'; +import { getOwnPropertyDescriptors } from '@lwc/shared/language'; // Like @lwc/shared, but for DOM APIs diff --git a/packages/@lwc/engine-dom/src/renderer.ts b/packages/@lwc/engine-dom/src/renderer.ts index cfdd8c9eae..5890024268 100644 --- a/packages/@lwc/engine-dom/src/renderer.ts +++ b/packages/@lwc/engine-dom/src/renderer.ts @@ -5,7 +5,8 @@ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT */ -import { assign, hasOwnProperty, KEY__SHADOW_TOKEN, noop } from '@lwc/shared'; +import { assign, hasOwnProperty, noop } from '@lwc/shared/language'; +import { KEY__SHADOW_TOKEN } from '@lwc/shared/keys'; import { insertStylesheet } from './styles'; import { createCustomElement, diff --git a/packages/@lwc/engine-dom/src/renderer/index.ts b/packages/@lwc/engine-dom/src/renderer/index.ts index 10558f98c9..8e95e1578b 100644 --- a/packages/@lwc/engine-dom/src/renderer/index.ts +++ b/packages/@lwc/engine-dom/src/renderer/index.ts @@ -5,7 +5,8 @@ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT */ -import { assert, isNull, isUndefined } from '@lwc/shared'; +import { isNull, isUndefined } from '@lwc/shared/language'; +import * as assert from '@lwc/shared/assert'; import { ElementAttachShadow, ElementShadowRootGetter } from '../language'; function cloneNode(node: Node, deep: boolean): Node { diff --git a/packages/@lwc/engine-dom/src/styles.ts b/packages/@lwc/engine-dom/src/styles.ts index a050830d61..c3cf1ac10c 100644 --- a/packages/@lwc/engine-dom/src/styles.ts +++ b/packages/@lwc/engine-dom/src/styles.ts @@ -5,7 +5,7 @@ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT */ -import { isUndefined, isArray, isFunction } from '@lwc/shared'; +import { isUndefined, isArray, isFunction } from '@lwc/shared/language'; // // Feature detection diff --git a/packages/@lwc/engine-server/src/apis/lightning-element.ts b/packages/@lwc/engine-server/src/apis/lightning-element.ts index 9124da4a80..cd932677df 100644 --- a/packages/@lwc/engine-server/src/apis/lightning-element.ts +++ b/packages/@lwc/engine-server/src/apis/lightning-element.ts @@ -4,7 +4,7 @@ * SPDX-License-Identifier: MIT * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT */ -import { freeze, seal } from '@lwc/shared'; +import { freeze, seal } from '@lwc/shared/language'; import { LightningElement } from '@lwc/engine-core'; freeze(LightningElement); diff --git a/packages/@lwc/engine-server/src/apis/render-component.ts b/packages/@lwc/engine-server/src/apis/render-component.ts index 183b25e258..33be4deac7 100644 --- a/packages/@lwc/engine-server/src/apis/render-component.ts +++ b/packages/@lwc/engine-server/src/apis/render-component.ts @@ -5,7 +5,8 @@ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT */ import { createVM, connectRootElement } from '@lwc/engine-core'; -import { isString, isFunction, isObject, isNull, HTML_NAMESPACE } from '@lwc/shared'; +import { isString, isFunction, isObject, isNull } from '@lwc/shared/language'; +import { HTML_NAMESPACE } from '@lwc/shared/namespaces'; import { renderer } from '../renderer'; import { serializeElement } from '../serializer'; diff --git a/packages/@lwc/engine-server/src/context.ts b/packages/@lwc/engine-server/src/context.ts index ada99f110d..be414bbe3c 100644 --- a/packages/@lwc/engine-server/src/context.ts +++ b/packages/@lwc/engine-server/src/context.ts @@ -6,7 +6,7 @@ */ import { createContextProviderWithRegister, getAssociatedVMIfPresent } from '@lwc/engine-core'; -import { isUndefined, isNull } from '@lwc/shared'; +import { isUndefined, isNull } from '@lwc/shared/language'; import { HostNodeType, HostTypeKey, diff --git a/packages/@lwc/engine-server/src/polyfills.ts b/packages/@lwc/engine-server/src/polyfills.ts index bf09821e32..0705a0b2cb 100644 --- a/packages/@lwc/engine-server/src/polyfills.ts +++ b/packages/@lwc/engine-server/src/polyfills.ts @@ -5,7 +5,7 @@ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT */ -import { defineProperty } from '@lwc/shared'; +import { defineProperty } from '@lwc/shared/language'; /** * The following constructor might be used in either the constructor or the connectedCallback. In diff --git a/packages/@lwc/engine-server/src/renderer.ts b/packages/@lwc/engine-server/src/renderer.ts index 39dd4474a0..59b9066e48 100644 --- a/packages/@lwc/engine-server/src/renderer.ts +++ b/packages/@lwc/engine-server/src/renderer.ts @@ -4,18 +4,16 @@ * SPDX-License-Identifier: MIT * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT */ +import { isFunction, isNull, isUndefined, noop, StringToLowerCase } from '@lwc/shared/language'; + +import { HTML_NAMESPACE } from '@lwc/shared/namespaces'; + import { - HTML_NAMESPACE, htmlPropertyToAttribute, - isAriaAttribute, isBooleanAttribute, - isFunction, - isNull, - isUndefined, - noop, REFLECTIVE_GLOBAL_PROPERTY_SET, - StringToLowerCase, -} from '@lwc/shared'; +} from '@lwc/shared/html-attributes'; +import { isAriaAttribute } from '@lwc/shared/aria'; import { HostNodeType, diff --git a/packages/@lwc/engine-server/src/serializer.ts b/packages/@lwc/engine-server/src/serializer.ts index 91dc6df9d4..d88fef411a 100644 --- a/packages/@lwc/engine-server/src/serializer.ts +++ b/packages/@lwc/engine-server/src/serializer.ts @@ -5,7 +5,9 @@ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT */ -import { htmlEscape, HTML_NAMESPACE, isVoidElement } from '@lwc/shared'; +import { htmlEscape } from '@lwc/shared/html-escape'; +import { HTML_NAMESPACE } from '@lwc/shared/namespaces'; +import { isVoidElement } from '@lwc/shared/void-elements'; import { HostNodeType, diff --git a/packages/@lwc/errors/src/__tests__/errors.spec.ts b/packages/@lwc/errors/src/__tests__/errors.spec.ts index 7d77967dd5..1ca9c811da 100644 --- a/packages/@lwc/errors/src/__tests__/errors.spec.ts +++ b/packages/@lwc/errors/src/__tests__/errors.spec.ts @@ -7,7 +7,7 @@ import path from 'node:path'; import fs from 'node:fs'; import { describe, it, expect } from 'vitest'; -import { hasOwnProperty } from '@lwc/shared'; +import { hasOwnProperty } from '@lwc/shared/language'; import * as CompilerErrors from '../compiler/error-info'; import type { LWCErrorInfo } from '../shared/types'; diff --git a/packages/@lwc/features/src/index.ts b/packages/@lwc/features/src/index.ts index d85e8276ca..e8056ee53a 100644 --- a/packages/@lwc/features/src/index.ts +++ b/packages/@lwc/features/src/index.ts @@ -4,7 +4,7 @@ * SPDX-License-Identifier: MIT * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT */ -import { create, defineProperty, isUndefined, isBoolean } from '@lwc/shared'; +import { create, defineProperty, isUndefined, isBoolean } from '@lwc/shared/language'; import type { FeatureFlagMap, FeatureFlagName, FeatureFlagValue } from './types'; // When deprecating a feature flag, ensure that it is also no longer set in the application. For diff --git a/packages/@lwc/integration-karma/scripts/karma-plugins/env.js b/packages/@lwc/integration-karma/scripts/karma-plugins/env.js index fdef6900d6..d78e65f26d 100644 --- a/packages/@lwc/integration-karma/scripts/karma-plugins/env.js +++ b/packages/@lwc/integration-karma/scripts/karma-plugins/env.js @@ -14,7 +14,7 @@ const fs = require('fs'); const path = require('path'); -const { LWC_VERSION } = require('@lwc/shared'); +const { LWC_VERSION } = require('@lwc/shared/meta'); const { FORCE_NATIVE_SHADOW_MODE_FOR_TEST, ENABLE_ARIA_REFLECTION_GLOBAL_POLYFILL, diff --git a/packages/@lwc/integration-karma/scripts/shared/options.js b/packages/@lwc/integration-karma/scripts/shared/options.js index 22d47c3e47..82693dc8ce 100644 --- a/packages/@lwc/integration-karma/scripts/shared/options.js +++ b/packages/@lwc/integration-karma/scripts/shared/options.js @@ -7,7 +7,7 @@ 'use strict'; -const { HIGHEST_API_VERSION } = require('@lwc/shared'); +const { HIGHEST_API_VERSION } = require('@lwc/shared/api-version'); // Helpful error. Remove after a few months. if (process.env.NATIVE_SHADOW) { diff --git a/packages/@lwc/rollup-plugin/src/__tests__/apiVersion/apiVersion.spec.ts b/packages/@lwc/rollup-plugin/src/__tests__/apiVersion/apiVersion.spec.ts index f6e788d3a4..f60b4fac04 100644 --- a/packages/@lwc/rollup-plugin/src/__tests__/apiVersion/apiVersion.spec.ts +++ b/packages/@lwc/rollup-plugin/src/__tests__/apiVersion/apiVersion.spec.ts @@ -7,7 +7,7 @@ import path from 'node:path'; import { describe, it, expect } from 'vitest'; import { rollup } from 'rollup'; -import { APIVersion, HIGHEST_API_VERSION, LOWEST_API_VERSION } from '@lwc/shared'; +import { APIVersion, HIGHEST_API_VERSION, LOWEST_API_VERSION } from '@lwc/shared/api-version'; import lwc from '../../index'; import type { RollupLwcOptions } from '../../index'; diff --git a/packages/@lwc/rollup-plugin/src/__tests__/warnings/warnings.spec.ts b/packages/@lwc/rollup-plugin/src/__tests__/warnings/warnings.spec.ts index 1497c6af79..ace1ee86a1 100644 --- a/packages/@lwc/rollup-plugin/src/__tests__/warnings/warnings.spec.ts +++ b/packages/@lwc/rollup-plugin/src/__tests__/warnings/warnings.spec.ts @@ -7,7 +7,7 @@ import path from 'node:path'; import { describe, it, expect } from 'vitest'; import { rollup } from 'rollup'; -import { APIVersion } from '@lwc/shared'; +import { APIVersion } from '@lwc/shared/api-version'; import lwc from '../../index'; import type { RollupLog } from 'rollup'; diff --git a/packages/@lwc/rollup-plugin/src/index.ts b/packages/@lwc/rollup-plugin/src/index.ts index 6004939ad1..f2fff4f790 100644 --- a/packages/@lwc/rollup-plugin/src/index.ts +++ b/packages/@lwc/rollup-plugin/src/index.ts @@ -11,12 +11,12 @@ import { URLSearchParams } from 'url'; import pluginUtils from '@rollup/pluginutils'; import { transformSync } from '@lwc/compiler'; import { resolveModule, RegistryType } from '@lwc/module-resolver'; -import { getAPIVersionFromNumber } from '@lwc/shared'; +import { getAPIVersionFromNumber, type APIVersion } from '@lwc/shared/api-version'; import type { Plugin, SourceMapInput, RollupLog } from 'rollup'; import type { FilterPattern } from '@rollup/pluginutils'; import type { StylesheetConfig, DynamicImportConfig } from '@lwc/compiler'; import type { ModuleRecord } from '@lwc/module-resolver'; -import type { APIVersion, CompilationMode } from '@lwc/shared'; +import type { CompilationMode } from '@lwc/shared/ssr'; import type { CompilerDiagnostic } from '@lwc/errors'; export interface RollupLwcOptions { diff --git a/packages/@lwc/shared/package.json b/packages/@lwc/shared/package.json index 1e50886e42..a6fd799473 100644 --- a/packages/@lwc/shared/package.json +++ b/packages/@lwc/shared/package.json @@ -25,13 +25,19 @@ "volta": { "extends": "../../../package.json" }, - "main": "dist/index.cjs.js", - "module": "dist/index.js", - "types": "dist/index.d.ts", "files": [ "dist/**/*.js", "dist/**/*.d.ts" ], + "exports": { + "./*": { + "types": "./dist/*.d.ts", + "node": "./dist/*.cjs.js", + "development": "./src/*.ts", + "import": "./dist/*.js", + "require": "./dist/*.cjs.js" + } + }, "scripts": { "build": "rollup --config ../../../scripts/rollup/rollup.config.js", "dev": "rollup --config ../../../scripts/rollup/rollup.config.js --watch --no-watch.clearScreen" diff --git a/packages/@lwc/shared/src/__tests__/assert.spec.ts b/packages/@lwc/shared/src/__tests__/assert.spec.ts index 281bbb190e..0c2b7dc206 100644 --- a/packages/@lwc/shared/src/__tests__/assert.spec.ts +++ b/packages/@lwc/shared/src/__tests__/assert.spec.ts @@ -5,7 +5,7 @@ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT */ import { describe, it, expect } from 'vitest'; -import { assert } from '../index'; +import * as assert from '../assert'; describe('assert', () => { describe('#invariant()', () => { diff --git a/packages/@lwc/shared/src/api-version.ts b/packages/@lwc/shared/src/api-version.ts index 72bc130103..0da9a83e3c 100644 --- a/packages/@lwc/shared/src/api-version.ts +++ b/packages/@lwc/shared/src/api-version.ts @@ -7,7 +7,7 @@ import { isNumber } from './language'; -export const enum APIVersion { +export enum APIVersion { V58_244_SUMMER_23 = 58, V59_246_WINTER_24 = 59, V60_248_SPRING_24 = 60, @@ -59,7 +59,7 @@ export function getAPIVersionFromNumber(version: number | undefined): APIVersion return HIGHEST_API_VERSION; } -export const enum APIFeature { +export enum APIFeature { /** * Lowercase all scope tokens, enable the SVG static optimization */ diff --git a/packages/@lwc/shared/src/index.ts b/packages/@lwc/shared/src/index.ts index 9d2c1209c5..a1613397bb 100644 --- a/packages/@lwc/shared/src/index.ts +++ b/packages/@lwc/shared/src/index.ts @@ -4,6 +4,7 @@ * SPDX-License-Identifier: MIT * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT */ + import * as assert from './assert'; export * from './api-version'; diff --git a/packages/@lwc/shared/src/static-part-tokens.ts b/packages/@lwc/shared/src/static-part-tokens.ts index 925c545052..33c3028aef 100644 --- a/packages/@lwc/shared/src/static-part-tokens.ts +++ b/packages/@lwc/shared/src/static-part-tokens.ts @@ -5,7 +5,7 @@ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT */ -export const enum STATIC_PART_TOKEN_ID { +export enum STATIC_PART_TOKEN_ID { ATTRIBUTE = 'a', CLASS = 'c', STYLE = 's', diff --git a/packages/@lwc/signals/src/index.ts b/packages/@lwc/signals/src/index.ts index 1b7ffed106..a5e6ad345e 100644 --- a/packages/@lwc/signals/src/index.ts +++ b/packages/@lwc/signals/src/index.ts @@ -5,8 +5,8 @@ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT */ -import { addTrustedSignal } from '@lwc/shared'; -export { setTrustedSignalSet } from '@lwc/shared'; +import { addTrustedSignal } from '@lwc/shared/signals'; +export { setTrustedSignalSet } from '@lwc/shared/signals'; export type OnUpdate = () => void; export type Unsubscribe = () => void; diff --git a/packages/@lwc/ssr-compiler/src/__tests__/fixtures.spec.ts b/packages/@lwc/ssr-compiler/src/__tests__/fixtures.spec.ts index 6e5cb3bcf9..98d1e1292b 100644 --- a/packages/@lwc/ssr-compiler/src/__tests__/fixtures.spec.ts +++ b/packages/@lwc/ssr-compiler/src/__tests__/fixtures.spec.ts @@ -11,7 +11,7 @@ import { rollup } from 'rollup'; import lwcRollupPlugin from '@lwc/rollup-plugin'; import { testFixtureDir, formatHTML } from '@lwc/test-utils-lwc-internals'; import { serverSideRenderComponent } from '@lwc/ssr-runtime'; -import { DEFAULT_SSR_MODE, type CompilationMode } from '@lwc/shared'; +import { DEFAULT_SSR_MODE, type CompilationMode } from '@lwc/shared/ssr'; import { expectedFailures } from './utils/expected-failures'; import type { FeatureFlagName } from '@lwc/features/dist/types'; diff --git a/packages/@lwc/ssr-compiler/src/compile-js/index.ts b/packages/@lwc/ssr-compiler/src/compile-js/index.ts index a6386dcadf..edb3774711 100644 --- a/packages/@lwc/ssr-compiler/src/compile-js/index.ts +++ b/packages/@lwc/ssr-compiler/src/compile-js/index.ts @@ -27,7 +27,7 @@ import type { Decorator as EsDecorator, } from 'estree'; import type { Visitors, ComponentMetaState } from './types'; -import type { CompilationMode } from '@lwc/shared'; +import type { CompilationMode } from '@lwc/shared/ssr'; const visitors: Visitors = { $: { scope: true }, diff --git a/packages/@lwc/ssr-compiler/src/compile-template/index.ts b/packages/@lwc/ssr-compiler/src/compile-template/index.ts index 037d51299f..eecceb5abe 100644 --- a/packages/@lwc/ssr-compiler/src/compile-template/index.ts +++ b/packages/@lwc/ssr-compiler/src/compile-template/index.ts @@ -16,7 +16,7 @@ import { transmogrify } from '../transmogrify'; import { optimizeAdjacentYieldStmts } from './shared'; import { templateIrToEsTree } from './ir-to-es'; import type { ExportDefaultDeclaration as EsExportDefaultDeclaration } from 'estree'; -import type { CompilationMode } from '@lwc/shared'; +import type { CompilationMode } from '@lwc/shared/ssr'; // TODO [#4663]: Render mode mismatch between template and compiler should throw. const bExportTemplate = esTemplate` diff --git a/packages/@lwc/ssr-compiler/src/compile-template/shared.ts b/packages/@lwc/ssr-compiler/src/compile-template/shared.ts index 53d15230b5..0ae8edfcb4 100644 --- a/packages/@lwc/ssr-compiler/src/compile-template/shared.ts +++ b/packages/@lwc/ssr-compiler/src/compile-template/shared.ts @@ -6,7 +6,8 @@ */ import { builders as b, is } from 'estree-toolkit'; -import { normalizeStyleAttributeValue, StringReplace, StringTrim } from '@lwc/shared'; +import { StringReplace, StringTrim } from '@lwc/shared/language'; +import { normalizeStyleAttributeValue } from '@lwc/shared/style'; import { isValidES3Identifier } from '@babel/types'; import { expressionIrToEs } from './expression'; import type { TransformerContext } from './types'; diff --git a/packages/@lwc/ssr-compiler/src/compile-template/transformers/component/lwc-component.ts b/packages/@lwc/ssr-compiler/src/compile-template/transformers/component/lwc-component.ts index b7076424c9..28a21d10fe 100644 --- a/packages/@lwc/ssr-compiler/src/compile-template/transformers/component/lwc-component.ts +++ b/packages/@lwc/ssr-compiler/src/compile-template/transformers/component/lwc-component.ts @@ -5,7 +5,7 @@ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT */ import { is } from 'estree-toolkit'; -import { isUndefined } from '@lwc/shared'; +import { isUndefined } from '@lwc/shared/language'; import { expressionIrToEs } from '../../expression'; import { esTemplateWithYield } from '../../../estemplate'; import { getChildAttrsOrProps } from '../../shared'; diff --git a/packages/@lwc/ssr-compiler/src/compile-template/transformers/element.ts b/packages/@lwc/ssr-compiler/src/compile-template/transformers/element.ts index 66341e2355..11895c9a6c 100644 --- a/packages/@lwc/ssr-compiler/src/compile-template/transformers/element.ts +++ b/packages/@lwc/ssr-compiler/src/compile-template/transformers/element.ts @@ -6,12 +6,10 @@ */ import { builders as b, is } from 'estree-toolkit'; -import { - HTML_NAMESPACE, - isBooleanAttribute, - isVoidElement, - normalizeStyleAttributeValue, -} from '@lwc/shared'; +import { HTML_NAMESPACE } from '@lwc/shared/namespaces'; +import { isBooleanAttribute } from '@lwc/shared/html-attributes'; +import { isVoidElement } from '@lwc/shared/void-elements'; +import { normalizeStyleAttributeValue } from '@lwc/shared/style'; import { type Attribute as IrAttribute, type Expression as IrExpression, diff --git a/packages/@lwc/ssr-compiler/src/estree/validators.ts b/packages/@lwc/ssr-compiler/src/estree/validators.ts index 69fd7c813c..5da0111637 100644 --- a/packages/@lwc/ssr-compiler/src/estree/validators.ts +++ b/packages/@lwc/ssr-compiler/src/estree/validators.ts @@ -6,7 +6,7 @@ */ import { is } from 'estree-toolkit'; -import { entries } from '@lwc/shared'; +import { entries } from '@lwc/shared/language'; import type { Checker } from 'estree-toolkit/dist/generated/is-type'; import type { Node } from 'estree-toolkit/dist/helpers'; // estree's `Node` is not compatible? diff --git a/packages/@lwc/ssr-compiler/src/index.ts b/packages/@lwc/ssr-compiler/src/index.ts index fdef53a9a9..acf835dd89 100644 --- a/packages/@lwc/ssr-compiler/src/index.ts +++ b/packages/@lwc/ssr-compiler/src/index.ts @@ -5,7 +5,8 @@ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT */ -import { DEFAULT_SSR_MODE, type CompilationMode, generateCustomElementTagName } from '@lwc/shared'; +import { generateCustomElementTagName } from '@lwc/shared/custom-element'; +import { DEFAULT_SSR_MODE, type CompilationMode } from '@lwc/shared/ssr'; import compileJS from './compile-js'; import compileTemplate from './compile-template'; import type { ComponentTransformOptions, TemplateTransformOptions } from './shared'; diff --git a/packages/@lwc/ssr-runtime/src/index.ts b/packages/@lwc/ssr-runtime/src/index.ts index cfa9b8dd53..3e56545638 100644 --- a/packages/@lwc/ssr-runtime/src/index.ts +++ b/packages/@lwc/ssr-runtime/src/index.ts @@ -8,7 +8,9 @@ // Must be first so that later exports take precedence export * from './stubs'; -export { htmlEscape, setHooks, sanitizeHtmlContent, normalizeClass } from '@lwc/shared'; +export { htmlEscape } from '@lwc/shared/html-escape'; +export { setHooks, sanitizeHtmlContent } from '@lwc/shared/overridable-hooks'; +export { normalizeClass } from '@lwc/shared/normalize-class'; export { ClassList } from './class-list'; export { diff --git a/packages/@lwc/ssr-runtime/src/lightning-element.ts b/packages/@lwc/ssr-runtime/src/lightning-element.ts index 2c78d199a4..489466b13a 100644 --- a/packages/@lwc/ssr-runtime/src/lightning-element.ts +++ b/packages/@lwc/ssr-runtime/src/lightning-element.ts @@ -17,20 +17,22 @@ import { assign, defineProperties, hasOwnProperty, - htmlPropertyToAttribute, - isAriaAttribute, keys, - REFLECTIVE_GLOBAL_PROPERTY_SET, StringToLowerCase, toString, -} from '@lwc/shared'; +} from '@lwc/shared/language'; +import { + htmlPropertyToAttribute, + REFLECTIVE_GLOBAL_PROPERTY_SET, +} from '@lwc/shared/html-attributes'; +import { isAriaAttribute } from '@lwc/shared/aria'; import { ClassList } from './class-list'; import { mutationTracker } from './mutation-tracker'; import { descriptors as reflectionDescriptors } from './reflection'; import { getReadOnlyProxy } from './get-read-only-proxy'; import type { Attributes, Properties } from './types'; -import type { Stylesheets } from '@lwc/shared'; +import type { Stylesheets } from '@lwc/shared/style'; type EventListenerOrEventListenerObject = unknown; type AddEventListenerOptions = unknown; diff --git a/packages/@lwc/ssr-runtime/src/reflection.ts b/packages/@lwc/ssr-runtime/src/reflection.ts index d2488337ab..ea2e7652ea 100644 --- a/packages/@lwc/ssr-runtime/src/reflection.ts +++ b/packages/@lwc/ssr-runtime/src/reflection.ts @@ -5,7 +5,8 @@ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT */ -import { AriaAttrNameToPropNameMap, entries, isNull, toString } from '@lwc/shared'; +import { entries, isNull, toString } from '@lwc/shared/language'; +import { AriaAttrNameToPropNameMap } from '@lwc/shared/aria'; import type { LightningElement } from './lightning-element'; diff --git a/packages/@lwc/ssr-runtime/src/render-text-content.ts b/packages/@lwc/ssr-runtime/src/render-text-content.ts index 25f8402402..27a10fe6ca 100644 --- a/packages/@lwc/ssr-runtime/src/render-text-content.ts +++ b/packages/@lwc/ssr-runtime/src/render-text-content.ts @@ -5,7 +5,7 @@ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT */ -import { htmlEscape } from '@lwc/shared'; +import { htmlEscape } from '@lwc/shared/html-escape'; /** * Given an object, render it for use as a text content node. Not that this applies to individual text nodes, diff --git a/packages/@lwc/ssr-runtime/src/render.ts b/packages/@lwc/ssr-runtime/src/render.ts index 188c169ba7..5e15e0159d 100644 --- a/packages/@lwc/ssr-runtime/src/render.ts +++ b/packages/@lwc/ssr-runtime/src/render.ts @@ -4,14 +4,9 @@ * SPDX-License-Identifier: MIT * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT */ -import { - getOwnPropertyNames, - isNull, - isString, - isUndefined, - DEFAULT_SSR_MODE, - htmlEscape, -} from '@lwc/shared'; +import { getOwnPropertyNames, isNull, isString, isUndefined } from '@lwc/shared/language'; +import { DEFAULT_SSR_MODE } from '@lwc/shared/ssr'; +import { htmlEscape } from '@lwc/shared/html-escape'; import { mutationTracker } from './mutation-tracker'; import { SYMBOL__GENERATE_MARKUP } from './lightning-element'; import type { LightningElement, LightningElementConstructor } from './lightning-element'; diff --git a/packages/@lwc/ssr-runtime/src/styles.ts b/packages/@lwc/ssr-runtime/src/styles.ts index 5def046a00..3625f48479 100644 --- a/packages/@lwc/ssr-runtime/src/styles.ts +++ b/packages/@lwc/ssr-runtime/src/styles.ts @@ -4,10 +4,10 @@ * SPDX-License-Identifier: MIT * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT */ -import { isArray } from '@lwc/shared'; +import { isArray } from '@lwc/shared/language'; import { validateStyleTextContents } from './validate-style-text-contents'; import type { LightningElementConstructor } from './lightning-element'; -import type { Stylesheets, Stylesheet } from '@lwc/shared'; +import type { Stylesheets, Stylesheet } from '@lwc/shared/style'; type ForgivingStylesheets = | Stylesheets diff --git a/packages/@lwc/style-compiler/src/__tests__/index.spec.ts b/packages/@lwc/style-compiler/src/__tests__/index.spec.ts index b352b4558d..f8e3d60c03 100644 --- a/packages/@lwc/style-compiler/src/__tests__/index.spec.ts +++ b/packages/@lwc/style-compiler/src/__tests__/index.spec.ts @@ -7,7 +7,7 @@ import path from 'node:path'; import { describe } from 'vitest'; import { testFixtureDir } from '@lwc/test-utils-lwc-internals'; -import { LWC_VERSION } from '@lwc/shared'; +import { LWC_VERSION } from '@lwc/shared/meta'; import { transform } from '../index'; diff --git a/packages/@lwc/style-compiler/src/postcss-lwc-plugin.ts b/packages/@lwc/style-compiler/src/postcss-lwc-plugin.ts index 835b4ec838..bd68b4f251 100644 --- a/packages/@lwc/style-compiler/src/postcss-lwc-plugin.ts +++ b/packages/@lwc/style-compiler/src/postcss-lwc-plugin.ts @@ -12,7 +12,7 @@ import transformSelectorScoping from './selector-scoping/transform'; import transformDirPseudoClass from './dir-pseudo-class/transform'; import transformAtRules from './scope-at-rules/transform'; import type { SelectorScopingConfig } from './selector-scoping/transform'; -import type { APIVersion } from '@lwc/shared'; +import type { APIVersion } from '@lwc/shared/api-version'; import type { Rule, AtRule, TransformCallback } from 'postcss'; function shouldTransformSelector(rule: Rule) { diff --git a/packages/@lwc/style-compiler/src/serialize.ts b/packages/@lwc/style-compiler/src/serialize.ts index be88626c52..92d5739782 100644 --- a/packages/@lwc/style-compiler/src/serialize.ts +++ b/packages/@lwc/style-compiler/src/serialize.ts @@ -5,7 +5,8 @@ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT */ import postcss from 'postcss'; -import { KEY__SCOPED_CSS, LWC_VERSION_COMMENT, KEY__NATIVE_ONLY_CSS } from '@lwc/shared'; +import { KEY__SCOPED_CSS, KEY__NATIVE_ONLY_CSS } from '@lwc/shared/keys'; +import { LWC_VERSION_COMMENT } from '@lwc/shared/meta'; import { isImportMessage } from './utils/message'; import { HOST_ATTRIBUTE, SHADOW_ATTRIBUTE } from './utils/selectors-scoping'; import { diff --git a/packages/@lwc/style-compiler/src/transform.ts b/packages/@lwc/style-compiler/src/transform.ts index 52f50fe6a2..1e700d26f4 100644 --- a/packages/@lwc/style-compiler/src/transform.ts +++ b/packages/@lwc/style-compiler/src/transform.ts @@ -5,7 +5,7 @@ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT */ import postcss from 'postcss'; -import { getAPIVersionFromNumber } from '@lwc/shared'; +import { getAPIVersionFromNumber } from '@lwc/shared/api-version'; import serialize from './serialize'; import postcssLwc from './postcss-lwc-plugin'; diff --git a/packages/@lwc/synthetic-shadow/src/3rdparty/polymer/path-composer.ts b/packages/@lwc/synthetic-shadow/src/3rdparty/polymer/path-composer.ts index c5478fcd87..2d2adf0a81 100644 --- a/packages/@lwc/synthetic-shadow/src/3rdparty/polymer/path-composer.ts +++ b/packages/@lwc/synthetic-shadow/src/3rdparty/polymer/path-composer.ts @@ -15,7 +15,7 @@ Code distributed by Google as part of the polymer project is also subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt */ -import { isNull } from '@lwc/shared'; +import { isNull } from '@lwc/shared/language'; import { getOwnerDocument } from '../../shared/utils'; import { Node } from '../../env/node'; import { isSyntheticOrNativeShadowRoot } from '../../shared/utils'; diff --git a/packages/@lwc/synthetic-shadow/src/3rdparty/polymer/retarget.ts b/packages/@lwc/synthetic-shadow/src/3rdparty/polymer/retarget.ts index 47eb72cae6..540bbe4598 100644 --- a/packages/@lwc/synthetic-shadow/src/3rdparty/polymer/retarget.ts +++ b/packages/@lwc/synthetic-shadow/src/3rdparty/polymer/retarget.ts @@ -4,7 +4,7 @@ * SPDX-License-Identifier: MIT * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT */ -import { isNull, isUndefined } from '@lwc/shared'; +import { isNull, isUndefined } from '@lwc/shared/language'; import { isSyntheticOrNativeShadowRoot } from '../../shared/utils'; import { pathComposer } from './path-composer'; diff --git a/packages/@lwc/synthetic-shadow/src/env/document.ts b/packages/@lwc/synthetic-shadow/src/env/document.ts index 17344d5f73..77e7438d5d 100644 --- a/packages/@lwc/synthetic-shadow/src/env/document.ts +++ b/packages/@lwc/synthetic-shadow/src/env/document.ts @@ -4,7 +4,7 @@ * SPDX-License-Identifier: MIT * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT */ -import { getOwnPropertyDescriptor } from '@lwc/shared'; +import { getOwnPropertyDescriptor } from '@lwc/shared/language'; const DocumentPrototypeActiveElement: (this: Document) => Element | null = getOwnPropertyDescriptor( Document.prototype, diff --git a/packages/@lwc/synthetic-shadow/src/env/dom.ts b/packages/@lwc/synthetic-shadow/src/env/dom.ts index cac2b33109..c3a1d8ad29 100644 --- a/packages/@lwc/synthetic-shadow/src/env/dom.ts +++ b/packages/@lwc/synthetic-shadow/src/env/dom.ts @@ -4,7 +4,7 @@ * SPDX-License-Identifier: MIT * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT */ -import { getOwnPropertyDescriptor, hasOwnProperty } from '@lwc/shared'; +import { getOwnPropertyDescriptor, hasOwnProperty } from '@lwc/shared/language'; const eventTargetGetter: (this: Event) => EventTarget = getOwnPropertyDescriptor( Event.prototype, diff --git a/packages/@lwc/synthetic-shadow/src/env/element.ts b/packages/@lwc/synthetic-shadow/src/env/element.ts index 1ff759736d..75708bb025 100644 --- a/packages/@lwc/synthetic-shadow/src/env/element.ts +++ b/packages/@lwc/synthetic-shadow/src/env/element.ts @@ -4,7 +4,7 @@ * SPDX-License-Identifier: MIT * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT */ -import { hasOwnProperty, getOwnPropertyDescriptor } from '@lwc/shared'; +import { hasOwnProperty, getOwnPropertyDescriptor } from '@lwc/shared/language'; const { getAttribute, diff --git a/packages/@lwc/synthetic-shadow/src/env/node.ts b/packages/@lwc/synthetic-shadow/src/env/node.ts index 3a190be733..0890a4637a 100644 --- a/packages/@lwc/synthetic-shadow/src/env/node.ts +++ b/packages/@lwc/synthetic-shadow/src/env/node.ts @@ -4,7 +4,7 @@ * SPDX-License-Identifier: MIT * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT */ -import { getOwnPropertyDescriptor, hasOwnProperty } from '@lwc/shared'; +import { getOwnPropertyDescriptor, hasOwnProperty } from '@lwc/shared/language'; // TODO [#2472]: Remove this workaround when appropriate. // eslint-disable-next-line @lwc/lwc-internal/no-global-node diff --git a/packages/@lwc/synthetic-shadow/src/env/text.ts b/packages/@lwc/synthetic-shadow/src/env/text.ts index 1419d31a9e..69fd5a464e 100644 --- a/packages/@lwc/synthetic-shadow/src/env/text.ts +++ b/packages/@lwc/synthetic-shadow/src/env/text.ts @@ -5,7 +5,7 @@ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT */ -import { hasOwnProperty, getOwnPropertyDescriptor } from '@lwc/shared'; +import { hasOwnProperty, getOwnPropertyDescriptor } from '@lwc/shared/language'; export const assignedSlotGetter: (this: Text) => HTMLSlotElement | null = hasOwnProperty.call( Text.prototype, diff --git a/packages/@lwc/synthetic-shadow/src/faux-shadow/element.ts b/packages/@lwc/synthetic-shadow/src/faux-shadow/element.ts index 293c8608bf..1eda8be94f 100644 --- a/packages/@lwc/synthetic-shadow/src/faux-shadow/element.ts +++ b/packages/@lwc/synthetic-shadow/src/faux-shadow/element.ts @@ -14,8 +14,9 @@ import { hasOwnProperty, isNull, isUndefined, - KEY__SYNTHETIC_MODE, -} from '@lwc/shared'; +} from '@lwc/shared/language'; + +import { KEY__SYNTHETIC_MODE } from '@lwc/shared/keys'; import { attachShadow as originalAttachShadow, diff --git a/packages/@lwc/synthetic-shadow/src/faux-shadow/events.ts b/packages/@lwc/synthetic-shadow/src/faux-shadow/events.ts index c6d8b8fcb8..c6da14fe5f 100644 --- a/packages/@lwc/synthetic-shadow/src/faux-shadow/events.ts +++ b/packages/@lwc/synthetic-shadow/src/faux-shadow/events.ts @@ -16,7 +16,7 @@ import { isFunction, isUndefined, toString, -} from '@lwc/shared'; +} from '@lwc/shared/language'; import { isInstanceOfNativeShadowRoot } from '../env/shadow-root'; import { eventCurrentTargetGetter, eventTargetGetter } from '../env/dom'; diff --git a/packages/@lwc/synthetic-shadow/src/faux-shadow/focus.ts b/packages/@lwc/synthetic-shadow/src/faux-shadow/focus.ts index 2c1d86ac0a..4c3fedbea0 100644 --- a/packages/@lwc/synthetic-shadow/src/faux-shadow/focus.ts +++ b/packages/@lwc/synthetic-shadow/src/faux-shadow/focus.ts @@ -9,11 +9,12 @@ import { ArrayIndexOf, ArrayReverse, ArraySlice, - assert, isNull, isUndefined, toString, -} from '@lwc/shared'; +} from '@lwc/shared/language'; + +import * as assert from '@lwc/shared/assert'; import { addEventListener, removeEventListener } from '../env/event-target'; import { windowAddEventListener, windowRemoveEventListener } from '../env/window'; diff --git a/packages/@lwc/synthetic-shadow/src/faux-shadow/html-element.ts b/packages/@lwc/synthetic-shadow/src/faux-shadow/html-element.ts index 40fc80a890..d0c37678dc 100644 --- a/packages/@lwc/synthetic-shadow/src/faux-shadow/html-element.ts +++ b/packages/@lwc/synthetic-shadow/src/faux-shadow/html-element.ts @@ -4,7 +4,7 @@ * SPDX-License-Identifier: MIT * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT */ -import { isNull, isFalse, defineProperties, defineProperty } from '@lwc/shared'; +import { isNull, isFalse, defineProperties, defineProperty } from '@lwc/shared/language'; import { hasAttribute, diff --git a/packages/@lwc/synthetic-shadow/src/faux-shadow/legacy-shadow-token.ts b/packages/@lwc/synthetic-shadow/src/faux-shadow/legacy-shadow-token.ts index 30ba2562ca..bddf64828b 100644 --- a/packages/@lwc/synthetic-shadow/src/faux-shadow/legacy-shadow-token.ts +++ b/packages/@lwc/synthetic-shadow/src/faux-shadow/legacy-shadow-token.ts @@ -5,12 +5,8 @@ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT */ // TODO [#3733]: remove this entire file when we can remove legacy scope tokens -import { - defineProperty, - isUndefined, - KEY__LEGACY_SHADOW_TOKEN, - KEY__LEGACY_SHADOW_TOKEN_PRIVATE, -} from '@lwc/shared'; +import { defineProperty, isUndefined } from '@lwc/shared/language'; +import { KEY__LEGACY_SHADOW_TOKEN, KEY__LEGACY_SHADOW_TOKEN_PRIVATE } from '@lwc/shared/keys'; import { setAttribute, removeAttribute } from '../env/element'; export function getLegacyShadowToken(node: Node): string | undefined { diff --git a/packages/@lwc/synthetic-shadow/src/faux-shadow/no-patch-utils.ts b/packages/@lwc/synthetic-shadow/src/faux-shadow/no-patch-utils.ts index 07175ff694..4605b53fc9 100644 --- a/packages/@lwc/synthetic-shadow/src/faux-shadow/no-patch-utils.ts +++ b/packages/@lwc/synthetic-shadow/src/faux-shadow/no-patch-utils.ts @@ -4,7 +4,7 @@ * SPDX-License-Identifier: MIT * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT */ -import { ArrayFilter, ArraySlice, isNull, isUndefined } from '@lwc/shared'; +import { ArrayFilter, ArraySlice, isNull, isUndefined } from '@lwc/shared/language'; import { getNodeKey, getNodeNearestOwnerKey, getNodeOwnerKey } from '../shared/node-ownership'; import { isGlobalPatchingSkipped } from '../shared/utils'; diff --git a/packages/@lwc/synthetic-shadow/src/faux-shadow/node.ts b/packages/@lwc/synthetic-shadow/src/faux-shadow/node.ts index e1a7a89595..be76dc75e5 100644 --- a/packages/@lwc/synthetic-shadow/src/faux-shadow/node.ts +++ b/packages/@lwc/synthetic-shadow/src/faux-shadow/node.ts @@ -12,7 +12,7 @@ import { isNull, isTrue, isUndefined, -} from '@lwc/shared'; +} from '@lwc/shared/language'; import { Node } from '../env/node'; import { diff --git a/packages/@lwc/synthetic-shadow/src/faux-shadow/portal.ts b/packages/@lwc/synthetic-shadow/src/faux-shadow/portal.ts index 88f5b1c8d8..58997b203d 100644 --- a/packages/@lwc/synthetic-shadow/src/faux-shadow/portal.ts +++ b/packages/@lwc/synthetic-shadow/src/faux-shadow/portal.ts @@ -4,7 +4,7 @@ * SPDX-License-Identifier: MIT * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT */ -import { isUndefined, forEach, defineProperty, isTrue } from '@lwc/shared'; +import { isUndefined, forEach, defineProperty, isTrue } from '@lwc/shared/language'; import { childNodesGetter, compareDocumentPosition, Node } from '../env/node'; import { MutationObserver, MutationObserverObserve } from '../env/mutation-observer'; import { getShadowRootResolver, isSyntheticShadowHost, setShadowRootResolver } from './shadow-root'; diff --git a/packages/@lwc/synthetic-shadow/src/faux-shadow/shadow-root.ts b/packages/@lwc/synthetic-shadow/src/faux-shadow/shadow-root.ts index 2861346653..1479ae1747 100644 --- a/packages/@lwc/synthetic-shadow/src/faux-shadow/shadow-root.ts +++ b/packages/@lwc/synthetic-shadow/src/faux-shadow/shadow-root.ts @@ -12,14 +12,17 @@ import { isNull, isTrue, isUndefined, + setPrototypeOf, + getPrototypeOf, + isObject, +} from '@lwc/shared/language'; + +import { KEY__SHADOW_RESOLVER, KEY__SHADOW_RESOLVER_PRIVATE, KEY__NATIVE_GET_ELEMENT_BY_ID, KEY__NATIVE_QUERY_SELECTOR_ALL, - setPrototypeOf, - getPrototypeOf, - isObject, -} from '@lwc/shared'; +} from '@lwc/shared/keys'; import { innerHTMLSetter } from '../env/element'; import { dispatchEvent } from '../env/event-target'; diff --git a/packages/@lwc/synthetic-shadow/src/faux-shadow/shadow-token.ts b/packages/@lwc/synthetic-shadow/src/faux-shadow/shadow-token.ts index 755f75843b..5a8a2a7dc3 100644 --- a/packages/@lwc/synthetic-shadow/src/faux-shadow/shadow-token.ts +++ b/packages/@lwc/synthetic-shadow/src/faux-shadow/shadow-token.ts @@ -4,16 +4,14 @@ * SPDX-License-Identifier: MIT * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT */ +import { defineProperty, isUndefined, isNull } from '@lwc/shared/language'; import { - defineProperty, - isUndefined, KEY__SHADOW_TOKEN, KEY__SHADOW_TOKEN_PRIVATE, KEY__SHADOW_STATIC, KEY__SHADOW_STATIC_PRIVATE, KEY__SHADOW_RESOLVER, - isNull, -} from '@lwc/shared'; +} from '@lwc/shared/keys'; import { setAttribute, removeAttribute } from '../env/element'; import { firstChildGetter, nextSiblingGetter } from '../env/node'; diff --git a/packages/@lwc/synthetic-shadow/src/faux-shadow/slot.ts b/packages/@lwc/synthetic-shadow/src/faux-shadow/slot.ts index acd480a4a4..18c18d3784 100644 --- a/packages/@lwc/synthetic-shadow/src/faux-shadow/slot.ts +++ b/packages/@lwc/synthetic-shadow/src/faux-shadow/slot.ts @@ -5,7 +5,6 @@ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT */ import { - assert, defineProperties, ArrayFilter, ArrayIndexOf, @@ -16,7 +15,8 @@ import { isNull, isTrue, isUndefined, -} from '@lwc/shared'; +} from '@lwc/shared/language'; +import * as assert from '@lwc/shared/assert'; import { getAttribute, setAttribute, diff --git a/packages/@lwc/synthetic-shadow/src/faux-shadow/text.ts b/packages/@lwc/synthetic-shadow/src/faux-shadow/text.ts index 42ccce9648..59ffceb0c4 100644 --- a/packages/@lwc/synthetic-shadow/src/faux-shadow/text.ts +++ b/packages/@lwc/synthetic-shadow/src/faux-shadow/text.ts @@ -5,7 +5,7 @@ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT */ -import { defineProperties } from '@lwc/shared'; +import { defineProperties } from '@lwc/shared/language'; import { assignedSlotGetterPatched } from './slot'; // Non-deep-traversing patches: this descriptor map includes all descriptors that diff --git a/packages/@lwc/synthetic-shadow/src/faux-shadow/traverse.ts b/packages/@lwc/synthetic-shadow/src/faux-shadow/traverse.ts index dbfe589bd6..ec1aef8f7e 100644 --- a/packages/@lwc/synthetic-shadow/src/faux-shadow/traverse.ts +++ b/packages/@lwc/synthetic-shadow/src/faux-shadow/traverse.ts @@ -4,7 +4,7 @@ * SPDX-License-Identifier: MIT * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT */ -import { ArrayReduce, ArrayPush, isNull, isUndefined, ArrayFilter } from '@lwc/shared'; +import { ArrayReduce, ArrayPush, isNull, isUndefined, ArrayFilter } from '@lwc/shared/language'; import { arrayFromCollection } from '../shared/utils'; import { getNodeKey, getNodeNearestOwnerKey, isNodeShadowed } from '../shared/node-ownership'; diff --git a/packages/@lwc/synthetic-shadow/src/polyfills/clipboard-event-composed/main.ts b/packages/@lwc/synthetic-shadow/src/polyfills/clipboard-event-composed/main.ts index 26f8849e9e..0b88550fbd 100644 --- a/packages/@lwc/synthetic-shadow/src/polyfills/clipboard-event-composed/main.ts +++ b/packages/@lwc/synthetic-shadow/src/polyfills/clipboard-event-composed/main.ts @@ -4,7 +4,7 @@ * SPDX-License-Identifier: MIT * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT */ -import { assign, create, defineProperties } from '@lwc/shared'; +import { assign, create, defineProperties } from '@lwc/shared/language'; // Note that ClipboardEvent is undefined in Jest/jsdom // See: https://github.com/jsdom/jsdom/issues/1568 diff --git a/packages/@lwc/synthetic-shadow/src/polyfills/document-shadow/polyfill.ts b/packages/@lwc/synthetic-shadow/src/polyfills/document-shadow/polyfill.ts index ebdc10d3ff..558a190334 100644 --- a/packages/@lwc/synthetic-shadow/src/polyfills/document-shadow/polyfill.ts +++ b/packages/@lwc/synthetic-shadow/src/polyfills/document-shadow/polyfill.ts @@ -12,7 +12,7 @@ import { getOwnPropertyDescriptor, isNull, isUndefined, -} from '@lwc/shared'; +} from '@lwc/shared/language'; import { DocumentPrototypeActiveElement, getElementById as documentGetElementById, diff --git a/packages/@lwc/synthetic-shadow/src/polyfills/event-target/polyfill.ts b/packages/@lwc/synthetic-shadow/src/polyfills/event-target/polyfill.ts index 1ed6f8dd56..375bba1c3c 100644 --- a/packages/@lwc/synthetic-shadow/src/polyfills/event-target/polyfill.ts +++ b/packages/@lwc/synthetic-shadow/src/polyfills/event-target/polyfill.ts @@ -4,7 +4,7 @@ * SPDX-License-Identifier: MIT * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT */ -import { ArraySlice, defineProperties } from '@lwc/shared'; +import { ArraySlice, defineProperties } from '@lwc/shared/language'; import { addEventListener as nativeAddEventListener, eventTargetPrototype, diff --git a/packages/@lwc/synthetic-shadow/src/polyfills/event/polyfill.ts b/packages/@lwc/synthetic-shadow/src/polyfills/event/polyfill.ts index c503e9d6ef..17231150b2 100644 --- a/packages/@lwc/synthetic-shadow/src/polyfills/event/polyfill.ts +++ b/packages/@lwc/synthetic-shadow/src/polyfills/event/polyfill.ts @@ -4,7 +4,7 @@ * SPDX-License-Identifier: MIT * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT */ -import { defineProperties, isNull, isUndefined } from '@lwc/shared'; +import { defineProperties, isNull, isUndefined } from '@lwc/shared/language'; import { pathComposer } from '../../3rdparty/polymer/path-composer'; import { retarget } from '../../3rdparty/polymer/retarget'; diff --git a/packages/@lwc/synthetic-shadow/src/polyfills/mutation-observer/polyfill.ts b/packages/@lwc/synthetic-shadow/src/polyfills/mutation-observer/polyfill.ts index 8f22389ce2..88da006e5f 100644 --- a/packages/@lwc/synthetic-shadow/src/polyfills/mutation-observer/polyfill.ts +++ b/packages/@lwc/synthetic-shadow/src/polyfills/mutation-observer/polyfill.ts @@ -14,7 +14,7 @@ import { forEach, isNull, isUndefined, -} from '@lwc/shared'; +} from '@lwc/shared/language'; import { isSyntheticShadowRoot } from '../../faux-shadow/shadow-root'; import { getNodeKey, getNodeNearestOwnerKey } from '../../shared/node-ownership'; diff --git a/packages/@lwc/synthetic-shadow/src/shared/event-target.ts b/packages/@lwc/synthetic-shadow/src/shared/event-target.ts index fd76f0f082..2f629e2132 100644 --- a/packages/@lwc/synthetic-shadow/src/shared/event-target.ts +++ b/packages/@lwc/synthetic-shadow/src/shared/event-target.ts @@ -4,7 +4,8 @@ * SPDX-License-Identifier: MIT * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT */ -import { assert, isFalse, isFunction, isNull, isObject, isUndefined } from '@lwc/shared'; +import { isFalse, isFunction, isNull, isObject, isUndefined } from '@lwc/shared/language'; +import * as assert from '@lwc/shared/assert'; import { eventCurrentTargetGetter } from '../env/dom'; import { getActualTarget } from '../faux-shadow/events'; import { isSyntheticShadowHost } from '../faux-shadow/shadow-root'; diff --git a/packages/@lwc/synthetic-shadow/src/shared/faux-element-from-point.ts b/packages/@lwc/synthetic-shadow/src/shared/faux-element-from-point.ts index 6317297e9d..d7c030e9ac 100644 --- a/packages/@lwc/synthetic-shadow/src/shared/faux-element-from-point.ts +++ b/packages/@lwc/synthetic-shadow/src/shared/faux-element-from-point.ts @@ -4,7 +4,7 @@ * SPDX-License-Identifier: MIT * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT */ -import { isNull } from '@lwc/shared'; +import { isNull } from '@lwc/shared/language'; import { elementFromPoint } from '../env/document'; import { retarget } from '../3rdparty/polymer/retarget'; import { pathComposer } from '../3rdparty/polymer/path-composer'; diff --git a/packages/@lwc/synthetic-shadow/src/shared/faux-elements-from-point.ts b/packages/@lwc/synthetic-shadow/src/shared/faux-elements-from-point.ts index 91fbb4043f..6f821776c6 100644 --- a/packages/@lwc/synthetic-shadow/src/shared/faux-elements-from-point.ts +++ b/packages/@lwc/synthetic-shadow/src/shared/faux-elements-from-point.ts @@ -4,7 +4,7 @@ * SPDX-License-Identifier: MIT * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT */ -import { ArrayIndexOf, ArrayPush, isNull, isUndefined } from '@lwc/shared'; +import { ArrayIndexOf, ArrayPush, isNull, isUndefined } from '@lwc/shared/language'; import { elementsFromPoint } from '../env/document'; import { isSyntheticSlotElement } from '../faux-shadow/traverse'; diff --git a/packages/@lwc/synthetic-shadow/src/shared/node-ownership.ts b/packages/@lwc/synthetic-shadow/src/shared/node-ownership.ts index eac9d58502..8200415004 100644 --- a/packages/@lwc/synthetic-shadow/src/shared/node-ownership.ts +++ b/packages/@lwc/synthetic-shadow/src/shared/node-ownership.ts @@ -4,7 +4,7 @@ * SPDX-License-Identifier: MIT * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT */ -import { defineProperty, isNull, isUndefined } from '@lwc/shared'; +import { defineProperty, isNull, isUndefined } from '@lwc/shared/language'; import { parentNodeGetter } from '../env/node'; import { isSyntheticSlotElement } from '../faux-shadow/traverse'; diff --git a/packages/@lwc/synthetic-shadow/src/shared/retarget-related-target.ts b/packages/@lwc/synthetic-shadow/src/shared/retarget-related-target.ts index d9693ed7bb..2de20789f7 100644 --- a/packages/@lwc/synthetic-shadow/src/shared/retarget-related-target.ts +++ b/packages/@lwc/synthetic-shadow/src/shared/retarget-related-target.ts @@ -4,7 +4,7 @@ * SPDX-License-Identifier: MIT * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT */ -import { defineProperty, getOwnPropertyDescriptor, isNull } from '@lwc/shared'; +import { defineProperty, getOwnPropertyDescriptor, isNull } from '@lwc/shared/language'; import { pathComposer } from '../3rdparty/polymer/path-composer'; import { retarget } from '../3rdparty/polymer/retarget'; diff --git a/packages/@lwc/synthetic-shadow/src/shared/static-html-collection.ts b/packages/@lwc/synthetic-shadow/src/shared/static-html-collection.ts index bcd1bb8245..fe02adbcd0 100644 --- a/packages/@lwc/synthetic-shadow/src/shared/static-html-collection.ts +++ b/packages/@lwc/synthetic-shadow/src/shared/static-html-collection.ts @@ -4,7 +4,7 @@ * SPDX-License-Identifier: MIT * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT */ -import { create, defineProperty, forEach, setPrototypeOf } from '@lwc/shared'; +import { create, defineProperty, forEach, setPrototypeOf } from '@lwc/shared/language'; import { getAttribute } from '../env/element'; diff --git a/packages/@lwc/synthetic-shadow/src/shared/static-node-list.ts b/packages/@lwc/synthetic-shadow/src/shared/static-node-list.ts index 2152d61e4b..73eedb1cb0 100644 --- a/packages/@lwc/synthetic-shadow/src/shared/static-node-list.ts +++ b/packages/@lwc/synthetic-shadow/src/shared/static-node-list.ts @@ -4,7 +4,7 @@ * SPDX-License-Identifier: MIT * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT */ -import { ArrayMap, create, defineProperty, forEach, setPrototypeOf } from '@lwc/shared'; +import { ArrayMap, create, defineProperty, forEach, setPrototypeOf } from '@lwc/shared/language'; const Items = new WeakMap(); diff --git a/packages/@lwc/synthetic-shadow/src/shared/utils.ts b/packages/@lwc/synthetic-shadow/src/shared/utils.ts index 77613845e8..740b84994f 100644 --- a/packages/@lwc/synthetic-shadow/src/shared/utils.ts +++ b/packages/@lwc/synthetic-shadow/src/shared/utils.ts @@ -4,7 +4,7 @@ * SPDX-License-Identifier: MIT * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT */ -import { isUndefined, isTrue } from '@lwc/shared'; +import { isUndefined, isTrue } from '@lwc/shared/language'; import { ownerDocumentGetter } from '../env/node'; import { defaultViewGetter } from '../env/document'; import { getAttribute } from '../env/element'; diff --git a/packages/@lwc/template-compiler/src/__tests__/config.spec.ts b/packages/@lwc/template-compiler/src/__tests__/config.spec.ts index 2ae907a918..48701ee7ef 100644 --- a/packages/@lwc/template-compiler/src/__tests__/config.spec.ts +++ b/packages/@lwc/template-compiler/src/__tests__/config.spec.ts @@ -5,7 +5,7 @@ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT */ import { describe, it, expect } from 'vitest'; -import { HIGHEST_API_VERSION } from '@lwc/shared'; +import { HIGHEST_API_VERSION } from '@lwc/shared/api-version'; import { normalizeConfig } from '../config'; describe('customRendererConfig normalization', () => { diff --git a/packages/@lwc/template-compiler/src/__tests__/fixtures.spec.ts b/packages/@lwc/template-compiler/src/__tests__/fixtures.spec.ts index 168ba72f2e..725ce42676 100644 --- a/packages/@lwc/template-compiler/src/__tests__/fixtures.spec.ts +++ b/packages/@lwc/template-compiler/src/__tests__/fixtures.spec.ts @@ -6,7 +6,7 @@ */ import path from 'node:path'; import { describe } from 'vitest'; -import { LWC_VERSION } from '@lwc/shared'; +import { LWC_VERSION } from '@lwc/shared/meta'; import prettier from 'prettier'; import { testFixtureDir } from '@lwc/test-utils-lwc-internals'; diff --git a/packages/@lwc/template-compiler/src/codegen/codegen.ts b/packages/@lwc/template-compiler/src/codegen/codegen.ts index 690d89a435..692a1577d5 100644 --- a/packages/@lwc/template-compiler/src/codegen/codegen.ts +++ b/packages/@lwc/template-compiler/src/codegen/codegen.ts @@ -5,15 +5,11 @@ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT */ import { walk } from 'estree-walker'; -import { - getAPIVersionFromNumber, - SVG_NAMESPACE, - STATIC_PART_TOKEN_ID, - isUndefined, - APIFeature, - isAPIFeatureEnabled, -} from '@lwc/shared'; +import { isUndefined } from '@lwc/shared/language'; +import { getAPIVersionFromNumber, isAPIFeatureEnabled, APIFeature } from '@lwc/shared/api-version'; +import { SVG_NAMESPACE } from '@lwc/shared/namespaces'; +import { STATIC_PART_TOKEN_ID } from '@lwc/shared/static-part-tokens'; import * as t from '../shared/estree'; import { LWCDirectiveRenderMode } from '../shared/types'; import { @@ -63,7 +59,7 @@ import type { KeyDirective, StaticChildNode, } from '../shared/types'; -import type { APIVersion } from '@lwc/shared'; +import type { APIVersion } from '@lwc/shared/api-version'; import type { Node } from 'estree'; // structuredClone is only available in Node 17+ diff --git a/packages/@lwc/template-compiler/src/codegen/expression.ts b/packages/@lwc/template-compiler/src/codegen/expression.ts index 35088eea89..7170f7aff2 100644 --- a/packages/@lwc/template-compiler/src/codegen/expression.ts +++ b/packages/@lwc/template-compiler/src/codegen/expression.ts @@ -7,7 +7,7 @@ import { walk } from 'estree-walker'; import { ParserDiagnostics, invariant } from '@lwc/errors'; -import { isBooleanAttribute } from '@lwc/shared'; +import { isBooleanAttribute } from '@lwc/shared/html-attributes'; import * as t from '../shared/estree'; import { TEMPLATE_PARAMS } from '../shared/constants'; import { isProperty, isStringLiteral } from '../shared/ast'; diff --git a/packages/@lwc/template-compiler/src/codegen/helpers.ts b/packages/@lwc/template-compiler/src/codegen/helpers.ts index b5887a1107..38ae92b86c 100644 --- a/packages/@lwc/template-compiler/src/codegen/helpers.ts +++ b/packages/@lwc/template-compiler/src/codegen/helpers.ts @@ -4,7 +4,8 @@ * SPDX-License-Identifier: MIT * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT */ -import { APIFeature, IMPORTANT_FLAG, isAPIFeatureEnabled } from '@lwc/shared'; +import { APIFeature, isAPIFeatureEnabled } from '@lwc/shared/api-version'; +import { IMPORTANT_FLAG } from '@lwc/shared/style'; import * as t from '../shared/estree'; import { toPropertyName } from '../shared/utils'; import { LWCDirectiveRenderMode } from '../shared/types'; diff --git a/packages/@lwc/template-compiler/src/codegen/index.ts b/packages/@lwc/template-compiler/src/codegen/index.ts index 1ec8350198..fc4a9f9fab 100644 --- a/packages/@lwc/template-compiler/src/codegen/index.ts +++ b/packages/@lwc/template-compiler/src/codegen/index.ts @@ -6,15 +6,13 @@ */ import * as astring from 'astring'; -import { - isBooleanAttribute, - SVG_NAMESPACE, - LWC_VERSION_COMMENT, - isUndefined, - parseStyleText, -} from '@lwc/shared'; +import { isUndefined } from '@lwc/shared/language'; import { CompilerMetrics, generateCompilerError, TemplateErrors } from '@lwc/errors'; +import { isBooleanAttribute } from '@lwc/shared/html-attributes'; +import { parseStyleText } from '@lwc/shared/style'; +import { SVG_NAMESPACE } from '@lwc/shared/namespaces'; +import { LWC_VERSION_COMMENT } from '@lwc/shared/meta'; import { isComment, isText, diff --git a/packages/@lwc/template-compiler/src/codegen/static-element-serializer.ts b/packages/@lwc/template-compiler/src/codegen/static-element-serializer.ts index ea44498094..774d04c2cb 100644 --- a/packages/@lwc/template-compiler/src/codegen/static-element-serializer.ts +++ b/packages/@lwc/template-compiler/src/codegen/static-element-serializer.ts @@ -4,12 +4,10 @@ * SPDX-License-Identifier: MIT * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT */ -import { - HTML_NAMESPACE, - htmlEscape, - isVoidElement, - normalizeStyleAttributeValue, -} from '@lwc/shared'; +import { HTML_NAMESPACE } from '@lwc/shared/namespaces'; +import { normalizeStyleAttributeValue } from '@lwc/shared/style'; +import { htmlEscape } from '@lwc/shared/html-escape'; +import { isVoidElement } from '@lwc/shared/void-elements'; import { isAllowedFragOnlyUrlsXHTML, isFragmentOnlyUrl, diff --git a/packages/@lwc/template-compiler/src/codegen/static-element.ts b/packages/@lwc/template-compiler/src/codegen/static-element.ts index 89dc42937c..f89c6650d4 100644 --- a/packages/@lwc/template-compiler/src/codegen/static-element.ts +++ b/packages/@lwc/template-compiler/src/codegen/static-element.ts @@ -4,15 +4,9 @@ * SPDX-License-Identifier: MIT * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT */ -import { - APIFeature, - ArrayEvery, - ArraySome, - HTML_NAMESPACE, - isAPIFeatureEnabled, - isArray, - isNull, -} from '@lwc/shared'; +import { ArrayEvery, ArraySome, isArray, isNull } from '@lwc/shared/language'; +import { APIFeature, isAPIFeatureEnabled } from '@lwc/shared/api-version'; +import { HTML_NAMESPACE } from '@lwc/shared/namespaces'; import { isBaseElement, isComment, @@ -32,7 +26,7 @@ import type { StaticChildNode, Text, } from '../shared/types'; -import type { APIVersion } from '@lwc/shared'; +import type { APIVersion } from '@lwc/shared/api-version'; // This set keeps track of static safe elements that have dynamic text in their direct children. const STATIC_ELEMENT_WITH_DYNAMIC_TEXT_SET = new WeakSet(); diff --git a/packages/@lwc/template-compiler/src/config.ts b/packages/@lwc/template-compiler/src/config.ts index dcf6169958..0b0d86341d 100644 --- a/packages/@lwc/template-compiler/src/config.ts +++ b/packages/@lwc/template-compiler/src/config.ts @@ -5,7 +5,8 @@ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT */ import { TemplateErrors, invariant, generateCompilerError } from '@lwc/errors'; -import { getAPIVersionFromNumber, hasOwnProperty } from '@lwc/shared'; +import { hasOwnProperty } from '@lwc/shared/language'; +import { getAPIVersionFromNumber } from '@lwc/shared/api-version'; import { isCustomElementTag } from './shared/utils'; import type { CustomRendererConfig } from './shared/renderer-hooks'; import type { InstrumentationObject } from '@lwc/errors'; diff --git a/packages/@lwc/template-compiler/src/parser/attribute.ts b/packages/@lwc/template-compiler/src/parser/attribute.ts index 342781d406..1674054222 100644 --- a/packages/@lwc/template-compiler/src/parser/attribute.ts +++ b/packages/@lwc/template-compiler/src/parser/attribute.ts @@ -5,14 +5,9 @@ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT */ import { ParserDiagnostics } from '@lwc/errors'; -import { - isAriaAttribute, - isBooleanAttribute, - isGlobalHtmlAttribute, - HTML_NAMESPACE, - SVG_NAMESPACE, - ID_REFERENCING_ATTRIBUTES_SET, -} from '@lwc/shared'; +import { isBooleanAttribute, isGlobalHtmlAttribute } from '@lwc/shared/html-attributes'; +import { isAriaAttribute, ID_REFERENCING_ATTRIBUTES_SET } from '@lwc/shared/aria'; +import { HTML_NAMESPACE, SVG_NAMESPACE } from '@lwc/shared/namespaces'; import { isComponent, isExternalComponent, isLwcComponent } from '../shared/ast'; import { toPropertyName } from '../shared/utils'; diff --git a/packages/@lwc/template-compiler/src/parser/constants.ts b/packages/@lwc/template-compiler/src/parser/constants.ts index d6010fd267..209f223540 100644 --- a/packages/@lwc/template-compiler/src/parser/constants.ts +++ b/packages/@lwc/template-compiler/src/parser/constants.ts @@ -4,12 +4,9 @@ * SPDX-License-Identifier: MIT * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT */ -import { - AriaAttrNameToPropNameMap, - ArrayFrom, - fromEntries, - SPECIAL_PROPERTY_ATTRIBUTE_MAPPING, -} from '@lwc/shared'; +import { ArrayFrom, fromEntries } from '@lwc/shared/language'; +import { AriaAttrNameToPropNameMap } from '@lwc/shared/aria'; +import { SPECIAL_PROPERTY_ATTRIBUTE_MAPPING } from '@lwc/shared/html-attributes'; import { ElementDirectiveName } from '../shared/types'; import { HTML_ELEMENTS } from './utils/html-elements'; import { SVG_ELEMENTS } from './utils/svg-elements'; diff --git a/packages/@lwc/template-compiler/src/parser/expression-complex/index.ts b/packages/@lwc/template-compiler/src/parser/expression-complex/index.ts index 4d12fa4445..7bcf345ef4 100644 --- a/packages/@lwc/template-compiler/src/parser/expression-complex/index.ts +++ b/packages/@lwc/template-compiler/src/parser/expression-complex/index.ts @@ -4,7 +4,7 @@ * SPDX-License-Identifier: MIT * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT */ -import { APIFeature, isAPIFeatureEnabled } from '@lwc/shared'; +import { APIFeature, isAPIFeatureEnabled } from '@lwc/shared/api-version'; import type ParserCtx from '../parser'; export * from './types'; diff --git a/packages/@lwc/template-compiler/src/parser/html.ts b/packages/@lwc/template-compiler/src/parser/html.ts index f7e563cec3..9dd2857474 100644 --- a/packages/@lwc/template-compiler/src/parser/html.ts +++ b/packages/@lwc/template-compiler/src/parser/html.ts @@ -8,7 +8,7 @@ import * as parse5 from 'parse5'; import * as he from 'he'; import { ParserDiagnostics } from '@lwc/errors'; -import { APIFeature, isAPIFeatureEnabled } from '@lwc/shared'; +import { APIFeature, isAPIFeatureEnabled } from '@lwc/shared/api-version'; import { sourceLocation } from '../shared/ast'; import { errorCodesToErrorOn, errorCodesToWarnOnInOlderAPIVersions } from './parse5Errors'; @@ -36,7 +36,10 @@ function getLwcErrorFromParse5Error(ctx: ParserCtx, code: string) { } } -export function parseHTML(ctx: ParserCtx, source: string) { +export function parseHTML( + ctx: ParserCtx, + source: string +): parse5.DefaultTreeAdapterTypes.DocumentFragment { const onParseError = (err: parse5.ParserError) => { const { code, ...location } = err; diff --git a/packages/@lwc/template-compiler/src/parser/index.ts b/packages/@lwc/template-compiler/src/parser/index.ts index 995bad66bb..4c8331ec2d 100644 --- a/packages/@lwc/template-compiler/src/parser/index.ts +++ b/packages/@lwc/template-compiler/src/parser/index.ts @@ -4,14 +4,9 @@ * SPDX-License-Identifier: MIT * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT */ -import { - HTML_NAMESPACE, - SVG_NAMESPACE, - MATHML_NAMESPACE, - isVoidElement, - isUndefined, - isNull, -} from '@lwc/shared'; +import { isUndefined, isNull } from '@lwc/shared/language'; +import { HTML_NAMESPACE, SVG_NAMESPACE, MATHML_NAMESPACE } from '@lwc/shared/namespaces'; +import { isVoidElement } from '@lwc/shared/void-elements'; import { ParserDiagnostics, DiagnosticLevel, CompilerMetrics } from '@lwc/errors'; import * as parse5Tools from '@parse5/tools'; diff --git a/packages/@lwc/template-compiler/src/parser/parser.ts b/packages/@lwc/template-compiler/src/parser/parser.ts index aefab34fac..d9ae8a2d6c 100644 --- a/packages/@lwc/template-compiler/src/parser/parser.ts +++ b/packages/@lwc/template-compiler/src/parser/parser.ts @@ -19,7 +19,7 @@ import type { Location, LWCErrorInfo, } from '@lwc/errors'; -import type { APIVersion } from '@lwc/shared'; +import type { APIVersion } from '@lwc/shared/api-version'; import type { NormalizedConfig } from '../config'; import type { Root, diff --git a/packages/@lwc/template-compiler/src/parser/utils/html-element-attributes.ts b/packages/@lwc/template-compiler/src/parser/utils/html-element-attributes.ts index 65656a67ff..5d258d50de 100644 --- a/packages/@lwc/template-compiler/src/parser/utils/html-element-attributes.ts +++ b/packages/@lwc/template-compiler/src/parser/utils/html-element-attributes.ts @@ -29,7 +29,7 @@ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -import { hasOwnProperty } from '@lwc/shared'; +import { hasOwnProperty } from '@lwc/shared/language'; // This mapping is based on https://github.com/wooorm/html-element-attributes/blob/270d8ce/index.js // TODO [#3019]: use the package directly instead of vendor'ing it diff --git a/packages/@lwc/template-compiler/src/shared/ast.ts b/packages/@lwc/template-compiler/src/shared/ast.ts index 016d582943..d5795b28e1 100644 --- a/packages/@lwc/template-compiler/src/shared/ast.ts +++ b/packages/@lwc/template-compiler/src/shared/ast.ts @@ -4,7 +4,7 @@ * SPDX-License-Identifier: MIT * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT */ -import { HTML_NAMESPACE } from '@lwc/shared'; +import { HTML_NAMESPACE } from '@lwc/shared/namespaces'; import type { Token as parse5TokenInfo } from 'parse5'; import type { Literal, diff --git a/packages/@lwc/template-compiler/src/shared/utils.ts b/packages/@lwc/template-compiler/src/shared/utils.ts index fa5e7b16de..9e5cbb4f94 100644 --- a/packages/@lwc/template-compiler/src/shared/utils.ts +++ b/packages/@lwc/template-compiler/src/shared/utils.ts @@ -4,7 +4,7 @@ * SPDX-License-Identifier: MIT * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT */ -import { StringCharAt } from '@lwc/shared'; +import { StringCharAt } from '@lwc/shared/language'; import { DASHED_TAGNAME_ELEMENT_SET } from './constants'; export function toPropertyName(attr: string) { diff --git a/packages/@lwc/wire-service/src/index.ts b/packages/@lwc/wire-service/src/index.ts index e92cb0de44..94756c09e0 100644 --- a/packages/@lwc/wire-service/src/index.ts +++ b/packages/@lwc/wire-service/src/index.ts @@ -4,7 +4,7 @@ * SPDX-License-Identifier: MIT * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT */ -import { isUndefined } from '@lwc/shared'; +import { isUndefined } from '@lwc/shared/language'; import { ValueChangedEvent } from './value-changed-event'; import type { WireConfigValue, WireAdapter, WireDataCallback } from '@lwc/engine-core'; diff --git a/packages/lwc/__tests__/isomorphic-exports.spec.ts b/packages/lwc/__tests__/isomorphic-exports.spec.ts index 18fcb5e791..d04c868aac 100644 --- a/packages/lwc/__tests__/isomorphic-exports.spec.ts +++ b/packages/lwc/__tests__/isomorphic-exports.spec.ts @@ -35,9 +35,6 @@ describe('isomorphic package exports', () => { for (const exp of superExports) { baseExports.delete(exp); } - expect(Array.from(baseExports)).toEqual([ - // Exports that intentionally only exist in @lwc/engine-server - 'default', // artifact of interop support - ]); + expect(Array.from(baseExports)).toEqual([]); }); }); diff --git a/packages/lwc/shared.d.ts b/packages/lwc/shared.d.ts index 2e105cba3a..58291bdd6a 100644 --- a/packages/lwc/shared.d.ts +++ b/packages/lwc/shared.d.ts @@ -4,4 +4,4 @@ * SPDX-License-Identifier: MIT * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT */ -export type * from '@lwc/shared'; +export type * from '@lwc/shared/language'; diff --git a/scripts/rollup/package.json b/scripts/rollup/package.json new file mode 100644 index 0000000000..cf76f3cb6c --- /dev/null +++ b/scripts/rollup/package.json @@ -0,0 +1,7 @@ +{ + "name": "@lwc/rollup-config", + "version": "0.0.0", + "private": true, + "type": "module", + "module": "rollup.config.js" +} diff --git a/scripts/rollup/rollup.config.js b/scripts/rollup/rollup.config.js index ca267b48de..b782637481 100644 --- a/scripts/rollup/rollup.config.js +++ b/scripts/rollup/rollup.config.js @@ -5,28 +5,37 @@ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT */ +// @ts-check /* eslint-env node */ -const { readFileSync } = require('node:fs'); -const path = require('node:path'); -const MagicString = require('magic-string'); -const { rollup } = require('rollup'); -const replace = require('@rollup/plugin-replace'); -const typescript = require('@rollup/plugin-typescript'); -const { nodeResolve } = require('@rollup/plugin-node-resolve'); -const { BUNDLED_DEPENDENCIES } = require('../shared/bundled-dependencies.js'); +import { readFileSync } from 'node:fs'; +import { resolve, join, relative, extname } from 'node:path'; +import { globSync } from 'glob'; +import MagicString from 'magic-string'; +import { rollup } from 'rollup'; +import replace from '@rollup/plugin-replace'; +import typescript from '@rollup/plugin-typescript'; +import { nodeResolve } from '@rollup/plugin-node-resolve'; +import { BUNDLED_DEPENDENCIES } from '../shared/bundled-dependencies.js'; // The assumption is that the build script for each sub-package runs in that sub-package's directory const packageRoot = process.cwd(); -const packageJson = JSON.parse(readFileSync(path.resolve(packageRoot, './package.json'), 'utf-8')); -const { name: packageName, version, dependencies, peerDependencies } = packageJson; + +/** + * @type {import('nx/src/utils/package-json.js').PackageJson} + */ +const pkg = JSON.parse(readFileSync(resolve(packageRoot, './package.json'), 'utf-8')); // This copyright text should match the text in the header/header eslint rule let banner = `/**\n * Copyright (c) ${new Date().getFullYear()} Salesforce, Inc.\n */`; -let footer = `/** version: ${version} */`; +let footer = `/** version: ${pkg.version} */`; const { ROLLUP_WATCH: watchMode } = process.env; + +/** + * @type {import('rollup').ModuleFormat[]} + */ const formats = ['es', 'cjs']; -if (packageName === '@lwc/synthetic-shadow') { +if (pkg.name === '@lwc/synthetic-shadow') { // Here we wrap all of synthetic shadow in a check for lwcRuntimeFlags.ENABLE_FORCE_SHADOW_MIGRATE_MODE and // lwcRuntimeFlags.DISABLE_SYNTHETIC_SHADOW, so that synthetic shadow is not loaded if either flag is set. // Note that lwcRuntimeFlags must be referenced as a pure global, or else string replacement in ESBuild @@ -43,6 +52,9 @@ if (packageName === '@lwc/synthetic-shadow') { footer += '\n}'; } +/** + * @type {import('rollup').WarningHandlerWithDefault} warning + */ const onwarn = ({ code, message }) => { if (!process.env.ROLLUP_WATCH && code !== 'CIRCULAR_DEPENDENCY') { throw new Error(message); @@ -50,16 +62,19 @@ const onwarn = ({ code, message }) => { }; // These plugins are used both by the main Rollup build as well as our sub-Rollup build (injectInlineRenderer). +/** + * @returns {import('rollup').Plugin[]} + */ function sharedPlugins() { - const engineBrowserConfig = ['@lwc/engine-server', '@lwc/engine-dom'].includes(packageName) && { + const engineBrowserConfig = ['@lwc/engine-server', '@lwc/engine-dom'].includes(pkg.name) && { // This is only used inside @lwc/engine-dom and @lwc/engine-server // Elsewhere, it _not_ be replaced, so that it can be replaced later (e.g. in @lwc/engine-core) - 'process.env.IS_BROWSER': packageName === '@lwc/engine-dom' ? 'true' : 'false', + 'process.env.IS_BROWSER': pkg.name === '@lwc/engine-dom' ? 'true' : 'false', }; return [ typescript({ - tsconfig: path.join(packageRoot, 'tsconfig.json'), + tsconfig: join(packageRoot, 'tsconfig.json'), exclude: ['**/__tests__/**'], noEmitOnError: !watchMode, // in watch mode, do not exit with an error if typechecking fails ...(watchMode && { @@ -71,7 +86,7 @@ function sharedPlugins() { replace({ values: { ...engineBrowserConfig, - 'process.env.LWC_VERSION': JSON.stringify(version), + 'process.env.LWC_VERSION': JSON.stringify(pkg.version), }, preventAssignment: true, }), @@ -83,6 +98,9 @@ function sharedPlugins() { // The reasons for this are due to how Locker does sandboxing. // So we run Rollup inside of a Rollup plugin to accomplish this. This resolves all dependencies and // builds them as an IIFE, which can then be injected into the source as process.env.RENDERER. +/** + * @returns {import('rollup').Plugin} + */ function injectInlineRenderer() { const rendererReplacementString = 'process.env.RENDERER'; @@ -92,8 +110,8 @@ function injectInlineRenderer() { async transform(source) { if (source.includes(rendererReplacementString)) { const bundle = await rollup({ - input: path.resolve( - __dirname, + input: resolve( + import.meta.dirname, '../../packages/@lwc/engine-dom/src/renderer/index.ts' ), @@ -136,18 +154,13 @@ function injectInlineRenderer() { }; } -module.exports = { - input: path.resolve(packageRoot, './src/index.ts'), +/** + * @type {import('rollup').RollupOptions} + */ +export default { + input: generateInputConfig(), - output: formats.map((format) => ({ - file: `dist/index${format === 'cjs' ? '.cjs' : ''}.js`, - sourcemap: true, - format, - banner, - footer, - exports: 'named', - esModule: true, - })), + output: formats.map(createOutputConfig), plugins: [ nodeResolve({ @@ -164,5 +177,57 @@ module.exports = { onwarn, - external: [...Object.keys(dependencies || {}), ...Object.keys(peerDependencies || {})], + external: [...Object.keys(pkg.dependencies || {}), ...Object.keys(pkg.peerDependencies || {})], }; + +/** + * @returns {import('rollup').InputOption} + */ +function generateInputConfig() { + if (pkg.name === '@lwc/shared') { + return Object.fromEntries( + globSync('src/*.ts', { root: packageRoot }).map((file) => [ + // This remove `src/` as well as the file extension from each + // file, so e.g. src/nested/foo.js becomes nested/foo + relative(`${packageRoot}/src`, file.slice(0, file.length - extname(file).length)), + // This expands the relative paths to absolute paths, so e.g. + // src/nested/foo becomes /project/src/nested/foo.js + resolve(packageRoot, file), + ]) + ); + } + return resolve(packageRoot, './src/index.ts'); +} + +/** + * @param {import('rollup').ModuleFormat} format + * @returns {import('rollup').OutputOptions} + */ +function createOutputConfig(format) { + if (pkg.name === '@lwc/shared') { + const ext = format === 'es' ? 'js' : `${format}.js`; + + + return { + dir: 'dist', + sourcemap: true, + format, + banner, + footer, + exports: 'named', + esModule: true, + preserveModules: true, + entryFileNames: `[name].${ext}`, + }; + } + + return { + file: format === 'es' ? pkg.module : pkg.main, + sourcemap: true, + format, + banner, + footer, + exports: 'named', + esModule: true, + }; +} diff --git a/scripts/tasks/check-and-rewrite-package-json.js b/scripts/tasks/check-and-rewrite-package-json.js index cf3c5e6fab..7c4691173e 100644 --- a/scripts/tasks/check-and-rewrite-package-json.js +++ b/scripts/tasks/check-and-rewrite-package-json.js @@ -47,7 +47,8 @@ for (const dir of globSync('./packages/@lwc/*')) { continue; } - const { name, description, version, dependencies, devDependencies, peerDependencies } = pkg; + const { name, description, version, dependencies, devDependencies, peerDependencies, exports } = + pkg; let { keywords } = pkg; // Keywords aren't really important, but keep any that already exist and add 'lwc' @@ -72,6 +73,7 @@ for (const dir of globSync('./packages/@lwc/*')) { types: 'dist/index.d.ts', // It's important _not_ to use `./dist` here (with the `./`), because npm does not understand that files: ['dist/**/*.js', 'dist/**/*.d.ts'], + ...(exports && { exports }), scripts: { build: 'rollup --config ../../../scripts/rollup/rollup.config.js', dev: 'rollup --config ../../../scripts/rollup/rollup.config.js --watch --no-watch.clearScreen', diff --git a/scripts/test-utils/format-html.ts b/scripts/test-utils/format-html.ts index 18a0b27ef6..cfe5d064d1 100644 --- a/scripts/test-utils/format-html.ts +++ b/scripts/test-utils/format-html.ts @@ -5,7 +5,8 @@ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT */ -import { HTML_NAMESPACE, isVoidElement } from '@lwc/shared'; +import { HTML_NAMESPACE } from '@lwc/shared/namespaces'; +import { isVoidElement } from '@lwc/shared/void-elements'; /** * Naive HTML fragment formatter. diff --git a/tsconfig.json b/tsconfig.json index 2774c7162d..61ed0cedeb 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -6,8 +6,10 @@ "declarationMap": true, "sourceMap": true, - "module": "commonjs", - "moduleResolution": "node", + "module": "Preserve", + "moduleResolution": "bundler", + "moduleDetection": "force", + "resolvePackageJsonExports": true, "esModuleInterop": true, "target": "es2021", diff --git a/vitest.shared.mjs b/vitest.shared.mjs index 43908edc09..5b81640cbc 100644 --- a/vitest.shared.mjs +++ b/vitest.shared.mjs @@ -11,28 +11,6 @@ export default defineConfig({ printBasicPrototype: true, callToJSON: true, }, - // To properly resolve `const enum`, we need to point to the TypeScript source files - // See https://github.com/vitest-dev/vitest/discussions/3964 - // Using `src` also ensures that the test coverage is accurately reported - alias: Object.fromEntries( - [ - 'aria-reflection', - 'babel-plugin-component', - 'compiler', - 'errors', - 'features', - 'module-resolver', - 'rollup-plugin', - 'shared', - 'signals', - 'ssr-compiler', - 'ssr-runtime', - 'style-compiler', - 'synthetic-shadow', - 'template-compiler', - 'wire-service', - ].map((dep) => [`@lwc/${dep}`, `@lwc/${dep}/src`]) - ), }, define: { 'process.env.LWC_VERSION': JSON.stringify(pkg.version), diff --git a/yarn.lock b/yarn.lock index df389be172..d0f9dcf540 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3014,10 +3014,10 @@ "@typescript-eslint/types" "8.20.0" eslint-visitor-keys "^4.2.0" -"@vitest/coverage-v8@^3.0.3": - version "3.0.3" - resolved "https://registry.yarnpkg.com/@vitest/coverage-v8/-/coverage-v8-3.0.3.tgz#8e7339b0b2ec36b0d1facd43f73d96ce185301bf" - integrity sha512-uVbJ/xhImdNtzPnLyxCZJMTeTIYdgcC2nWtBBBpR1H6z0w8m7D+9/zrDIx2nNxgMg9r+X8+RY2qVpUDeW2b3nw== +"@vitest/coverage-v8@^3.0.4": + version "3.0.4" + resolved "https://registry.yarnpkg.com/@vitest/coverage-v8/-/coverage-v8-3.0.4.tgz#01b2d295cf664be9545228f364fa6495bc066a45" + integrity sha512-f0twgRCHgbs24Dp8cLWagzcObXMcuKtAwgxjJV/nnysPAJJk1JiKu/W0gIehZLmkljhJXU/E0/dmuQzsA/4jhA== dependencies: "@ampproject/remapping" "^2.3.0" "@bcoe/v8-coverage" "^1.0.2" @@ -3037,22 +3037,22 @@ resolved "https://registry.yarnpkg.com/@vitest/eslint-plugin/-/eslint-plugin-1.1.25.tgz#0e2ed719844b52edc88a0467f11f80162ebbebf0" integrity sha512-u8DpDnMbPcqBmJOB4PeEtn6q7vKmLVTLFMpzoxSAo0hjYdl4iYSHRleqwPQo0ywc7UV0S6RKIahYRQ3BnZdMVw== -"@vitest/expect@3.0.3": - version "3.0.3" - resolved "https://registry.yarnpkg.com/@vitest/expect/-/expect-3.0.3.tgz#a83af04a68e70a9af8aa6f68442a696b4bc599c5" - integrity sha512-SbRCHU4qr91xguu+dH3RUdI5dC86zm8aZWydbp961aIR7G8OYNN6ZiayFuf9WAngRbFOfdrLHCGgXTj3GtoMRQ== +"@vitest/expect@3.0.4": + version "3.0.4" + resolved "https://registry.yarnpkg.com/@vitest/expect/-/expect-3.0.4.tgz#95c0a73980e99a30d3994c35b4468c4bb257d093" + integrity sha512-Nm5kJmYw6P2BxhJPkO3eKKhGYKRsnqJqf+r0yOGRKpEP+bSCBDsjXgiu1/5QFrnPMEgzfC38ZEjvCFgaNBC0Eg== dependencies: - "@vitest/spy" "3.0.3" - "@vitest/utils" "3.0.3" + "@vitest/spy" "3.0.4" + "@vitest/utils" "3.0.4" chai "^5.1.2" tinyrainbow "^2.0.0" -"@vitest/mocker@3.0.3": - version "3.0.3" - resolved "https://registry.yarnpkg.com/@vitest/mocker/-/mocker-3.0.3.tgz#f63a7e2e93fecaab1046038f3a9f60ea6b369173" - integrity sha512-XT2XBc4AN9UdaxJAeIlcSZ0ILi/GzmG5G8XSly4gaiqIvPV3HMTSIDZWJVX6QRJ0PX1m+W8Cy0K9ByXNb/bPIA== +"@vitest/mocker@3.0.4": + version "3.0.4" + resolved "https://registry.yarnpkg.com/@vitest/mocker/-/mocker-3.0.4.tgz#91eba38f720d47aa708d1bcc5e4c7d885b1fc435" + integrity sha512-gEef35vKafJlfQbnyOXZ0Gcr9IBUsMTyTLXsEQwuyYAerpHqvXhzdBnDFuHLpFqth3F7b6BaFr4qV/Cs1ULx5A== dependencies: - "@vitest/spy" "3.0.3" + "@vitest/spy" "3.0.4" estree-walker "^3.0.3" magic-string "^0.30.17" @@ -3063,29 +3063,29 @@ dependencies: tinyrainbow "^1.2.0" -"@vitest/pretty-format@3.0.3", "@vitest/pretty-format@^3.0.3": - version "3.0.3" - resolved "https://registry.yarnpkg.com/@vitest/pretty-format/-/pretty-format-3.0.3.tgz#4bd59463d1c944c22287c3da2060785269098183" - integrity sha512-gCrM9F7STYdsDoNjGgYXKPq4SkSxwwIU5nkaQvdUxiQ0EcNlez+PdKOVIsUJvh9P9IeIFmjn4IIREWblOBpP2Q== +"@vitest/pretty-format@3.0.4", "@vitest/pretty-format@^3.0.4": + version "3.0.4" + resolved "https://registry.yarnpkg.com/@vitest/pretty-format/-/pretty-format-3.0.4.tgz#18d5da3bad9a0eebf49f5c5daa84d0d5f7d2bbfa" + integrity sha512-ts0fba+dEhK2aC9PFuZ9LTpULHpY/nd6jhAQ5IMU7Gaj7crPCTdCFfgvXxruRBLFS+MLraicCuFXxISEq8C93g== dependencies: tinyrainbow "^2.0.0" -"@vitest/runner@3.0.3": - version "3.0.3" - resolved "https://registry.yarnpkg.com/@vitest/runner/-/runner-3.0.3.tgz#c123e3225ccdd52c5a8e45edb59340ec8dcb6df2" - integrity sha512-Rgi2kOAk5ZxWZlwPguRJFOBmWs6uvvyAAR9k3MvjRvYrG7xYvKChZcmnnpJCS98311CBDMqsW9MzzRFsj2gX3g== +"@vitest/runner@3.0.4": + version "3.0.4" + resolved "https://registry.yarnpkg.com/@vitest/runner/-/runner-3.0.4.tgz#5bdc965c32721c7cf025481124f73589deea313a" + integrity sha512-dKHzTQ7n9sExAcWH/0sh1elVgwc7OJ2lMOBrAm73J7AH6Pf9T12Zh3lNE1TETZaqrWFXtLlx3NVrLRb5hCK+iw== dependencies: - "@vitest/utils" "3.0.3" - pathe "^2.0.1" + "@vitest/utils" "3.0.4" + pathe "^2.0.2" -"@vitest/snapshot@3.0.3": - version "3.0.3" - resolved "https://registry.yarnpkg.com/@vitest/snapshot/-/snapshot-3.0.3.tgz#a20a8cfa0e7434ef94f4dff40d946a57922119de" - integrity sha512-kNRcHlI4txBGztuJfPEJ68VezlPAXLRT1u5UCx219TU3kOG2DplNxhWLwDf2h6emwmTPogzLnGVwP6epDaJN6Q== +"@vitest/snapshot@3.0.4": + version "3.0.4" + resolved "https://registry.yarnpkg.com/@vitest/snapshot/-/snapshot-3.0.4.tgz#7e64c19ca1ab9abb2f01fd246817b5f0404798fd" + integrity sha512-+p5knMLwIk7lTQkM3NonZ9zBewzVp9EVkVpvNta0/PlFWpiqLaRcF4+33L1it3uRUCh0BGLOaXPPGEjNKfWb4w== dependencies: - "@vitest/pretty-format" "3.0.3" + "@vitest/pretty-format" "3.0.4" magic-string "^0.30.17" - pathe "^2.0.1" + pathe "^2.0.2" "@vitest/snapshot@^2.0.5", "@vitest/snapshot@^2.1.1": version "2.1.8" @@ -3096,32 +3096,32 @@ magic-string "^0.30.12" pathe "^1.1.2" -"@vitest/spy@3.0.3": - version "3.0.3" - resolved "https://registry.yarnpkg.com/@vitest/spy/-/spy-3.0.3.tgz#ea4e5f7f8b3513e3ac0e556557e4ed339edc82e8" - integrity sha512-7/dgux8ZBbF7lEIKNnEqQlyRaER9nkAL9eTmdKJkDO3hS8p59ATGwKOCUDHcBLKr7h/oi/6hP+7djQk8049T2A== +"@vitest/spy@3.0.4": + version "3.0.4" + resolved "https://registry.yarnpkg.com/@vitest/spy/-/spy-3.0.4.tgz#966fd3422ba093568a6a33c437751a91061f8622" + integrity sha512-sXIMF0oauYyUy2hN49VFTYodzEAu744MmGcPR3ZBsPM20G+1/cSW/n1U+3Yu/zHxX2bIDe1oJASOkml+osTU6Q== dependencies: tinyspy "^3.0.2" -"@vitest/ui@^3.0.3": - version "3.0.3" - resolved "https://registry.yarnpkg.com/@vitest/ui/-/ui-3.0.3.tgz#5dd455981935172eda4a9a4979f589b33bbcbd09" - integrity sha512-kGavHxFA3dETa61mgzdvxc3u/JSCiHR2o/0Z99IE8EAwtFxSLZeb2MofPKNVCPY3IAIcTx4blH57BJ1GuiRAUA== +"@vitest/ui@^3.0.4": + version "3.0.4" + resolved "https://registry.yarnpkg.com/@vitest/ui/-/ui-3.0.4.tgz#751e5ec7e00201adeb0a75a07e57f34c9c9b6eb4" + integrity sha512-e+s2F9e9FUURkZ5aFIe1Fi3Y8M7UF6gEuShcaV/ur7y/Ldri+1tzWQ1TJq9Vas42NXnXvCAIrU39Z4U2RyET6g== dependencies: - "@vitest/utils" "3.0.3" + "@vitest/utils" "3.0.4" fflate "^0.8.2" flatted "^3.3.2" - pathe "^2.0.1" + pathe "^2.0.2" sirv "^3.0.0" tinyglobby "^0.2.10" tinyrainbow "^2.0.0" -"@vitest/utils@3.0.3": - version "3.0.3" - resolved "https://registry.yarnpkg.com/@vitest/utils/-/utils-3.0.3.tgz#25d5a2e0cd0b5529132b76482fd48139ca56c197" - integrity sha512-f+s8CvyzPtMFY1eZKkIHGhPsQgYo5qCm6O8KZoim9qm1/jT64qBgGpO5tHscNH6BzRHM+edLNOP+3vO8+8pE/A== +"@vitest/utils@3.0.4": + version "3.0.4" + resolved "https://registry.yarnpkg.com/@vitest/utils/-/utils-3.0.4.tgz#9dd2336170097b20a6e5b778bb5ea7786cc56008" + integrity sha512-8BqC1ksYsHtbWH+DfpOAKrFw3jl3Uf9J7yeFh85Pz52IWuh1hBBtyfEbRNNZNjl8H8A5yMLH9/t+k7HIKzQcZQ== dependencies: - "@vitest/pretty-format" "3.0.3" + "@vitest/pretty-format" "3.0.4" loupe "^3.1.2" tinyrainbow "^2.0.0" @@ -9922,7 +9922,7 @@ pathe@^1.1.2: resolved "https://registry.yarnpkg.com/pathe/-/pathe-1.1.2.tgz#6c4cb47a945692e48a1ddd6e4094d170516437ec" integrity sha512-whLdWMYL2TwI08hn8/ZqAbrVemu0LNaNNJZX73O6qaIdCTfXutsLhMkjdENX0qhsQ9uIimo4/aQOmXkoon2nDQ== -pathe@^2.0.1: +pathe@^2.0.2: version "2.0.2" resolved "https://registry.yarnpkg.com/pathe/-/pathe-2.0.2.tgz#5ed86644376915b3c7ee4d00ac8c348d671da3a5" integrity sha512-15Ztpk+nov8DR524R4BF7uEuzESgzUEAV4Ah7CUMNGXdE5ELuvxElxGXndBl32vMSsWa1jpNf22Z+Er3sKwq+w== @@ -12370,15 +12370,15 @@ vary@^1, vary@^1.1.2, vary@~1.1.2: resolved "https://registry.yarnpkg.com/vary/-/vary-1.1.2.tgz#2299f02c6ded30d4a5961b0b9f74524a18f634fc" integrity sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg== -vite-node@3.0.3: - version "3.0.3" - resolved "https://registry.yarnpkg.com/vite-node/-/vite-node-3.0.3.tgz#2127458eae8c78b92f609f4c84d613599cd14317" - integrity sha512-0sQcwhwAEw/UJGojbhOrnq3HtiZ3tC7BzpAa0lx3QaTX0S3YX70iGcik25UBdB96pmdwjyY2uyKNYruxCDmiEg== +vite-node@3.0.4: + version "3.0.4" + resolved "https://registry.yarnpkg.com/vite-node/-/vite-node-3.0.4.tgz#6db5bc4c182baf04986265d46bc3193c5491f41f" + integrity sha512-7JZKEzcYV2Nx3u6rlvN8qdo3QV7Fxyt6hx+CCKz9fbWxdX5IvUOmTWEAxMrWxaiSf7CKGLJQ5rFu8prb/jBjOA== dependencies: cac "^6.7.14" debug "^4.4.0" es-module-lexer "^1.6.0" - pathe "^2.0.1" + pathe "^2.0.2" vite "^5.0.0 || ^6.0.0" "vite@^5.0.0 || ^6.0.0": @@ -12392,30 +12392,30 @@ vite-node@3.0.3: optionalDependencies: fsevents "~2.3.3" -vitest@^3.0.3: - version "3.0.3" - resolved "https://registry.yarnpkg.com/vitest/-/vitest-3.0.3.tgz#e7bcf3ba82e4a18f1f2c5083b3d989cd344cb78c" - integrity sha512-dWdwTFUW9rcnL0LyF2F+IfvNQWB0w9DERySCk8VMG75F8k25C7LsZoh6XfCjPvcR8Nb+Lqi9JKr6vnzH7HSrpQ== - dependencies: - "@vitest/expect" "3.0.3" - "@vitest/mocker" "3.0.3" - "@vitest/pretty-format" "^3.0.3" - "@vitest/runner" "3.0.3" - "@vitest/snapshot" "3.0.3" - "@vitest/spy" "3.0.3" - "@vitest/utils" "3.0.3" +vitest@^3.0.4: + version "3.0.4" + resolved "https://registry.yarnpkg.com/vitest/-/vitest-3.0.4.tgz#c1d1c7ed1b21308906cd06d9cdee28b2eefddf97" + integrity sha512-6XG8oTKy2gnJIFTHP6LD7ExFeNLxiTkK3CfMvT7IfR8IN+BYICCf0lXUQmX7i7JoxUP8QmeP4mTnWXgflu4yjw== + dependencies: + "@vitest/expect" "3.0.4" + "@vitest/mocker" "3.0.4" + "@vitest/pretty-format" "^3.0.4" + "@vitest/runner" "3.0.4" + "@vitest/snapshot" "3.0.4" + "@vitest/spy" "3.0.4" + "@vitest/utils" "3.0.4" chai "^5.1.2" debug "^4.4.0" expect-type "^1.1.0" magic-string "^0.30.17" - pathe "^2.0.1" + pathe "^2.0.2" std-env "^3.8.0" tinybench "^2.9.0" tinyexec "^0.3.2" tinypool "^1.0.2" tinyrainbow "^2.0.0" vite "^5.0.0 || ^6.0.0" - vite-node "3.0.3" + vite-node "3.0.4" why-is-node-running "^2.3.0" void-elements@^2.0.0: