Skip to content

Commit

Permalink
Merge pull request #43 from vite-plugin/v0.10.1
Browse files Browse the repository at this point in the history
V0.10.1
  • Loading branch information
yejimeiming committed Nov 14, 2023
2 parents b97d18d + 038b486 commit 172d8c3
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 5 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.10.1 (2023-11-14)

- 492aab3 fix(#42): auto-increment dynamic require id

## 0.10.0 (2023-10-08)

- c286fe2 chore: backup files
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vite-plugin-commonjs",
"version": "0.10.0",
"version": "0.10.1",
"description": "A pure JavaScript implementation of CommonJs",
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion src/dynamic-require.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export class DynaimcRequire {
let counter2 = 0
record.dynaimc = {
importee: [],
runtimeName: `__matchRequireRuntime${counter}__`,
runtimeName: `__matchRequireRuntime${counter++}__`,
runtimeFn: '', // to be immediately set
}

Expand Down
6 changes: 3 additions & 3 deletions test/fixtures/__snapshots__/dynamic.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* [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) {
/* [vite-plugin-commonjs] import-require2import-S */ import * as __dynamic_require2import__1__0 from './module-exports/hello.cjs'; import * as __dynamic_require2import__1__1 from './module-exports/world.cjs'; /* [vite-plugin-commonjs] import-require2import-E */function load(name) {
const mod = __matchRequireRuntime0__(`@/module-exports/${name}`);
console.log(mod);
return mod;
Expand All @@ -9,10 +9,10 @@ function __matchRequireRuntime0__(path) {
switch(path) {
case '@/module-exports/hello':
case '@/module-exports/hello.cjs':
return __dynamic_require2import__0__0;
return __dynamic_require2import__1__0;
case '@/module-exports/world':
case '@/module-exports/world.cjs':
return __dynamic_require2import__0__1;
return __dynamic_require2import__1__1;
default: throw new Error("Cann't found module: " + path);
}
}

0 comments on commit 172d8c3

Please sign in to comment.