File tree Expand file tree Collapse file tree 2 files changed +9
-4
lines changed
packages/@lwc/integration-not-karma
test/custom-elements-registry Expand file tree Collapse file tree 2 files changed +9
-4
lines changed Original file line number Diff line number Diff 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 } ` ;
Original file line number Diff line number Diff line change @@ -7,7 +7,13 @@ const tagAlreadyUsedErrorMessage =
77/** Fetches a text resource. */
88async 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
You can’t perform that action at this time.
0 commit comments