diff --git a/crates/rspack_plugin_javascript/src/parser_plugin/amd/amd_define_dependency_parser_plugin.rs b/crates/rspack_plugin_javascript/src/parser_plugin/amd/amd_define_dependency_parser_plugin.rs index 3fdb6bc538b4..6dc1597c8a20 100644 --- a/crates/rspack_plugin_javascript/src/parser_plugin/amd/amd_define_dependency_parser_plugin.rs +++ b/crates/rspack_plugin_javascript/src/parser_plugin/amd/amd_define_dependency_parser_plugin.rs @@ -289,10 +289,6 @@ impl AMDDefineDependencyParserPlugin { } } else { // define([…], …) - if !first_arg.expr.is_array() { - return None; - } - array = Some(&first_arg.expr); if is_callable(&second_arg.expr) { diff --git a/crates/rspack_plugin_javascript/src/parser_plugin/amd/amd_plugin.rs b/crates/rspack_plugin_javascript/src/parser_plugin/amd/amd_plugin.rs index e749201e133f..07a94baca4dc 100644 --- a/crates/rspack_plugin_javascript/src/parser_plugin/amd/amd_plugin.rs +++ b/crates/rspack_plugin_javascript/src/parser_plugin/amd/amd_plugin.rs @@ -141,6 +141,26 @@ impl JavascriptParserPlugin for AMDParserPlugin { None } + fn identifier( + &self, + parser: &mut JavascriptParser, + ident: &swc_core::ecma::ast::Ident, + for_name: &str, + ) -> Option { + if for_name == DEFINE { + parser + .presentational_dependencies + .push(Box::new(ConstDependency::new( + ident.span().real_lo(), + ident.span().real_hi(), + RuntimeGlobals::AMD_DEFINE.name().into(), + Some(RuntimeGlobals::AMD_DEFINE), + ))); + return Some(true); + } + None + } + fn evaluate_identifier( &self, _parser: &mut JavascriptParser, diff --git a/packages/rspack-test-tools/tests/normalCases/amd/define-function/index.js b/packages/rspack-test-tools/tests/configCases/amd/define-function/index.js similarity index 100% rename from packages/rspack-test-tools/tests/normalCases/amd/define-function/index.js rename to packages/rspack-test-tools/tests/configCases/amd/define-function/index.js diff --git a/packages/rspack-test-tools/tests/normalCases/amd/define-function/lib.js b/packages/rspack-test-tools/tests/configCases/amd/define-function/lib.js similarity index 100% rename from packages/rspack-test-tools/tests/normalCases/amd/define-function/lib.js rename to packages/rspack-test-tools/tests/configCases/amd/define-function/lib.js diff --git a/packages/rspack-test-tools/tests/configCases/amd/define-function/rspack.config.js b/packages/rspack-test-tools/tests/configCases/amd/define-function/rspack.config.js new file mode 100644 index 000000000000..91e119b92a07 --- /dev/null +++ b/packages/rspack-test-tools/tests/configCases/amd/define-function/rspack.config.js @@ -0,0 +1,4 @@ +/** @type {import("@rspack/core").Configuration} */ +module.exports = { + amd: {}, +}; diff --git a/packages/rspack-test-tools/tests/normalCases/amd/define-object/index.js b/packages/rspack-test-tools/tests/configCases/amd/define-object/index.js similarity index 100% rename from packages/rspack-test-tools/tests/normalCases/amd/define-object/index.js rename to packages/rspack-test-tools/tests/configCases/amd/define-object/index.js diff --git a/packages/rspack-test-tools/tests/normalCases/amd/define-object/lib.js b/packages/rspack-test-tools/tests/configCases/amd/define-object/lib.js similarity index 100% rename from packages/rspack-test-tools/tests/normalCases/amd/define-object/lib.js rename to packages/rspack-test-tools/tests/configCases/amd/define-object/lib.js diff --git a/packages/rspack-test-tools/tests/configCases/amd/define-object/rspack.config.js b/packages/rspack-test-tools/tests/configCases/amd/define-object/rspack.config.js new file mode 100644 index 000000000000..91e119b92a07 --- /dev/null +++ b/packages/rspack-test-tools/tests/configCases/amd/define-object/rspack.config.js @@ -0,0 +1,4 @@ +/** @type {import("@rspack/core").Configuration} */ +module.exports = { + amd: {}, +}; diff --git a/packages/rspack-test-tools/tests/normalCases/amd/define-others/hello.js b/packages/rspack-test-tools/tests/configCases/amd/define-others/hello.js similarity index 100% rename from packages/rspack-test-tools/tests/normalCases/amd/define-others/hello.js rename to packages/rspack-test-tools/tests/configCases/amd/define-others/hello.js diff --git a/packages/rspack-test-tools/tests/normalCases/amd/define-others/index.js b/packages/rspack-test-tools/tests/configCases/amd/define-others/index.js similarity index 100% rename from packages/rspack-test-tools/tests/normalCases/amd/define-others/index.js rename to packages/rspack-test-tools/tests/configCases/amd/define-others/index.js diff --git a/packages/rspack-test-tools/tests/normalCases/amd/define-others/lucky-number.js b/packages/rspack-test-tools/tests/configCases/amd/define-others/lucky-number.js similarity index 100% rename from packages/rspack-test-tools/tests/normalCases/amd/define-others/lucky-number.js rename to packages/rspack-test-tools/tests/configCases/amd/define-others/lucky-number.js diff --git a/packages/rspack-test-tools/tests/configCases/amd/define-others/rspack.config.js b/packages/rspack-test-tools/tests/configCases/amd/define-others/rspack.config.js new file mode 100644 index 000000000000..91e119b92a07 --- /dev/null +++ b/packages/rspack-test-tools/tests/configCases/amd/define-others/rspack.config.js @@ -0,0 +1,4 @@ +/** @type {import("@rspack/core").Configuration} */ +module.exports = { + amd: {}, +}; diff --git a/packages/rspack-test-tools/tests/normalCases/amd/define-with-deps/add.js b/packages/rspack-test-tools/tests/configCases/amd/define-with-deps/add.js similarity index 100% rename from packages/rspack-test-tools/tests/normalCases/amd/define-with-deps/add.js rename to packages/rspack-test-tools/tests/configCases/amd/define-with-deps/add.js diff --git a/packages/rspack-test-tools/tests/normalCases/amd/define-with-deps/constants.js b/packages/rspack-test-tools/tests/configCases/amd/define-with-deps/constants.js similarity index 100% rename from packages/rspack-test-tools/tests/normalCases/amd/define-with-deps/constants.js rename to packages/rspack-test-tools/tests/configCases/amd/define-with-deps/constants.js diff --git a/packages/rspack-test-tools/tests/normalCases/amd/define-with-deps/hello.js b/packages/rspack-test-tools/tests/configCases/amd/define-with-deps/hello.js similarity index 100% rename from packages/rspack-test-tools/tests/normalCases/amd/define-with-deps/hello.js rename to packages/rspack-test-tools/tests/configCases/amd/define-with-deps/hello.js diff --git a/packages/rspack-test-tools/tests/normalCases/amd/define-with-deps/index.js b/packages/rspack-test-tools/tests/configCases/amd/define-with-deps/index.js similarity index 100% rename from packages/rspack-test-tools/tests/normalCases/amd/define-with-deps/index.js rename to packages/rspack-test-tools/tests/configCases/amd/define-with-deps/index.js diff --git a/packages/rspack-test-tools/tests/normalCases/amd/define-with-deps/lib.js b/packages/rspack-test-tools/tests/configCases/amd/define-with-deps/lib.js similarity index 100% rename from packages/rspack-test-tools/tests/normalCases/amd/define-with-deps/lib.js rename to packages/rspack-test-tools/tests/configCases/amd/define-with-deps/lib.js diff --git a/packages/rspack-test-tools/tests/configCases/amd/define-with-deps/rspack.config.js b/packages/rspack-test-tools/tests/configCases/amd/define-with-deps/rspack.config.js new file mode 100644 index 000000000000..91e119b92a07 --- /dev/null +++ b/packages/rspack-test-tools/tests/configCases/amd/define-with-deps/rspack.config.js @@ -0,0 +1,4 @@ +/** @type {import("@rspack/core").Configuration} */ +module.exports = { + amd: {}, +}; diff --git a/packages/rspack-test-tools/tests/normalCases/amd/define-with-name/index.js b/packages/rspack-test-tools/tests/configCases/amd/define-with-name/index.js similarity index 100% rename from packages/rspack-test-tools/tests/normalCases/amd/define-with-name/index.js rename to packages/rspack-test-tools/tests/configCases/amd/define-with-name/index.js diff --git a/packages/rspack-test-tools/tests/normalCases/amd/define-with-name/jquery.js b/packages/rspack-test-tools/tests/configCases/amd/define-with-name/jquery.js similarity index 100% rename from packages/rspack-test-tools/tests/normalCases/amd/define-with-name/jquery.js rename to packages/rspack-test-tools/tests/configCases/amd/define-with-name/jquery.js diff --git a/packages/rspack-test-tools/tests/normalCases/amd/define-with-name/lib.js b/packages/rspack-test-tools/tests/configCases/amd/define-with-name/lib.js similarity index 100% rename from packages/rspack-test-tools/tests/normalCases/amd/define-with-name/lib.js rename to packages/rspack-test-tools/tests/configCases/amd/define-with-name/lib.js diff --git a/packages/rspack-test-tools/tests/configCases/amd/define-with-name/rspack.config.js b/packages/rspack-test-tools/tests/configCases/amd/define-with-name/rspack.config.js new file mode 100644 index 000000000000..91e119b92a07 --- /dev/null +++ b/packages/rspack-test-tools/tests/configCases/amd/define-with-name/rspack.config.js @@ -0,0 +1,4 @@ +/** @type {import("@rspack/core").Configuration} */ +module.exports = { + amd: {}, +}; diff --git a/packages/rspack-test-tools/tests/normalCases/amd/define-wrapper/add.js b/packages/rspack-test-tools/tests/configCases/amd/define-wrapper/add.js similarity index 100% rename from packages/rspack-test-tools/tests/normalCases/amd/define-wrapper/add.js rename to packages/rspack-test-tools/tests/configCases/amd/define-wrapper/add.js diff --git a/packages/rspack-test-tools/tests/normalCases/amd/define-wrapper/constants.js b/packages/rspack-test-tools/tests/configCases/amd/define-wrapper/constants.js similarity index 100% rename from packages/rspack-test-tools/tests/normalCases/amd/define-wrapper/constants.js rename to packages/rspack-test-tools/tests/configCases/amd/define-wrapper/constants.js diff --git a/packages/rspack-test-tools/tests/normalCases/amd/define-wrapper/hello.js b/packages/rspack-test-tools/tests/configCases/amd/define-wrapper/hello.js similarity index 100% rename from packages/rspack-test-tools/tests/normalCases/amd/define-wrapper/hello.js rename to packages/rspack-test-tools/tests/configCases/amd/define-wrapper/hello.js diff --git a/packages/rspack-test-tools/tests/normalCases/amd/define-wrapper/index.js b/packages/rspack-test-tools/tests/configCases/amd/define-wrapper/index.js similarity index 100% rename from packages/rspack-test-tools/tests/normalCases/amd/define-wrapper/index.js rename to packages/rspack-test-tools/tests/configCases/amd/define-wrapper/index.js diff --git a/packages/rspack-test-tools/tests/normalCases/amd/define-wrapper/lib1.js b/packages/rspack-test-tools/tests/configCases/amd/define-wrapper/lib1.js similarity index 100% rename from packages/rspack-test-tools/tests/normalCases/amd/define-wrapper/lib1.js rename to packages/rspack-test-tools/tests/configCases/amd/define-wrapper/lib1.js diff --git a/packages/rspack-test-tools/tests/normalCases/amd/define-wrapper/lib2.js b/packages/rspack-test-tools/tests/configCases/amd/define-wrapper/lib2.js similarity index 100% rename from packages/rspack-test-tools/tests/normalCases/amd/define-wrapper/lib2.js rename to packages/rspack-test-tools/tests/configCases/amd/define-wrapper/lib2.js diff --git a/packages/rspack-test-tools/tests/configCases/amd/define-wrapper/rspack.config.js b/packages/rspack-test-tools/tests/configCases/amd/define-wrapper/rspack.config.js new file mode 100644 index 000000000000..91e119b92a07 --- /dev/null +++ b/packages/rspack-test-tools/tests/configCases/amd/define-wrapper/rspack.config.js @@ -0,0 +1,4 @@ +/** @type {import("@rspack/core").Configuration} */ +module.exports = { + amd: {}, +}; diff --git a/packages/rspack-test-tools/tests/normalCases/amd/real-amd-libs/define-in-params.js b/packages/rspack-test-tools/tests/configCases/amd/real-amd-libs/define-in-params.js similarity index 100% rename from packages/rspack-test-tools/tests/normalCases/amd/real-amd-libs/define-in-params.js rename to packages/rspack-test-tools/tests/configCases/amd/real-amd-libs/define-in-params.js diff --git a/packages/rspack-test-tools/tests/normalCases/amd/real-amd-libs/index.js b/packages/rspack-test-tools/tests/configCases/amd/real-amd-libs/index.js similarity index 100% rename from packages/rspack-test-tools/tests/normalCases/amd/real-amd-libs/index.js rename to packages/rspack-test-tools/tests/configCases/amd/real-amd-libs/index.js diff --git a/packages/rspack-test-tools/tests/normalCases/amd/real-amd-libs/jquery-ui.js b/packages/rspack-test-tools/tests/configCases/amd/real-amd-libs/jquery-ui.js similarity index 100% rename from packages/rspack-test-tools/tests/normalCases/amd/real-amd-libs/jquery-ui.js rename to packages/rspack-test-tools/tests/configCases/amd/real-amd-libs/jquery-ui.js diff --git a/packages/rspack-test-tools/tests/normalCases/amd/real-amd-libs/jquery.js b/packages/rspack-test-tools/tests/configCases/amd/real-amd-libs/jquery.js similarity index 100% rename from packages/rspack-test-tools/tests/normalCases/amd/real-amd-libs/jquery.js rename to packages/rspack-test-tools/tests/configCases/amd/real-amd-libs/jquery.js diff --git a/packages/rspack-test-tools/tests/normalCases/amd/real-amd-libs/json-logic-js.js b/packages/rspack-test-tools/tests/configCases/amd/real-amd-libs/json-logic-js.js similarity index 100% rename from packages/rspack-test-tools/tests/normalCases/amd/real-amd-libs/json-logic-js.js rename to packages/rspack-test-tools/tests/configCases/amd/real-amd-libs/json-logic-js.js diff --git a/packages/rspack-test-tools/tests/configCases/amd/real-amd-libs/rspack.config.js b/packages/rspack-test-tools/tests/configCases/amd/real-amd-libs/rspack.config.js new file mode 100644 index 000000000000..91e119b92a07 --- /dev/null +++ b/packages/rspack-test-tools/tests/configCases/amd/real-amd-libs/rspack.config.js @@ -0,0 +1,4 @@ +/** @type {import("@rspack/core").Configuration} */ +module.exports = { + amd: {}, +}; diff --git a/packages/rspack-test-tools/tests/normalCases/amd/real-amd-libs/webpack-umd-output.js b/packages/rspack-test-tools/tests/configCases/amd/real-amd-libs/webpack-umd-output.js similarity index 100% rename from packages/rspack-test-tools/tests/normalCases/amd/real-amd-libs/webpack-umd-output.js rename to packages/rspack-test-tools/tests/configCases/amd/real-amd-libs/webpack-umd-output.js diff --git a/packages/rspack-test-tools/tests/normalCases/amd/require-error-callback/add.js b/packages/rspack-test-tools/tests/configCases/amd/require-error-callback/add.js similarity index 100% rename from packages/rspack-test-tools/tests/normalCases/amd/require-error-callback/add.js rename to packages/rspack-test-tools/tests/configCases/amd/require-error-callback/add.js diff --git a/packages/rspack-test-tools/tests/normalCases/amd/require-error-callback/index.js b/packages/rspack-test-tools/tests/configCases/amd/require-error-callback/index.js similarity index 100% rename from packages/rspack-test-tools/tests/normalCases/amd/require-error-callback/index.js rename to packages/rspack-test-tools/tests/configCases/amd/require-error-callback/index.js diff --git a/packages/rspack-test-tools/tests/configCases/amd/require-error-callback/rspack.config.js b/packages/rspack-test-tools/tests/configCases/amd/require-error-callback/rspack.config.js new file mode 100644 index 000000000000..91e119b92a07 --- /dev/null +++ b/packages/rspack-test-tools/tests/configCases/amd/require-error-callback/rspack.config.js @@ -0,0 +1,4 @@ +/** @type {import("@rspack/core").Configuration} */ +module.exports = { + amd: {}, +}; diff --git a/packages/rspack-test-tools/tests/normalCases/amd/require-local-module/index.js b/packages/rspack-test-tools/tests/configCases/amd/require-local-module/index.js similarity index 100% rename from packages/rspack-test-tools/tests/normalCases/amd/require-local-module/index.js rename to packages/rspack-test-tools/tests/configCases/amd/require-local-module/index.js diff --git a/packages/rspack-test-tools/tests/configCases/amd/require-local-module/rspack.config.js b/packages/rspack-test-tools/tests/configCases/amd/require-local-module/rspack.config.js new file mode 100644 index 000000000000..91e119b92a07 --- /dev/null +++ b/packages/rspack-test-tools/tests/configCases/amd/require-local-module/rspack.config.js @@ -0,0 +1,4 @@ +/** @type {import("@rspack/core").Configuration} */ +module.exports = { + amd: {}, +}; diff --git a/packages/rspack-test-tools/tests/normalCases/amd/require-unsupported/index.js b/packages/rspack-test-tools/tests/configCases/amd/require-unsupported/index.js similarity index 100% rename from packages/rspack-test-tools/tests/normalCases/amd/require-unsupported/index.js rename to packages/rspack-test-tools/tests/configCases/amd/require-unsupported/index.js diff --git a/packages/rspack-test-tools/tests/configCases/amd/require-unsupported/rspack.config.js b/packages/rspack-test-tools/tests/configCases/amd/require-unsupported/rspack.config.js new file mode 100644 index 000000000000..91e119b92a07 --- /dev/null +++ b/packages/rspack-test-tools/tests/configCases/amd/require-unsupported/rspack.config.js @@ -0,0 +1,4 @@ +/** @type {import("@rspack/core").Configuration} */ +module.exports = { + amd: {}, +}; diff --git a/packages/rspack-test-tools/tests/normalCases/amd/require-unsupported/warnings.js b/packages/rspack-test-tools/tests/configCases/amd/require-unsupported/warnings.js similarity index 100% rename from packages/rspack-test-tools/tests/normalCases/amd/require-unsupported/warnings.js rename to packages/rspack-test-tools/tests/configCases/amd/require-unsupported/warnings.js diff --git a/packages/rspack-test-tools/tests/normalCases/amd/require-wrapper/add.js b/packages/rspack-test-tools/tests/configCases/amd/require-wrapper/add.js similarity index 100% rename from packages/rspack-test-tools/tests/normalCases/amd/require-wrapper/add.js rename to packages/rspack-test-tools/tests/configCases/amd/require-wrapper/add.js diff --git a/packages/rspack-test-tools/tests/normalCases/amd/require-wrapper/constants.js b/packages/rspack-test-tools/tests/configCases/amd/require-wrapper/constants.js similarity index 100% rename from packages/rspack-test-tools/tests/normalCases/amd/require-wrapper/constants.js rename to packages/rspack-test-tools/tests/configCases/amd/require-wrapper/constants.js diff --git a/packages/rspack-test-tools/tests/normalCases/amd/require-wrapper/hello.js b/packages/rspack-test-tools/tests/configCases/amd/require-wrapper/hello.js similarity index 100% rename from packages/rspack-test-tools/tests/normalCases/amd/require-wrapper/hello.js rename to packages/rspack-test-tools/tests/configCases/amd/require-wrapper/hello.js diff --git a/packages/rspack-test-tools/tests/normalCases/amd/require-wrapper/index.js b/packages/rspack-test-tools/tests/configCases/amd/require-wrapper/index.js similarity index 100% rename from packages/rspack-test-tools/tests/normalCases/amd/require-wrapper/index.js rename to packages/rspack-test-tools/tests/configCases/amd/require-wrapper/index.js diff --git a/packages/rspack-test-tools/tests/configCases/amd/require-wrapper/rspack.config.js b/packages/rspack-test-tools/tests/configCases/amd/require-wrapper/rspack.config.js new file mode 100644 index 000000000000..91e119b92a07 --- /dev/null +++ b/packages/rspack-test-tools/tests/configCases/amd/require-wrapper/rspack.config.js @@ -0,0 +1,4 @@ +/** @type {import("@rspack/core").Configuration} */ +module.exports = { + amd: {}, +}; diff --git a/packages/rspack-test-tools/tests/normalCases/amd/require/add.js b/packages/rspack-test-tools/tests/configCases/amd/require/add.js similarity index 100% rename from packages/rspack-test-tools/tests/normalCases/amd/require/add.js rename to packages/rspack-test-tools/tests/configCases/amd/require/add.js diff --git a/packages/rspack-test-tools/tests/normalCases/amd/require/dep.js b/packages/rspack-test-tools/tests/configCases/amd/require/dep.js similarity index 100% rename from packages/rspack-test-tools/tests/normalCases/amd/require/dep.js rename to packages/rspack-test-tools/tests/configCases/amd/require/dep.js diff --git a/packages/rspack-test-tools/tests/configCases/amd/require/fn.js b/packages/rspack-test-tools/tests/configCases/amd/require/fn.js new file mode 100644 index 000000000000..689ea7026160 --- /dev/null +++ b/packages/rspack-test-tools/tests/configCases/amd/require/fn.js @@ -0,0 +1,4 @@ +module.exports.value = undefined; +module.exports = (newValue) => { + module.exports.value = newValue; +} diff --git a/packages/rspack-test-tools/tests/normalCases/amd/require/index.js b/packages/rspack-test-tools/tests/configCases/amd/require/index.js similarity index 86% rename from packages/rspack-test-tools/tests/normalCases/amd/require/index.js rename to packages/rspack-test-tools/tests/configCases/amd/require/index.js index a0110b1dfdcb..8ea5967bfc08 100644 --- a/packages/rspack-test-tools/tests/normalCases/amd/require/index.js +++ b/packages/rspack-test-tools/tests/configCases/amd/require/index.js @@ -4,7 +4,7 @@ it("require([...]) should work well", async function () { await p; - expect(require('./fn')).toHaveBeenCalledWith(123); + expect(require('./fn').value).toBe(123); }); it("require([...], function () {}) should work well", function (done) { diff --git a/packages/rspack-test-tools/tests/configCases/amd/require/rspack.config.js b/packages/rspack-test-tools/tests/configCases/amd/require/rspack.config.js new file mode 100644 index 000000000000..91e119b92a07 --- /dev/null +++ b/packages/rspack-test-tools/tests/configCases/amd/require/rspack.config.js @@ -0,0 +1,4 @@ +/** @type {import("@rspack/core").Configuration} */ +module.exports = { + amd: {}, +}; diff --git a/packages/rspack-test-tools/tests/normalCases/amd/require/fn.js b/packages/rspack-test-tools/tests/normalCases/amd/require/fn.js deleted file mode 100644 index 74541a168e34..000000000000 --- a/packages/rspack-test-tools/tests/normalCases/amd/require/fn.js +++ /dev/null @@ -1,2 +0,0 @@ - -module.exports = jest.fn(); diff --git a/packages/rspack/src/config/adapter.ts b/packages/rspack/src/config/adapter.ts index 320c1b47f915..59780c716fb2 100644 --- a/packages/rspack/src/config/adapter.ts +++ b/packages/rspack/src/config/adapter.ts @@ -99,7 +99,7 @@ export const getRawOptions = ( experiments, node: getRawNode(options.node), profile: options.profile!, - amd: options.amd !== false ? JSON.stringify(options.amd || {}) : undefined, + amd: options.amd ? JSON.stringify(options.amd || {}) : undefined, bail: options.bail!, __references: {} }; diff --git a/tests/webpack-test/ConfigTestCases.template.js b/tests/webpack-test/ConfigTestCases.template.js index aac6a5891639..9b596c5b7bad 100644 --- a/tests/webpack-test/ConfigTestCases.template.js +++ b/tests/webpack-test/ConfigTestCases.template.js @@ -91,6 +91,7 @@ const describeCases = config => { }).not.toThrow(); optionsArr = [].concat(options); optionsArr.forEach((options, idx) => { + if (options.amd === undefined) options.amd = {}; if (!options.context) options.context = testDirectory; if (!options.mode) options.mode = "production"; if (!options.optimization) options.optimization = {}; diff --git a/tests/webpack-test/TestCases.template.js b/tests/webpack-test/TestCases.template.js index 8421e668616e..4edb7c0736fd 100644 --- a/tests/webpack-test/TestCases.template.js +++ b/tests/webpack-test/TestCases.template.js @@ -97,6 +97,7 @@ const describeCases = config => { }); let options = { ...testConfig, + amd: {}, context: casesPath, entry: "./" + category.name + "/" + testName + "/", target: config.target || "async-node", diff --git a/tests/webpack-test/__snapshots__/StatsTestCases.basictest.js.snap b/tests/webpack-test/__snapshots__/StatsTestCases.basictest.js.snap index e95ca956a25e..63ddb8371f23 100644 --- a/tests/webpack-test/__snapshots__/StatsTestCases.basictest.js.snap +++ b/tests/webpack-test/__snapshots__/StatsTestCases.basictest.js.snap @@ -574,61 +574,101 @@ Rspack x.x.x compiled successfully in X.23" exports[`StatsTestCases should print correct stats for limit-chunk-count-plugin 1`] = ` "1 chunks: - asset bundle1.js 3.86 KiB [emitted] (name: main) - chunk (runtime: main) bundle1.js (main) 219 bytes (javascript) 1.84 KiB (runtime) <{909}> >{909}< [entry] [rendered] + asset bundle1.js 4.04 KiB [emitted] (name: main) + chunk (runtime: main) bundle1.js (main) 357 bytes (javascript) 1.84 KiB (runtime) <{909}> >{909}< [entry] [rendered] ./a.js 22 bytes [dependent] [built] [code generated] - ./b.js 22 bytes [dependent] [built] [code generated] ./c.js 30 bytes [dependent] [built] [code generated] ./d.js 22 bytes [dependent] [built] [code generated] ./e.js 22 bytes [dependent] [built] [code generated] - ./index.js 101 bytes [built] [code generated] - 1 chunks (Rspack x.x.x) compiled successfully in X.23 + ./index.js 101 bytes [built] [code generated] [1 warning] + Xdir/limit-chunk-count-plugin|sync 160 bytes [dependent] [built] [code generated] + + WARNING in ./index.js + ⚠ Critical dependency: the request of a dependency is an expression + ╭─[2:8] + 1 │ require.ensure([\\"./a\\"], function() {}); + 2 │ require([\\"./b\\"]); + · ──────── + 3 │ import(/* webpackChunkName: \\"c\\" */ \\"./c\\"); + ╰──── + + 1 chunks (Rspack x.x.x) compiled with 1 warning in X.23 2 chunks: - asset bundle2.js 10.3 KiB [emitted] (name: main) - asset 76.bundle2.js 599 bytes [emitted] (name: c) - chunk (runtime: main) 76.bundle2.js (c) 118 bytes <{76}> <{909}> >{76}< [rendered] + asset bundle2.js 10.6 KiB [emitted] (name: main) + asset 76.bundle2.js 545 bytes [emitted] (name: c) + chunk (runtime: main) 76.bundle2.js (c) 96 bytes <{76}> <{909}> >{76}< [rendered] dependent modules 44 bytes [dependent] ./d.js 22 bytes [dependent] [built] [code generated] ./e.js 22 bytes [dependent] [built] [code generated] ./a.js 22 bytes [built] [code generated] - ./b.js 22 bytes [built] [code generated] ./c.js 30 bytes [built] [code generated] - chunk (runtime: main) bundle2.js (main) 101 bytes (javascript) 8.46 KiB (runtime) >{76}< [entry] [rendered] - ./index.js 101 bytes [built] [code generated] - 2 chunks (Rspack x.x.x) compiled successfully in X.23 + chunk (runtime: main) bundle2.js (main) 261 bytes (javascript) 8.46 KiB (runtime) >{76}< [entry] [rendered] + ./index.js 101 bytes [built] [code generated] [1 warning] + Xdir/limit-chunk-count-plugin|sync 160 bytes [dependent] [built] [code generated] + + WARNING in ./index.js + ⚠ Critical dependency: the request of a dependency is an expression + ╭─[2:8] + 1 │ require.ensure([\\"./a\\"], function() {}); + 2 │ require([\\"./b\\"]); + · ──────── + 3 │ import(/* webpackChunkName: \\"c\\" */ \\"./c\\"); + ╰──── + + 2 chunks (Rspack x.x.x) compiled with 1 warning in X.23 3 chunks: - asset bundle3.js 10.3 KiB [emitted] (name: main) + asset bundle3.js 10.6 KiB [emitted] (name: main) asset 76.bundle3.js 385 bytes [emitted] (name: c) - asset 656.bundle3.js 290 bytes [emitted] - chunk (runtime: main) 656.bundle3.js 88 bytes <{76}> <{909}> [rendered] + asset 588.bundle3.js 236 bytes [emitted] + chunk (runtime: main) 588.bundle3.js 66 bytes <{76}> <{909}> [rendered] ./a.js 22 bytes [built] [code generated] - ./b.js 22 bytes [built] [code generated] ./d.js 22 bytes [built] [code generated] ./e.js 22 bytes [built] [code generated] - chunk (runtime: main) 76.bundle3.js (c) 30 bytes <{909}> >{656}< [rendered] + chunk (runtime: main) 76.bundle3.js (c) 30 bytes <{909}> >{588}< [rendered] ./c.js 30 bytes [built] [code generated] - chunk (runtime: main) bundle3.js (main) 101 bytes (javascript) 8.46 KiB (runtime) >{656}< >{76}< [entry] [rendered] - ./index.js 101 bytes [built] [code generated] - 3 chunks (Rspack x.x.x) compiled successfully in X.23 + chunk (runtime: main) bundle3.js (main) 261 bytes (javascript) 8.46 KiB (runtime) >{588}< >{76}< [entry] [rendered] + ./index.js 101 bytes [built] [code generated] [1 warning] + Xdir/limit-chunk-count-plugin|sync 160 bytes [dependent] [built] [code generated] + + WARNING in ./index.js + ⚠ Critical dependency: the request of a dependency is an expression + ╭─[2:8] + 1 │ require.ensure([\\"./a\\"], function() {}); + 2 │ require([\\"./b\\"]); + · ──────── + 3 │ import(/* webpackChunkName: \\"c\\" */ \\"./c\\"); + ╰──── + + 3 chunks (Rspack x.x.x) compiled with 1 warning in X.23 4 chunks: - asset bundle4.js 10.3 KiB [emitted] (name: main) + asset bundle4.js 10.6 KiB [emitted] (name: main) asset 76.bundle4.js 385 bytes [emitted] (name: c) - asset 537.bundle4.js 236 bytes [emitted] - asset 697.bundle4.js 128 bytes [emitted] - chunk (runtime: main) 537.bundle4.js 66 bytes <{76}> <{909}> [rendered] + asset 345.bundle4.js 182 bytes [emitted] + asset 272.bundle4.js 128 bytes [emitted] + chunk (runtime: main) 272.bundle4.js 22 bytes <{909}> [rendered] ./a.js 22 bytes [built] [code generated] - ./b.js 22 bytes [built] [code generated] + chunk (runtime: main) 345.bundle4.js 44 bytes <{76}> [rendered] ./d.js 22 bytes [built] [code generated] - chunk (runtime: main) 697.bundle4.js 22 bytes <{76}> [rendered] ./e.js 22 bytes [built] [code generated] - chunk (runtime: main) 76.bundle4.js (c) 30 bytes <{909}> >{537}< >{697}< [rendered] + chunk (runtime: main) 76.bundle4.js (c) 30 bytes <{909}> >{345}< [rendered] ./c.js 30 bytes [built] [code generated] - chunk (runtime: main) bundle4.js (main) 101 bytes (javascript) 8.46 KiB (runtime) >{537}< >{76}< [entry] [rendered] - ./index.js 101 bytes [built] [code generated] - 4 chunks (Rspack x.x.x) compiled successfully in X.23" + chunk (runtime: main) bundle4.js (main) 261 bytes (javascript) 8.46 KiB (runtime) >{272}< >{76}< [entry] [rendered] + ./index.js 101 bytes [built] [code generated] [1 warning] + Xdir/limit-chunk-count-plugin|sync 160 bytes [dependent] [built] [code generated] + + WARNING in ./index.js + ⚠ Critical dependency: the request of a dependency is an expression + ╭─[2:8] + 1 │ require.ensure([\\"./a\\"], function() {}); + 2 │ require([\\"./b\\"]); + · ──────── + 3 │ import(/* webpackChunkName: \\"c\\" */ \\"./c\\"); + ╰──── + + 4 chunks (Rspack x.x.x) compiled with 1 warning in X.23" `; exports[`StatsTestCases should print correct stats for logging-debug 1`] = ` diff --git a/tests/webpack-test/cases/amd/define-needs-module/test.filter.js b/tests/webpack-test/cases/amd/define-needs-module/test.filter.js deleted file mode 100644 index c1e761ebcbf9..000000000000 --- a/tests/webpack-test/cases/amd/define-needs-module/test.filter.js +++ /dev/null @@ -1,4 +0,0 @@ - -module.exports = () => {return "https://github.com/web-infra-dev/rspack/issues/4313"} - - \ No newline at end of file diff --git a/tests/webpack-test/cases/amd/namedModules/test.filter.js b/tests/webpack-test/cases/amd/namedModules/test.filter.js deleted file mode 100644 index c1e761ebcbf9..000000000000 --- a/tests/webpack-test/cases/amd/namedModules/test.filter.js +++ /dev/null @@ -1,4 +0,0 @@ - -module.exports = () => {return "https://github.com/web-infra-dev/rspack/issues/4313"} - - \ No newline at end of file diff --git a/tests/webpack-test/cases/amd/namedModulesConstArrayDep/test.filter.js b/tests/webpack-test/cases/amd/namedModulesConstArrayDep/test.filter.js index c1e761ebcbf9..12dcfeb8efcc 100644 --- a/tests/webpack-test/cases/amd/namedModulesConstArrayDep/test.filter.js +++ b/tests/webpack-test/cases/amd/namedModulesConstArrayDep/test.filter.js @@ -1,4 +1,4 @@ -module.exports = () => {return "https://github.com/web-infra-dev/rspack/issues/4313"} +module.exports = () => {return "compile time eval split"} \ No newline at end of file diff --git a/tests/webpack-test/cases/cjs-tree-shaking/bailouts/index.js b/tests/webpack-test/cases/cjs-tree-shaking/bailouts/index.js index 7beff9e65700..665c352dc404 100644 --- a/tests/webpack-test/cases/cjs-tree-shaking/bailouts/index.js +++ b/tests/webpack-test/cases/cjs-tree-shaking/bailouts/index.js @@ -50,7 +50,7 @@ it("should be able to do stuff with the module object", () => { expect(require("./accessing-module?1").def).toBe("def"); }); -// it("should be able to use AMD to define exports", () => { -// expect(require("./using-amd?2").abc).toBe("abc"); -// expect(require("./using-amd?1").def).toBe("def"); -// }); +it("should be able to use AMD to define exports", () => { + expect(require("./using-amd?2").abc).toBe("abc"); + expect(require("./using-amd?1").def).toBe("def"); +}); diff --git a/tests/webpack-test/cases/cjs-tree-shaking/bailouts/test.filter.js b/tests/webpack-test/cases/cjs-tree-shaking/bailouts/test.filter.js deleted file mode 100644 index a1f8b7c22630..000000000000 --- a/tests/webpack-test/cases/cjs-tree-shaking/bailouts/test.filter.js +++ /dev/null @@ -1,4 +0,0 @@ -const { FilteredStatus } = require("../../../lib/util/filterUtil") - -module.exports = () => { return [FilteredStatus.PARTIAL_PASS, "https://github.com/web-infra-dev/rspack/issues/4313"] } - diff --git a/tests/webpack-test/cases/parsing/amd-rename/test.filter.js b/tests/webpack-test/cases/parsing/amd-rename/test.filter.js deleted file mode 100644 index c1e761ebcbf9..000000000000 --- a/tests/webpack-test/cases/parsing/amd-rename/test.filter.js +++ /dev/null @@ -1,4 +0,0 @@ - -module.exports = () => {return "https://github.com/web-infra-dev/rspack/issues/4313"} - - \ No newline at end of file diff --git a/tests/webpack-test/cases/parsing/complex-require/test.filter.js b/tests/webpack-test/cases/parsing/complex-require/test.filter.js index b2191979cda9..4a9ac76ba6a2 100644 --- a/tests/webpack-test/cases/parsing/complex-require/test.filter.js +++ b/tests/webpack-test/cases/parsing/complex-require/test.filter.js @@ -11,7 +11,7 @@ module.exports = function (config) { module.exports = () => { return [ FilteredStatus.PARTIAL_PASS, - "https://github.com/web-infra-dev/rspack/issues/4313", + "amd require context", "require(String.raw``)" ]; }; diff --git a/tests/webpack-test/cases/parsing/declared-api/test.filter.js b/tests/webpack-test/cases/parsing/declared-api/test.filter.js deleted file mode 100644 index c1e761ebcbf9..000000000000 --- a/tests/webpack-test/cases/parsing/declared-api/test.filter.js +++ /dev/null @@ -1,4 +0,0 @@ - -module.exports = () => {return "https://github.com/web-infra-dev/rspack/issues/4313"} - - \ No newline at end of file diff --git a/tests/webpack-test/cases/parsing/extract-amd.nominimize/test.filter.js b/tests/webpack-test/cases/parsing/extract-amd.nominimize/test.filter.js index 79ac8657be27..4430967cd36a 100644 --- a/tests/webpack-test/cases/parsing/extract-amd.nominimize/test.filter.js +++ b/tests/webpack-test/cases/parsing/extract-amd.nominimize/test.filter.js @@ -7,6 +7,6 @@ module.exports = function (config) { }; */ -module.exports = () => {return "https://github.com/web-infra-dev/rspack/issues/4313"} +module.exports = () => {return "amd require context"} \ No newline at end of file diff --git a/tests/webpack-test/cases/parsing/extract-amd/test.filter.js b/tests/webpack-test/cases/parsing/extract-amd/test.filter.js index c1e761ebcbf9..fba9ad4b275e 100644 --- a/tests/webpack-test/cases/parsing/extract-amd/test.filter.js +++ b/tests/webpack-test/cases/parsing/extract-amd/test.filter.js @@ -1,4 +1,4 @@ -module.exports = () => {return "https://github.com/web-infra-dev/rspack/issues/4313"} +module.exports = () => {return "amd require context"} \ No newline at end of file diff --git a/tests/webpack-test/cases/parsing/harmony-injecting-order/test.filter.js b/tests/webpack-test/cases/parsing/harmony-injecting-order/test.filter.js index c1e761ebcbf9..a68847dce73a 100644 --- a/tests/webpack-test/cases/parsing/harmony-injecting-order/test.filter.js +++ b/tests/webpack-test/cases/parsing/harmony-injecting-order/test.filter.js @@ -1,4 +1,3 @@ - -module.exports = () => {return "https://github.com/web-infra-dev/rspack/issues/4313"} +module.exports = () => {return "__webpack_amd_options__ module variable"} \ No newline at end of file diff --git a/tests/webpack-test/cases/parsing/issue-2084/test.filter.js b/tests/webpack-test/cases/parsing/issue-2084/test.filter.js deleted file mode 100644 index c1e761ebcbf9..000000000000 --- a/tests/webpack-test/cases/parsing/issue-2084/test.filter.js +++ /dev/null @@ -1,4 +0,0 @@ - -module.exports = () => {return "https://github.com/web-infra-dev/rspack/issues/4313"} - - \ No newline at end of file diff --git a/tests/webpack-test/cases/parsing/issue-2641/index.js b/tests/webpack-test/cases/parsing/issue-2641/index.js index 4626a3d9cdac..6a25f19e87af 100644 --- a/tests/webpack-test/cases/parsing/issue-2641/index.js +++ b/tests/webpack-test/cases/parsing/issue-2641/index.js @@ -19,17 +19,17 @@ it("should call error callback on missing module", function(done) { }); }); -it("should call error callback on missing module in context", function(done) { - (function(module) { - require(['./' + module], function(file){}, function(error) { - try { - expect(error).toBeInstanceOf(Error); - expect(error.message).toBe("Cannot find module './missingModule'"); - done(); - } catch(e) { done(e); } - }); - })('missingModule'); -}); +// it("should call error callback on missing module in context", function(done) { +// (function(module) { +// require(['./' + module], function(file){}, function(error) { +// try { +// expect(error).toBeInstanceOf(Error); +// expect(error.message).toBe("Cannot find module './missingModule'"); +// done(); +// } catch(e) { done(e); } +// }); +// })('missingModule'); +// }); it("should call error callback on exception thrown in loading module", function(done) { require(['./throwing'], function(){}, function(error) { diff --git a/tests/webpack-test/cases/parsing/issue-2641/test.filter.js b/tests/webpack-test/cases/parsing/issue-2641/test.filter.js index c1e761ebcbf9..a16a6e85c4ec 100644 --- a/tests/webpack-test/cases/parsing/issue-2641/test.filter.js +++ b/tests/webpack-test/cases/parsing/issue-2641/test.filter.js @@ -1,4 +1,4 @@ -module.exports = () => {return "https://github.com/web-infra-dev/rspack/issues/4313"} +module.exports = () => {return "error callback on missing module in context"} \ No newline at end of file diff --git a/tests/webpack-test/cases/parsing/issue-345/test.filter.js b/tests/webpack-test/cases/parsing/issue-345/test.filter.js index c1e761ebcbf9..fba9ad4b275e 100644 --- a/tests/webpack-test/cases/parsing/issue-345/test.filter.js +++ b/tests/webpack-test/cases/parsing/issue-345/test.filter.js @@ -1,4 +1,4 @@ -module.exports = () => {return "https://github.com/web-infra-dev/rspack/issues/4313"} +module.exports = () => {return "amd require context"} \ No newline at end of file diff --git a/tests/webpack-test/cases/parsing/issue-387/test.filter.js b/tests/webpack-test/cases/parsing/issue-387/test.filter.js deleted file mode 100644 index c1e761ebcbf9..000000000000 --- a/tests/webpack-test/cases/parsing/issue-387/test.filter.js +++ /dev/null @@ -1,4 +0,0 @@ - -module.exports = () => {return "https://github.com/web-infra-dev/rspack/issues/4313"} - - \ No newline at end of file diff --git a/tests/webpack-test/cases/parsing/issue-4940/test.filter.js b/tests/webpack-test/cases/parsing/issue-4940/test.filter.js index c1e761ebcbf9..6c30dabf8f04 100644 --- a/tests/webpack-test/cases/parsing/issue-4940/test.filter.js +++ b/tests/webpack-test/cases/parsing/issue-4940/test.filter.js @@ -1,4 +1,4 @@ -module.exports = () => {return "https://github.com/web-infra-dev/rspack/issues/4313"} +module.exports = () => {return "amd local module"} \ No newline at end of file diff --git a/tests/webpack-test/cases/parsing/local-modules/test.filter.js b/tests/webpack-test/cases/parsing/local-modules/test.filter.js index c1e761ebcbf9..6c30dabf8f04 100644 --- a/tests/webpack-test/cases/parsing/local-modules/test.filter.js +++ b/tests/webpack-test/cases/parsing/local-modules/test.filter.js @@ -1,4 +1,4 @@ -module.exports = () => {return "https://github.com/web-infra-dev/rspack/issues/4313"} +module.exports = () => {return "amd local module"} \ No newline at end of file diff --git a/tests/webpack-test/cases/parsing/renaming/test.filter.js b/tests/webpack-test/cases/parsing/renaming/test.filter.js index ea5dc5c4837e..944bc95bd8d3 100644 --- a/tests/webpack-test/cases/parsing/renaming/test.filter.js +++ b/tests/webpack-test/cases/parsing/renaming/test.filter.js @@ -1,3 +1,3 @@ -module.exports = () => {return "https://github.com/web-infra-dev/rspack/issues/4313, https://github.com/web-infra-dev/rspack/issues/3346"} +module.exports = () => {return "amd define renaming"} diff --git a/tests/webpack-test/cases/parsing/strict-mode/test.filter.js b/tests/webpack-test/cases/parsing/strict-mode/test.filter.js deleted file mode 100644 index c1e761ebcbf9..000000000000 --- a/tests/webpack-test/cases/parsing/strict-mode/test.filter.js +++ /dev/null @@ -1,4 +0,0 @@ - -module.exports = () => {return "https://github.com/web-infra-dev/rspack/issues/4313"} - - \ No newline at end of file diff --git a/tests/webpack-test/cases/parsing/unsupported-amd/test.filter.js b/tests/webpack-test/cases/parsing/unsupported-amd/test.filter.js index c1e761ebcbf9..76ad1497123d 100644 --- a/tests/webpack-test/cases/parsing/unsupported-amd/test.filter.js +++ b/tests/webpack-test/cases/parsing/unsupported-amd/test.filter.js @@ -1,4 +1,4 @@ -module.exports = () => {return "https://github.com/web-infra-dev/rspack/issues/4313"} +module.exports = () => {return "amd unsupported errors"} \ No newline at end of file diff --git a/tests/webpack-test/cases/resolving/commomjs-local-module/test.filter.js b/tests/webpack-test/cases/resolving/commomjs-local-module/test.filter.js index 5288f73b3bad..61b417867743 100644 --- a/tests/webpack-test/cases/resolving/commomjs-local-module/test.filter.js +++ b/tests/webpack-test/cases/resolving/commomjs-local-module/test.filter.js @@ -1 +1 @@ -module.exports = () => {return "https://github.com/web-infra-dev/rspack/issues/4313"} +module.exports = () => {return "amd local module"} diff --git a/tests/webpack-test/cases/runtime/chunk-callback-order/test.filter.js b/tests/webpack-test/cases/runtime/chunk-callback-order/test.filter.js deleted file mode 100644 index c1e761ebcbf9..000000000000 --- a/tests/webpack-test/cases/runtime/chunk-callback-order/test.filter.js +++ /dev/null @@ -1,4 +0,0 @@ - -module.exports = () => {return "https://github.com/web-infra-dev/rspack/issues/4313"} - - \ No newline at end of file diff --git a/tests/webpack-test/configCases/async-commons-chunk/all-selected/test.filter.js b/tests/webpack-test/configCases/async-commons-chunk/all-selected/test.filter.js index 7f81799d343b..2d7fd95f87ee 100644 --- a/tests/webpack-test/configCases/async-commons-chunk/all-selected/test.filter.js +++ b/tests/webpack-test/configCases/async-commons-chunk/all-selected/test.filter.js @@ -1 +1 @@ -module.exports = () => {return "https://github.com/web-infra-dev/rspack/issues/4313"} \ No newline at end of file +module.exports = () => {return "amd require ensure"}; \ No newline at end of file diff --git a/tests/webpack-test/configCases/async-commons-chunk/existing-name/test.filter.js b/tests/webpack-test/configCases/async-commons-chunk/existing-name/test.filter.js index 7f81799d343b..ef018b0653fd 100644 --- a/tests/webpack-test/configCases/async-commons-chunk/existing-name/test.filter.js +++ b/tests/webpack-test/configCases/async-commons-chunk/existing-name/test.filter.js @@ -1 +1 @@ -module.exports = () => {return "https://github.com/web-infra-dev/rspack/issues/4313"} \ No newline at end of file +module.exports = () => {return "amd require ensure"} \ No newline at end of file diff --git a/tests/webpack-test/configCases/async-commons-chunk/simple/test.filter.js b/tests/webpack-test/configCases/async-commons-chunk/simple/test.filter.js index 7f81799d343b..2d7fd95f87ee 100644 --- a/tests/webpack-test/configCases/async-commons-chunk/simple/test.filter.js +++ b/tests/webpack-test/configCases/async-commons-chunk/simple/test.filter.js @@ -1 +1 @@ -module.exports = () => {return "https://github.com/web-infra-dev/rspack/issues/4313"} \ No newline at end of file +module.exports = () => {return "amd require ensure"}; \ No newline at end of file diff --git a/tests/webpack-test/configCases/library/1-use-library/webpack.config.js b/tests/webpack-test/configCases/library/1-use-library/webpack.config.js index 560634a00f87..59a4a3338e68 100644 --- a/tests/webpack-test/configCases/library/1-use-library/webpack.config.js +++ b/tests/webpack-test/configCases/library/1-use-library/webpack.config.js @@ -92,31 +92,30 @@ module.exports = (env, { testPath }) => [ }) ] }, - // TODO: https://github.com/web-infra-dev/rspack/issues/4313 - // { - // resolve: { - // alias: { - // library: path.resolve(testPath, "../0-create-library/amd.js") - // } - // }, - // plugins: [ - // new webpack.DefinePlugin({ - // NAME: JSON.stringify("amd") - // }) - // ] - // }, - // { - // resolve: { - // alias: { - // library: path.resolve(testPath, "../0-create-library/amd-iife.js") - // } - // }, - // plugins: [ - // new webpack.DefinePlugin({ - // NAME: JSON.stringify("amd-iife") - // }) - // ] - // }, + { + resolve: { + alias: { + library: path.resolve(testPath, "../0-create-library/amd.js") + } + }, + plugins: [ + new webpack.DefinePlugin({ + NAME: JSON.stringify("amd") + }) + ] + }, + { + resolve: { + alias: { + library: path.resolve(testPath, "../0-create-library/amd-iife.js") + } + }, + plugins: [ + new webpack.DefinePlugin({ + NAME: JSON.stringify("amd-iife") + }) + ] + }, { externals: { library: `promise (require(${JSON.stringify( @@ -315,7 +314,7 @@ module.exports = (env, { testPath }) => [ }) ] }, - // TODO: https://github.com/web-infra-dev/rspack/issues/4313 + // TODO: amd esm import exports presence check // { // resolve: { // alias: { @@ -452,17 +451,16 @@ module.exports = (env, { testPath }) => [ }) ] }, - // TODO: https://github.com/web-infra-dev/rspack/issues/4313 - // { - // resolve: { - // alias: { - // library: path.resolve(testPath, "../0-create-library/entryC.js") - // } - // }, - // plugins: [ - // new webpack.DefinePlugin({ - // NAME: JSON.stringify("entryC") - // }) - // ] - // } + { + resolve: { + alias: { + library: path.resolve(testPath, "../0-create-library/entryC.js") + } + }, + plugins: [ + new webpack.DefinePlugin({ + NAME: JSON.stringify("entryC") + }) + ] + } ]; diff --git a/tests/webpack-test/statsCases/async-commons-chunk/test.filter.js b/tests/webpack-test/statsCases/async-commons-chunk/test.filter.js index a8bb6ccb41bd..98345d69843e 100644 --- a/tests/webpack-test/statsCases/async-commons-chunk/test.filter.js +++ b/tests/webpack-test/statsCases/async-commons-chunk/test.filter.js @@ -1,3 +1,3 @@ module.exports = () => { - return "https://github.com/web-infra-dev/rspack/issues/4313"; + return "amd require ensure"; }; diff --git a/x.mjs b/x.mjs index 049db6c6212c..6f3da8ad2720 100755 --- a/x.mjs +++ b/x.mjs @@ -202,6 +202,7 @@ const rspackCommand = program.command("rspack").alias("rs").description(` rspackCommand .option("-d, --debug", "Launch debugger in VSCode") + .argument("[args...]", "Arguments pass through to rspack cli") .action(async ({ debug }) => { try { if (!debug) { @@ -219,6 +220,7 @@ program .command("rspack-debug") .alias("rsd") .description("Alias for `x rspack --debug`") + .argument("[args...]", "Arguments pass through to rspack cli") .action(async () => { await launchRspackCli(getVariadicArgs()); }); @@ -233,6 +235,7 @@ const jestCommand = program.command("jest").alias("j").description(` jestCommand .option("-d, --debug", "Launch debugger in VSCode") + .argument("[args...]", "Arguments pass through to rspack cli") .action(async ({ debug }) => { if (!debug) { await $`npx jest ${getVariadicArgs()}`; @@ -246,6 +249,7 @@ program .command("jest-debug") .alias("jd") .description("Alias for `x jest --debug`") + .argument("[args...]", "Arguments pass through to rspack cli") .action(async () => { await launchJestWithArgs(getVariadicArgs()); });