Skip to content

Commit fe48d42

Browse files
committed
Merge branch 'master' into wjh/no-spy-console
2 parents 8eece7c + 8fdac07 commit fe48d42

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

packages/@lwc/integration-not-karma/helpers/utils.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ export const resolvePathOutsideRoot = (file) => {
267267
return file.replace(/^(\.\.\/)+?(.+?)$/, (_, outside, filepath) => {
268268
// To serve files from outside the web root (e.g. from the monorepo root
269269
// node_modules, @web/dev-server provides this "magic" path. It's hacky
270-
// of us to use it it directly.
270+
// of us to use it directly.
271271
// '../'.repeat(depth) becomes `/__wds-outside-root__/${depth}/`
272272
const depth = outside.length / 3;
273273
return `/__wds-outside-root__/${depth}/${filepath}`;

packages/@lwc/integration-not-karma/test/custom-elements-registry/index.spec.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,13 @@ const tagAlreadyUsedErrorMessage =
77
/** Fetches a text resource. */
88
async function getModuleCode(pkg) {
99
const res = await fetch(resolvePathOutsideRoot(`../${pkg}/dist/index.cjs.js`));
10-
return await res.text();
10+
const code = await res.text();
11+
// CommonJS code needs to have `exports` defined, so we wrap in an IIFE
12+
// to provide it and to encapsulate the code.
13+
return `((exports) => {
14+
${code};
15+
return exports;
16+
})({});`;
1117
}
1218

1319
/** Gets the contents of a set of script tags to insert on a page. */
@@ -20,10 +26,9 @@ async function getEngineCode() {
2026

2127
return `(() => {
2228
globalThis.process = { env: { NODE_ENV: "production" } };
23-
globalThis.LWC = globalThis.exports = {};
2429
globalThis.lwcRuntimeFlags = ${JSON.stringify(lwcRuntimeFlags)};
2530
${syntheticShadow};
26-
${engineDom};
31+
globalThis.LWC = ${engineDom};
2732
})();`;
2833
}
2934

0 commit comments

Comments
 (0)