Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion .github/workflows/unit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ jobs:
- name: Check licenses are up to date
run: node ./scripts/tasks/generate-license-files.js --test
- name: Verify @lwc/shared is tree-shakable
run: node ./scripts/tasks/verify-treeshakable.js ./packages/@lwc/shared/dist/index.js
run: node ./scripts/tasks/verify-treeshakable.mjs ./packages/@lwc/shared/dist/index.js
- name: Verify that dependencies are declared
run: node ./scripts/tasks/check-imports-are-declared-dependencies.js
- name: Check formatting
Expand Down
2 changes: 1 addition & 1 deletion .husky/pre-push
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
set -e
node ./scripts/tasks/check-and-rewrite-package-json.js --test
node ./scripts/tasks/generate-license-files.js --test
node ./scripts/tasks/verify-treeshakable.js ./packages/@lwc/shared/dist/index.js
node ./scripts/tasks/verify-treeshakable.mjs ./packages/@lwc/shared/dist/index.js
node ./scripts/tasks/check-imports-are-declared-dependencies.js
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "lwc-monorepo",
"version": "8.13.2",
"version": "8.13.3",
"private": true,
"description": "Lightning Web Components",
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion packages/@lwc/aria-reflection/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"You can safely modify dependencies, devDependencies, keywords, etc., but other props will be overwritten."
],
"name": "@lwc/aria-reflection",
"version": "8.13.2",
"version": "8.13.3",
"description": "ARIA element reflection polyfill for strings",
"keywords": [
"aom",
Expand Down
6 changes: 3 additions & 3 deletions packages/@lwc/babel-plugin-component/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"You can safely modify dependencies, devDependencies, keywords, etc., but other props will be overwritten."
],
"name": "@lwc/babel-plugin-component",
"version": "8.13.2",
"version": "8.13.3",
"description": "Babel plugin to transform a LWC module",
"keywords": [
"lwc"
Expand Down Expand Up @@ -47,8 +47,8 @@
},
"dependencies": {
"@babel/helper-module-imports": "7.25.9",
"@lwc/errors": "8.13.2",
"@lwc/shared": "8.13.2",
"@lwc/errors": "8.13.3",
"@lwc/shared": "8.13.3",
"line-column": "~1.0.2"
},
"devDependencies": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { describe } from 'vitest';
import { transformSync } from '@babel/core';
import { LWC_VERSION, HIGHEST_API_VERSION } from '@lwc/shared';
import { testFixtureDir } from '@lwc/test-utils-lwc-internals';
import plugin from '../index';
import plugin, { type LwcBabelPluginOptions } from '../index';

const BASE_OPTS = {
namespace: 'lwc',
Expand Down Expand Up @@ -62,7 +62,7 @@ function transform(source: string, opts = {}) {
}

describe('fixtures', () => {
testFixtureDir(
testFixtureDir<LwcBabelPluginOptions>(
{
root: path.resolve(__dirname, 'fixtures'),
pattern: '**/actual.js',
Expand Down
14 changes: 7 additions & 7 deletions packages/@lwc/compiler/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"You can safely modify dependencies, devDependencies, keywords, etc., but other props will be overwritten."
],
"name": "@lwc/compiler",
"version": "8.13.2",
"version": "8.13.3",
"description": "LWC compiler",
"keywords": [
"lwc"
Expand Down Expand Up @@ -52,11 +52,11 @@
"@babel/plugin-transform-class-properties": "7.25.9",
"@babel/plugin-transform-object-rest-spread": "7.25.9",
"@locker/babel-plugin-transform-unforgeables": "0.22.0",
"@lwc/babel-plugin-component": "8.13.2",
"@lwc/errors": "8.13.2",
"@lwc/shared": "8.13.2",
"@lwc/ssr-compiler": "8.13.2",
"@lwc/style-compiler": "8.13.2",
"@lwc/template-compiler": "8.13.2"
"@lwc/babel-plugin-component": "8.13.3",
"@lwc/errors": "8.13.3",
"@lwc/shared": "8.13.3",
"@lwc/ssr-compiler": "8.13.3",
"@lwc/style-compiler": "8.13.3",
"@lwc/template-compiler": "8.13.3"
}
}
8 changes: 4 additions & 4 deletions packages/@lwc/engine-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"You can safely modify dependencies, devDependencies, keywords, etc., but other props will be overwritten."
],
"name": "@lwc/engine-core",
"version": "8.13.2",
"version": "8.13.3",
"description": "Core LWC engine APIs.",
"keywords": [
"lwc"
Expand Down Expand Up @@ -46,9 +46,9 @@
}
},
"dependencies": {
"@lwc/features": "8.13.2",
"@lwc/shared": "8.13.2",
"@lwc/signals": "8.13.2"
"@lwc/features": "8.13.3",
"@lwc/shared": "8.13.3",
"@lwc/signals": "8.13.3"
},
"devDependencies": {
"observable-membrane": "2.0.0"
Expand Down
10 changes: 4 additions & 6 deletions packages/@lwc/engine-core/src/framework/invoker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { addErrorComponentStack } from '../shared/error';
import { evaluateTemplate, setVMBeingRendered, getVMBeingRendered } from './template';
import { runWithBoundaryProtection } from './vm';
import { logOperationStart, logOperationEnd, OperationId } from './profiler';
import type { LightningElement } from './base-lightning-element';
import { LightningElement } from './base-lightning-element';
import type { Template } from './template';
import type { VM } from './vm';
import type { LightningElementConstructor } from './base-lightning-element';
Expand Down Expand Up @@ -58,11 +58,9 @@ export function invokeComponentConstructor(vm: VM, Ctor: LightningElementConstru
// the "instanceof" operator would not work here since Locker Service provides its own
// implementation of LightningElement, so we indirectly check if the base constructor is
// invoked by accessing the component on the vm.
// TODO [W-17769475]: Restore this fix when we can reliably detect Locker enabled
// const isInvalidConstructor = lwcRuntimeFlags.LEGACY_LOCKER_ENABLED
// ? vmBeingConstructed.component !== result
// : !(result instanceof LightningElement);
const isInvalidConstructor = vmBeingConstructed.component !== result;
const isInvalidConstructor = lwcRuntimeFlags.LEGACY_LOCKER_ENABLED
? vmBeingConstructed.component !== result
: !(result instanceof LightningElement);

if (isInvalidConstructor) {
throw new TypeError(
Expand Down
8 changes: 4 additions & 4 deletions packages/@lwc/engine-dom/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"You can safely modify dependencies, devDependencies, keywords, etc., but other props will be overwritten."
],
"name": "@lwc/engine-dom",
"version": "8.13.2",
"version": "8.13.3",
"description": "Renders LWC components in a DOM environment.",
"keywords": [
"lwc"
Expand Down Expand Up @@ -46,9 +46,9 @@
}
},
"devDependencies": {
"@lwc/engine-core": "8.13.2",
"@lwc/shared": "8.13.2",
"@lwc/features": "8.13.2"
"@lwc/engine-core": "8.13.3",
"@lwc/shared": "8.13.3",
"@lwc/features": "8.13.3"
},
"lwc": {
"modules": [
Expand Down
10 changes: 5 additions & 5 deletions packages/@lwc/engine-server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"You can safely modify dependencies, devDependencies, keywords, etc., but other props will be overwritten."
],
"name": "@lwc/engine-server",
"version": "8.13.2",
"version": "8.13.3",
"description": "Renders LWC components in a server environment.",
"keywords": [
"lwc"
Expand Down Expand Up @@ -46,10 +46,10 @@
}
},
"devDependencies": {
"@lwc/engine-core": "8.13.2",
"@lwc/rollup-plugin": "8.13.2",
"@lwc/shared": "8.13.2",
"@lwc/features": "8.13.2",
"@lwc/engine-core": "8.13.3",
"@lwc/rollup-plugin": "8.13.3",
"@lwc/shared": "8.13.3",
"@lwc/features": "8.13.3",
"@rollup/plugin-virtual": "^3.0.2",
"parse5": "^7.2.1"
}
Expand Down
68 changes: 27 additions & 41 deletions packages/@lwc/engine-server/src/__tests__/fixtures.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,41 +9,38 @@ import path from 'node:path';
import { vi, describe, beforeAll, afterAll } from 'vitest';
import { rollup } from 'rollup';
import lwcRollupPlugin from '@lwc/rollup-plugin';
import { testFixtureDir, formatHTML } from '@lwc/test-utils-lwc-internals';
import { testFixtureDir, formatHTML, pluginVirtual } from '@lwc/test-utils-lwc-internals';
import { setFeatureFlagForTest } from '../index';
import type { FeatureFlagName } from '@lwc/features/dist/types';
import type { LightningElementConstructor } from '@lwc/engine-core/dist/framework/base-lightning-element';
import type { RollupLwcOptions } from '@lwc/rollup-plugin';
import type * as lwc from '../index';

interface FixtureModule {
tagName: string;
default: typeof lwc.LightningElement;
props?: { [key: string]: any };
features?: any[];
}

vi.setConfig({ testTimeout: 10_000 /* 10 seconds */ });

vi.mock('lwc', async () => {
const lwcEngineServer = await import('../index');
try {
lwcEngineServer.setHooks({
sanitizeHtmlContent(content: unknown) {
return content as string;
},
});
lwcEngineServer.setHooks({ sanitizeHtmlContent: String });
} catch (_err) {
// Ignore error if the hook is already overridden
}
return lwcEngineServer;
});

interface FixtureConfig {
/**
* Component name that serves as the entrypoint / root component of the fixture.
* @example x/test
*/
entry: string;

/** Props to provide to the root component. */
props?: Record<string, string>;
}

async function compileFixture({
input,
entry,
dirname,
options,
}: {
input: string;
entry: string;
dirname: string;
options?: RollupLwcOptions;
}) {
Expand All @@ -53,11 +50,13 @@ async function compileFixture({
.join('-') || 'default';
const modulesDir = path.resolve(dirname, './modules');
const outputFile = path.resolve(dirname, `./dist/compiled-${optionsAsString}.js`);
const input = 'virtual/fixture/test.js';

const bundle = await rollup({
input,
external: ['lwc', 'vitest'],
external: ['lwc', '@lwc/ssr-runtime', 'vitest'],
plugins: [
pluginVirtual(`export { default } from "${entry}";`, input),
lwcRollupPlugin({
enableDynamicComponents: true,
experimentalDynamicComponent: {
Expand Down Expand Up @@ -100,23 +99,23 @@ async function compileFixture({
}

function testFixtures(options?: RollupLwcOptions) {
testFixtureDir(
testFixtureDir<FixtureConfig>(
{
root: path.resolve(__dirname, 'fixtures'),
pattern: '**/index.js',
pattern: '**/config.json',
},
async ({ filename, dirname, config }) => {
async ({ dirname, config }) => {
let compiledFixturePath;

try {
compiledFixturePath = await compileFixture({
input: filename,
entry: config!.entry,
dirname,
options,
});
} catch (err: any) {
// Filter out the stacktrace, just include the LWC error message
const message = err?.message?.match(/(LWC\d+[^\n]+)/)?.[1];
const message = err?.message?.match(/(LWC\d+[^\n]+)/)?.[1] ?? err.message;
return {
'expected.html': '',
'error.txt': message,
Expand All @@ -132,20 +131,11 @@ function testFixtures(options?: RollupLwcOptions) {

let result;
let err;
let features: FeatureFlagName[] = [];
try {
const module = (await import(compiledFixturePath)) as FixtureModule;

features = module!.features ?? [];
features.forEach((flag) => {
lwcEngineServer!.setFeatureFlagForTest(flag, true);
});
const module: LightningElementConstructor = (await import(compiledFixturePath))
.default;
result = formatHTML(
lwcEngineServer!.renderComponent(
module!.tagName,
module!.default,
config?.props ?? {}
)
lwcEngineServer.renderComponent('fixture-test', module, config?.props ?? {})
);
} catch (_err: any) {
if (_err?.name === 'AssertionError') {
Expand All @@ -154,10 +144,6 @@ function testFixtures(options?: RollupLwcOptions) {
err = _err?.message || 'An empty error occurred?!';
}

features.forEach((flag) => {
lwcEngineServer!.setFeatureFlagForTest(flag, false);
});

return {
'expected.html': result,
'error.txt': err,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"entry": "x/comments-text"
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<x-comments-text>
<fixture-test>
<template shadowrootmode="open">
<span>
</span>
</template>
</x-comments-text>
</fixture-test>

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"entry": "x/comments-text"
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<x-comments-text>
<fixture-test>
<template shadowrootmode="open">
<span>
<div>
</div>
</span>
</template>
</x-comments-text>
</fixture-test>

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"entry": "x/comments-text"
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<x-comments-text>
<fixture-test>
<template shadowrootmode="open">
ab
<div data-foo="1">
c
</div>
de
</template>
</x-comments-text>
</fixture-test>

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"entry": "x/comments-text"
}
Loading
Loading