-
-
Notifications
You must be signed in to change notification settings - Fork 598
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(commonjs)!: Correctly infer module name for any separator (#924)
* test(commonjs): Add test for different path separators Add test for module IDs that use a path separator that is different from `path.sep`. Previously, when a module whose file name is `index.js` was resolved to a module ID containing different path separators, the commonjs plugin generated a variable name containing the module's absolute path. * fix(commonjs)!: Correctly infer module name for any separator BREAKING CHANGES: Correctly infer the module name from the module ID, regardless of the path separator used in the module ID and the value of `path.sep`. This generates variable names like `react` instead of `C__testViteApp_node_modules_react` when a module ID of `C:/test-vite-app/node_modules/react/index.js` is given on Windows.
- Loading branch information
1 parent
31aad90
commit f408497
Showing
4 changed files
with
34 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
packages/commonjs/test/fixtures/samples/module-path-separator/foo/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
module.exports.a = 1; |
2 changes: 2 additions & 0 deletions
2
packages/commonjs/test/fixtures/samples/module-path-separator/main.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
const foo = require("./foo"); | ||
console.log(foo.a); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters