Skip to content

Commit

Permalink
fix: dynamic-require typo #28
Browse files Browse the repository at this point in the history
  • Loading branch information
yejimeiming committed Jun 24, 2023
1 parent 66ce5dd commit bf2f306
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/index.ts
Expand Up @@ -198,7 +198,7 @@ async function transformCommonjs({
} else if (dymc) {
requires.push(...dymc.importee.map(impt => impt + ';'))
runtimes.push(dymc.runtimeFn)
ms.overwrite(node.callee.start, node.callee.end, dymc.runtimeFn)
ms.overwrite(node.callee.start, node.callee.end, dymc.runtimeName)
}
}

Expand Down
12 changes: 1 addition & 11 deletions test/fixtures/__snapshots__/dynamic.tsx
@@ -1,15 +1,5 @@
/* [vite-plugin-commonjs] import-require2import-S */ import * as __dynamic_require2import__0__0 from './module-exports/hello.cjs'; import * as __dynamic_require2import__0__1 from './module-exports/world.cjs'; /* [vite-plugin-commonjs] import-require2import-E */function load(name) {
const mod = function __matchRequireRuntime0__(path) {
switch(path) {
case '@/module-exports/hello':
case '@/module-exports/hello.cjs':
return __dynamic_require2import__0__0;
case '@/module-exports/world':
case '@/module-exports/world.cjs':
return __dynamic_require2import__0__1;
default: throw new Error("Cann't found module: " + path);
}
}(`@/module-exports/${name}`);
const mod = __matchRequireRuntime0__(`@/module-exports/${name}`);
console.log(mod);
return mod;
}
Expand Down

0 comments on commit bf2f306

Please sign in to comment.