-
-
Notifications
You must be signed in to change notification settings - Fork 602
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix:
Path
pitfall for loader type (#7666)
* fix: fix UTF-8 pitfall for loader type * fix: `as_str` instead of `extension` * fix * fix
- Loading branch information
Showing
10 changed files
with
50 additions
and
1 deletion.
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
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
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,15 @@ | ||
it("should pass package.json type to loader", function () { | ||
expect(require("cjs/loader.js!")).toBe("commonjs"); | ||
expect(require("./loader.js!")).toBe("undefined"); | ||
}); | ||
|
||
it("should pass 'commonjs' type to loader for .cjs", function () { | ||
expect(require("cjs/loader.cjs!")).toBe("commonjs"); | ||
expect(require("./loader.cjs!")).toBe("commonjs"); | ||
// ORIGINAL WEBPACK COMMENT: TODO need fix in v8 https://github.com/nodejs/node/issues/35889 | ||
// ORIGINAL WEBPACK COMMENT: TODO otherwise this test case cause segment fault | ||
// Turned on this as rspack checks extensions for loader type. | ||
// So this will not fall into dynamic import which causes segment fault. | ||
// See: crates/rspack_binding_options/src/plugins/js_loader/resolver.rs | ||
expect(require("esm/loader.cjs!")).toBe("commonjs"); | ||
}); |
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,4 @@ | ||
/** @type {import("../../../../").LoaderDefinition} */ | ||
module.exports = function loader() { | ||
return `module.exports = "${this.loaders[this.loaderIndex].type}";`; | ||
}; |
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,4 @@ | ||
/** @type {import("../../../../").LoaderDefinition} */ | ||
module.exports = function loader() { | ||
return `module.exports = "${this.loaders[this.loaderIndex].type}";`; | ||
}; |
4 changes: 4 additions & 0 deletions
4
tests/webpack-test/cases/loaders/cjs-loader-type/node_modules/cjs/loader.cjs
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
4 changes: 4 additions & 0 deletions
4
tests/webpack-test/cases/loaders/cjs-loader-type/node_modules/cjs/loader.js
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
4 changes: 4 additions & 0 deletions
4
tests/webpack-test/cases/loaders/cjs-loader-type/node_modules/cjs/package.json
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
4 changes: 4 additions & 0 deletions
4
tests/webpack-test/cases/loaders/cjs-loader-type/node_modules/esm/loader.cjs
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
4 changes: 4 additions & 0 deletions
4
tests/webpack-test/cases/loaders/cjs-loader-type/node_modules/esm/package.json
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
b96bf7d
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📝 Benchmark detail: Open
b96bf7d
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📝 Ran ecosystem CI: Open