Skip to content

Commit 54d43f9

Browse files
authored
Merge branch 'master' into wjh/style-token-flag
2 parents 12680e5 + 72c169c commit 54d43f9

File tree

699 files changed

+1128
-435
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

699 files changed

+1128
-435
lines changed

.github/workflows/unit.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ jobs:
5353
- name: Check licenses are up to date
5454
run: node ./scripts/tasks/generate-license-files.js --test
5555
- name: Verify @lwc/shared is tree-shakable
56-
run: node ./scripts/tasks/verify-treeshakable.js ./packages/@lwc/shared/dist/index.js
56+
run: node ./scripts/tasks/verify-treeshakable.mjs ./packages/@lwc/shared/dist/index.js
5757
- name: Verify that dependencies are declared
5858
run: node ./scripts/tasks/check-imports-are-declared-dependencies.js
5959
- name: Check formatting

.husky/pre-push

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
set -e
22
node ./scripts/tasks/check-and-rewrite-package-json.js --test
33
node ./scripts/tasks/generate-license-files.js --test
4-
node ./scripts/tasks/verify-treeshakable.js ./packages/@lwc/shared/dist/index.js
4+
node ./scripts/tasks/verify-treeshakable.mjs ./packages/@lwc/shared/dist/index.js
55
node ./scripts/tasks/check-imports-are-declared-dependencies.js

packages/@lwc/babel-plugin-component/src/__tests__/index.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { describe } from 'vitest';
99
import { transformSync } from '@babel/core';
1010
import { LWC_VERSION, HIGHEST_API_VERSION } from '@lwc/shared';
1111
import { testFixtureDir } from '@lwc/test-utils-lwc-internals';
12-
import plugin from '../index';
12+
import plugin, { type LwcBabelPluginOptions } from '../index';
1313

1414
const BASE_OPTS = {
1515
namespace: 'lwc',
@@ -62,7 +62,7 @@ function transform(source: string, opts = {}) {
6262
}
6363

6464
describe('fixtures', () => {
65-
testFixtureDir(
65+
testFixtureDir<LwcBabelPluginOptions>(
6666
{
6767
root: path.resolve(__dirname, 'fixtures'),
6868
pattern: '**/actual.js',

packages/@lwc/engine-core/src/framework/invoker.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { addErrorComponentStack } from '../shared/error';
1111
import { evaluateTemplate, setVMBeingRendered, getVMBeingRendered } from './template';
1212
import { runWithBoundaryProtection } from './vm';
1313
import { logOperationStart, logOperationEnd, OperationId } from './profiler';
14-
import type { LightningElement } from './base-lightning-element';
14+
import { LightningElement } from './base-lightning-element';
1515
import type { Template } from './template';
1616
import type { VM } from './vm';
1717
import type { LightningElementConstructor } from './base-lightning-element';
@@ -58,11 +58,9 @@ export function invokeComponentConstructor(vm: VM, Ctor: LightningElementConstru
5858
// the "instanceof" operator would not work here since Locker Service provides its own
5959
// implementation of LightningElement, so we indirectly check if the base constructor is
6060
// invoked by accessing the component on the vm.
61-
// TODO [W-17769475]: Restore this fix when we can reliably detect Locker enabled
62-
// const isInvalidConstructor = lwcRuntimeFlags.LEGACY_LOCKER_ENABLED
63-
// ? vmBeingConstructed.component !== result
64-
// : !(result instanceof LightningElement);
65-
const isInvalidConstructor = vmBeingConstructed.component !== result;
61+
const isInvalidConstructor = lwcRuntimeFlags.LEGACY_LOCKER_ENABLED
62+
? vmBeingConstructed.component !== result
63+
: !(result instanceof LightningElement);
6664

6765
if (isInvalidConstructor) {
6866
throw new TypeError(

packages/@lwc/engine-server/src/__tests__/fixtures.spec.ts

Lines changed: 28 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -9,35 +9,38 @@ import path from 'node:path';
99
import { vi, describe, beforeAll, afterAll } from 'vitest';
1010
import { rollup } from 'rollup';
1111
import lwcRollupPlugin from '@lwc/rollup-plugin';
12-
import { testFixtureDir, formatHTML } from '@lwc/test-utils-lwc-internals';
12+
import { testFixtureDir, formatHTML, pluginVirtual } from '@lwc/test-utils-lwc-internals';
1313
import { setFeatureFlagForTest } from '../index';
14+
import type { LightningElementConstructor } from '@lwc/engine-core/dist/framework/base-lightning-element';
1415
import type { RollupLwcOptions } from '@lwc/rollup-plugin';
15-
import type * as lwc from '../index';
16-
17-
interface FixtureModule {
18-
default: typeof lwc.LightningElement;
19-
}
2016

2117
vi.mock('lwc', async () => {
2218
const lwcEngineServer = await import('../index');
2319
try {
24-
lwcEngineServer.setHooks({
25-
sanitizeHtmlContent(content: unknown) {
26-
return content as string;
27-
},
28-
});
20+
lwcEngineServer.setHooks({ sanitizeHtmlContent: String });
2921
} catch (_err) {
3022
// Ignore error if the hook is already overridden
3123
}
3224
return lwcEngineServer;
3325
});
3426

27+
interface FixtureConfig {
28+
/**
29+
* Component name that serves as the entrypoint / root component of the fixture.
30+
* @example x/test
31+
*/
32+
entry: string;
33+
34+
/** Props to provide to the root component. */
35+
props?: Record<string, string>;
36+
}
37+
3538
async function compileFixture({
36-
input,
39+
entry,
3740
dirname,
3841
options,
3942
}: {
40-
input: string;
43+
entry: string;
4144
dirname: string;
4245
options?: RollupLwcOptions;
4346
}) {
@@ -47,11 +50,13 @@ async function compileFixture({
4750
.join('-') || 'default';
4851
const modulesDir = path.resolve(dirname, './modules');
4952
const outputFile = path.resolve(dirname, `./dist/compiled-${optionsAsString}.js`);
53+
const input = 'virtual/fixture/test.js';
5054

5155
const bundle = await rollup({
5256
input,
53-
external: ['lwc', 'vitest'],
57+
external: ['lwc', '@lwc/ssr-runtime', 'vitest'],
5458
plugins: [
59+
pluginVirtual(`export { default } from "${entry}";`, input),
5560
lwcRollupPlugin({
5661
enableDynamicComponents: true,
5762
experimentalDynamicComponent: {
@@ -94,23 +99,23 @@ async function compileFixture({
9499
}
95100

96101
function testFixtures(options?: RollupLwcOptions) {
97-
testFixtureDir(
102+
testFixtureDir<FixtureConfig>(
98103
{
99104
root: path.resolve(__dirname, 'fixtures'),
100-
pattern: '**/index.js',
105+
pattern: '**/config.json',
101106
},
102-
async ({ filename, dirname, config }) => {
107+
async ({ dirname, config }) => {
103108
let compiledFixturePath;
104109

105110
try {
106111
compiledFixturePath = await compileFixture({
107-
input: filename,
112+
entry: config!.entry,
108113
dirname,
109114
options,
110115
});
111116
} catch (err: any) {
112117
// Filter out the stacktrace, just include the LWC error message
113-
const message = err?.message?.match(/(LWC\d+[^\n]+)/)?.[1];
118+
const message = err?.message?.match(/(LWC\d+[^\n]+)/)?.[1] ?? err.message;
114119
return {
115120
'expected.html': '',
116121
'error.txt': message,
@@ -130,7 +135,10 @@ function testFixtures(options?: RollupLwcOptions) {
130135
config?.features?.forEach((flag) => {
131136
lwcEngineServer.setFeatureFlagForTest(flag, true);
132137
});
133-
const { default: module } = (await import(compiledFixturePath)) as FixtureModule;
138+
139+
const module: LightningElementConstructor = (await import(compiledFixturePath))
140+
.default;
141+
134142
result = formatHTML(
135143
lwcEngineServer.renderComponent('fixture-test', module, config?.props ?? {})
136144
);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"entry": "x/comments-text"
3+
}

packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/comments-at-end/index.js

Lines changed: 0 additions & 1 deletion
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"entry": "x/comments-text"
3+
}

packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/comments-then-element/index.js

Lines changed: 0 additions & 1 deletion
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"entry": "x/comments-text"
3+
}

0 commit comments

Comments
 (0)