diff --git a/packages/rspack-test-tools/etc/api.md b/packages/rspack-test-tools/etc/api.md index daa389c879c0..9428d5566428 100644 --- a/packages/rspack-test-tools/etc/api.md +++ b/packages/rspack-test-tools/etc/api.md @@ -12,8 +12,7 @@ import type { Compiler } from '@rspack/core'; import type { Compiler as Compiler_2 } from 'webpack'; import type { Configuration } from 'webpack'; import type EventEmitter from 'node:events'; -import { IBasicGlobalContext as IBasicGlobalContext_2 } from '../type'; -import { IBasicGlobalContext as IBasicGlobalContext_3 } from '../../type'; +import { IBasicGlobalContext as IBasicGlobalContext_2 } from '../../type'; import { IBasicModuleScope as IBasicModuleScope_2 } from '../../type'; import { ITestCompilerManager as ITestCompilerManager_2 } from '../type'; import type { RspackOptions } from '@rspack/core'; @@ -377,7 +376,7 @@ export class FakeDocumentWebRunner extends IMultiT // @public (undocumented) interface IWatchRunnerOptions extends IBasicRunnerOptions { + // (undocumented) + isWeb: boolean; // (undocumented) stepName: string; } @@ -1478,13 +1479,13 @@ export class WatchProcessor extends MultiTaskProcessor< } // @public (undocumented) -export class WatchRunner extends CommonJsRunner { +export class WatchRunner extends FakeDocumentWebRunner { constructor(_watchOptions: IWatchRunnerOptions); // (undocumented) - protected createGlobalContext(): IBasicGlobalContext_2; - // (undocumented) protected createModuleScope(requireFn: TRunnerRequirer, m: any, file: TBasicRunnerFile): IBasicModuleScope; // (undocumented) + run(file: string): Promise; + // (undocumented) protected _watchOptions: IWatchRunnerOptions; } diff --git a/packages/rspack-test-tools/src/processor/watch.ts b/packages/rspack-test-tools/src/processor/watch.ts index 6b9dc14589cb..a081efd91830 100644 --- a/packages/rspack-test-tools/src/processor/watch.ts +++ b/packages/rspack-test-tools/src/processor/watch.ts @@ -9,6 +9,7 @@ import type { ITestEnv, TCompilerOptions } from "../type"; +import { ConfigProcessor } from "./config"; import { type IMultiTaskProcessorOptions, MultiTaskProcessor } from "./multi"; // This file is used to port step number to rspack.config.js/webpack.config.js @@ -37,7 +38,7 @@ export class WatchProcessor< constructor(protected _watchOptions: IWatchProcessorOptions) { super({ overrideOptions: WatchProcessor.overrideOptions(_watchOptions), - findBundle: () => "bundle.js", + findBundle: ConfigProcessor.findBundle, ..._watchOptions }); } diff --git a/packages/rspack-test-tools/src/runner/runner/cjs.ts b/packages/rspack-test-tools/src/runner/runner/cjs.ts index 423ca1aeb13a..a294ad0fc48d 100644 --- a/packages/rspack-test-tools/src/runner/runner/cjs.ts +++ b/packages/rspack-test-tools/src/runner/runner/cjs.ts @@ -117,7 +117,10 @@ export class CommonJsRunner< ); if (this._options.testConfig.moduleScope) { - this._options.testConfig.moduleScope(currentModuleScope, this._options.stats); + this._options.testConfig.moduleScope( + currentModuleScope, + this._options.stats + ); } if (!this._options.runInNewContext) { @@ -133,7 +136,6 @@ export class CommonJsRunner< const fn = this._options.runInNewContext ? vm.runInNewContext(code, this.globalContext!, file.path) : vm.runInThisContext(code, file.path); - fn.call( this._options.testConfig.nonEsmThis ? this._options.testConfig.nonEsmThis(modulePath) diff --git a/packages/rspack-test-tools/src/runner/runner/watch.ts b/packages/rspack-test-tools/src/runner/runner/watch.ts index f9c721a4dfc5..e1771299ce77 100644 --- a/packages/rspack-test-tools/src/runner/runner/watch.ts +++ b/packages/rspack-test-tools/src/runner/runner/watch.ts @@ -1,6 +1,5 @@ import path from "node:path"; -import FakeDocument from "../../helper/legacy/FakeDocument"; import type { ECompilerType } from "../../type"; import type { IBasicModuleScope, @@ -8,27 +7,20 @@ import type { TRunnerRequirer } from "../type"; import type { IBasicRunnerOptions } from "./basic"; -import { CommonJsRunner } from "./cjs"; +import { FakeDocumentWebRunner } from "./web/fake"; interface IWatchRunnerOptions extends IBasicRunnerOptions { stepName: string; + isWeb: boolean; } export class WatchRunner< T extends ECompilerType = ECompilerType.Rspack -> extends CommonJsRunner { - private document: any; +> extends FakeDocumentWebRunner { private state: Record = {}; constructor(protected _watchOptions: IWatchRunnerOptions) { super(_watchOptions); - this.document = new FakeDocument(_watchOptions.dist); - } - - protected createGlobalContext() { - const globalContext = super.createGlobalContext(); - globalContext.document = this.document; - return globalContext; } protected createModuleScope( @@ -43,4 +35,8 @@ export class WatchRunner< moduleScope.WATCH_STEP = this._watchOptions.stepName; return moduleScope; } + + run(file: string) { + return super.run(file); + } } diff --git a/packages/rspack-test-tools/src/runner/watch.ts b/packages/rspack-test-tools/src/runner/watch.ts index 44390911341a..82ea6e40b192 100644 --- a/packages/rspack-test-tools/src/runner/watch.ts +++ b/packages/rspack-test-tools/src/runner/watch.ts @@ -32,14 +32,21 @@ export class WatchRunnerFactory< if (!stepName) { throw new Error("Can not get watch step name from context"); } + + const isWeb = Array.isArray(compilerOptions) + ? compilerOptions.some(option => { + return option.target === "web" || option.target === "webworker"; + }) + : compilerOptions.target === "web" || + compilerOptions.target === "webworker"; + return new WatchRunner({ env, stats, name: this.name, stepName, - runInNewContext: - compilerOptions.target === "web" || - compilerOptions.target === "webworker", + runInNewContext: isWeb, + isWeb, testConfig: this.context.getTestConfig(), source: this.context.getSource(), dist: this.context.getDist(), diff --git a/packages/rspack-test-tools/tests/__snapshots__/Config.test.js.snap b/packages/rspack-test-tools/tests/__snapshots__/Config.test.js.snap new file mode 100644 index 000000000000..509302db9e81 --- /dev/null +++ b/packages/rspack-test-tools/tests/__snapshots__/Config.test.js.snap @@ -0,0 +1,403 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`config config/builtins/css-auto exported tests css/auto can handle css module correctly 1`] = ` +Object { + "style": "-ca56f23580d7bbb484-style", +} +`; + +exports[`config config/builtins/css-modules-composes exported tests css modules composes 1`] = ` +Object { + "simple-bar": "-a7200a43b5c2530b1414-simple-bar -f27007fff641a72c371d-imported-simple", + "simple-foo": "-a7200a43b5c2530b1414-simple-foo -f27007fff641a72c371d-imported-simple", +} +`; + +exports[`config config/builtins/css-modules-composes-preprocessers exported tests css modules with css preprocessers 1`] = ` +Object { + "class": "-a7200a43b5c2530b1414-class -feb80f2fe6d30-lessClass", + "ghi": "-a7200a43b5c2530b1414-ghi", + "other": "-a7200a43b5c2530b1414-other -ebd90a48d100efd-scssClass", + "otherClassName": "-a7200a43b5c2530b1414-otherClassName globalClassName", +} +`; + +exports[`config config/builtins/css-modules-composes-sass exported tests css modules in scss 1`] = ` +Object { + "bar": "-f1f00e6e62b9a7fadb02-bar -a3b1929b59eeacf15a4-foo", +} +`; + +exports[`config config/builtins/css-modules-dedupe exported tests css modules dedupe 1`] = ` +Object { + "backButton": "-baa5c4d806a1671b-backButton -e683a459bd7b289e1b8d-secondaryButton -d8686a334ddc6bdd0-button", + "nextButton": "-baa5c4d806a1671b-nextButton -a510fa2734ece860e70-primaryButton -d8686a334ddc6bdd0-button", +} +`; + +exports[`config config/builtins/css-modules-exports-only exported tests css modules exportsOnly 1`] = ` +Object { + "simple-bar": "-a7200a43b5c2530b1414-simple-bar -f27007fff641a72c371d-imported-simple", + "simple-foo": "-a7200a43b5c2530b1414-simple-foo -f27007fff641a72c371d-imported-simple", +} +`; + +exports[`config config/builtins/css-modules-local-ident-name-hash exported tests css modules localIdentName with hash 1`] = ` +Object { + "#": "ccc05d01b5ed91e5a4d", + "##": "c16d3dd30b7cca2d412d", + "#.#.#": "c6e8935740a6209cd48e", + "#fake-id": "c053ba4f7badbc242", + "++++++++++[>+++++++>++++++++++>+++>+<<<<-]>++.>+.+++++++..+++.>++.<<+++++++++++++++.>.+++.------.--------.>+.>.": "f5775dd999dc95dd350", + "-a-b-c-": "e171381fc62026ffe05b", + "-a0-34a___f": "e6419db424263d77191e", + ".": "b1061101d3ff1517822", + "123": "c6f16686ef1ceab9728", + "1a2b3c": "ea6ff32ba4e9ad9e4c71", + ":)": "c8ad14da9eacd8206f95", + ":\`(": "ab034bce3407ac44d", + ":hover": "d64a685363ea14300", + ":hover:focus:active": "f1ba6ba717fdcfbecc52", + "<><<<>><>": "a8471bf6e63738086bfa", + "

": "f4a8269a3b7c6f38759d", + "?": "d4a79a8d3ea0285a", + "@": "dba948edd127566bb", + "B&W?": "d26b7b08b3ee0fec8093", + "[attr=value]": "cf98e323da83a7ef1", + "_": "b21bb2384964fa8226c0", + "_test": "acd3c0528ed3c3330", + "className": "a20f38af3e2122251", + "f!o!o": "a4a2e3c31408bb709fb", + "f'o'o": "c1712d83c24d5b7bd9d", + "f*o*o": "f5ce693ef2ea116b05", + "f+o+o": "e3714c708c213b9e", + "f/o/o": "cd9b24dbefa12afeaba5", + "f\\\\o\\\\o": "f90fa90fb52121fce923", + "foo.bar": "a7554930d53d1d95676", + "foo/bar": "e21d87979464d92960b9", + "foo/bar/baz": "e26519aba0f8e105eb13", + "foo\\\\bar": "f93c23331183aeac60", + "foo\\\\bar\\\\baz": "aa79627c6f36d0c8f9", + "f~o~o": "f4c89337b4a84e05", + "m_x_@": "f106c601eea0160783bb", + "someId": "f7dad309581ff59a8c1", + "subClass": "f904cf1d95567c868707", + "test": "c8e76de9832d60b206c2", + "{}": "e73bdae84335b77", + "©": "d4c6ea8dbaf492a7e42e", + "“‘’”": "d3df6d853c11234b8", + "⌘⌥": "bbb74fa7684d2b07", + "☺☃": "d09672ed2a23417fa543", + "♥": "f5682d5025ab700972a0", + "𝄞♪♩♫♬": "b7e928b15b6057d2f8", + "💩": "bb34b4e107a01390e3fb", + "😍": "e5439193d7906536aeac", +} +`; + +exports[`config config/builtins/css-modules-local-ident-name-path exported tests css modules localIdentName with path 1`] = ` +Object { + "#": "./src/index__#", + "##": "./src/index__##", + "#.#.#": "./src/index__#.#.#", + "#fake-id": "./src/index__#fake-id", + "++++++++++[>+++++++>++++++++++>+++>+<<<<-]>++.>+.+++++++..+++.>++.<<+++++++++++++++.>.+++.------.--------.>+.>.": "./src/index__++++++++++[>+++++++>++++++++++>+++>+<<<<-]>++.>+.+++++++..+++.>++.<<+++++++++++++++.>.+++.------.--------.>+.>.", + "-a-b-c-": "./src/index__-a-b-c-", + "-a0-34a___f": "./src/index__-a0-34a___f", + ".": "./src/index__.", + "123": "./src/index__123", + "1a2b3c": "./src/index__1a2b3c", + ":)": "./src/index__:)", + ":\`(": "./src/index__:\`(", + ":hover": "./src/index__:hover", + ":hover:focus:active": "./src/index__:hover:focus:active", + "<><<<>><>": "./src/index__<><<<>><>", + "

": "./src/index__

", + "?": "./src/index__?", + "@": "./src/index__@", + "B&W?": "./src/index__B&W?", + "[attr=value]": "./src/index__[attr=value]", + "_": "./src/index___", + "_test": "./src/index___test", + "className": "./src/index__className", + "f!o!o": "./src/index__f!o!o", + "f'o'o": "./src/index__f'o'o", + "f*o*o": "./src/index__f*o*o", + "f+o+o": "./src/index__f+o+o", + "f/o/o": "./src/index__f/o/o", + "f\\\\o\\\\o": "./src/index__f\\\\o\\\\o", + "foo.bar": "./src/index__foo.bar", + "foo/bar": "./src/index__foo/bar", + "foo/bar/baz": "./src/index__foo/bar/baz", + "foo\\\\bar": "./src/index__foo\\\\bar", + "foo\\\\bar\\\\baz": "./src/index__foo\\\\bar\\\\baz", + "f~o~o": "./src/index__f~o~o", + "m_x_@": "./src/index__m_x_@", + "someId": "./src/index__someId", + "subClass": "./src/index__subClass", + "test": "./src/index__test", + "{}": "./src/index__{}", + "©": "./src/index__©", + "“‘’”": "./src/index__“‘’”", + "⌘⌥": "./src/index__⌘⌥", + "☺☃": "./src/index__☺☃", + "♥": "./src/index__♥", + "𝄞♪♩♫♬": "./src/index__𝄞♪♩♫♬", + "💩": "./src/index__💩", + "😍": "./src/index__😍", +} +`; + +exports[`config config/builtins/css-modules-locals-convention-camelCase exported tests css modules localsConvention with camelCase 1`] = ` +Object { + "btn--info_is-disabled_1": "-a7200a43b5c2530b1414-btn--info_is-disabled_1", + "btn-info_is-disabled": "-a7200a43b5c2530b1414-btn-info_is-disabled", + "btnInfoIsDisabled": "-a7200a43b5c2530b1414-btn-info_is-disabled", + "btnInfoIsDisabled1": "-a7200a43b5c2530b1414-btn--info_is-disabled_1", + "fooBar": "-a7200a43b5c2530b1414-foo_bar", + "foo_bar": "-a7200a43b5c2530b1414-foo_bar", + "simple": "-a7200a43b5c2530b1414-simple", +} +`; + +exports[`config config/builtins/css-modules-locals-convention-camelCaseOnly exported tests css modules localsConvention with camelCaseOnly 1`] = ` +Object { + "btnInfoIsDisabled": "-a7200a43b5c2530b1414-btn-info_is-disabled", + "btnInfoIsDisabled1": "-a7200a43b5c2530b1414-btn--info_is-disabled_1", + "fooBar": "-a7200a43b5c2530b1414-foo_bar", + "simple": "-a7200a43b5c2530b1414-simple", +} +`; + +exports[`config config/builtins/css-modules-locals-convention-dashes exported tests css modules localsConvention with dashes 1`] = ` +Object { + "btn--info_is-disabled_1": "-a7200a43b5c2530b1414-btn--info_is-disabled_1", + "btn-info-is-disabled": "-a7200a43b5c2530b1414-btn-info_is-disabled", + "btn-info-is-disabled-1": "-a7200a43b5c2530b1414-btn--info_is-disabled_1", + "btn-info_is-disabled": "-a7200a43b5c2530b1414-btn-info_is-disabled", + "foo-bar": "-a7200a43b5c2530b1414-foo_bar", + "foo_bar": "-a7200a43b5c2530b1414-foo_bar", + "simple": "-a7200a43b5c2530b1414-simple", +} +`; + +exports[`config config/builtins/css-modules-pseudo exported tests css modules pseudo syntax 1`] = ` +Object { + "bar": "-a7200a43b5c2530b1414-bar", + "bav": "-a7200a43b5c2530b1414-bav", + "foo": "-a7200a43b5c2530b1414-foo", + "four": "-a7200a43b5c2530b1414-four", + "one": "-a7200a43b5c2530b1414-one", + "three": "-a7200a43b5c2530b1414-three", + "two": "-a7200a43b5c2530b1414-two", +} +`; + +exports[`config config/builtins/css-modules-simple exported tests css modules simple test 1`] = ` +Object { + "style": "-ca56f23580d7bbb484-style", +} +`; + +exports[`config config/chunk-index/available-modules-order-index exported tests should compile 1`] = ` +".m { + color: red; +} +.n { + color: blue; +} +head{--webpack--shared:&_547,Ā587;}" +`; + +exports[`config config/css/at-import-in-the-top exported tests at-import-in-the-top 1`] = ` +"@import url(\\"https://fonts.googleapis.com/css2?family=Roboto\\"); +@import url(\\"https://fonts.googleapis.com/css2?family=Inter\\"); +.c { + color: pink; +} + + + + +.a { + color: blue; +} + + + +.b { + color: red; +} + +head{--webpack--909:&_412,Ā645ą_34;}" +`; + +exports[`config config/css/export-selector exported tests should have correct css result 1`] = ` +"/* #region \\"./style.module.css?imported\\" */ +/* +- type: css/auto +*/ + + +.local {} + + + + +/* #endregion \\"./style.module.css?imported\\" */ + +head{--webpack--imported_js:foo:foo/bar:b a r/local:local/dashName:dashName/&\\\\.\\\\/style\\\\.module\\\\.css\\\\?imported;}" +`; + +exports[`config config/css/rewrite-url exported tests should rewrite the css url() 1`] = `"5d8d67b36a3d70a5cea9.png"`; + +exports[`config config/css/rewrite-url exported tests should rewrite the css url() 2`] = `"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAOCAYAAAAbvf3sAAAACXBIWXMAABYlAAAWJQFJUiTwAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAEWSURBVHgBjZFRSsNAEIb/3fQAOUK9gfpe6YIovjU3UE+gJ2g8gTcw3sC+itUFrW+BeAN7ATFSKAjbHWcSC+mSlszLDrvfzvzzj0LHmNpZBtBQd4Gf7fuYgHPPueoCe1DK1UsHd7Dzw+P0daQj/SC5h09OzdGktw221vZXUBlVMN0ILPd6O9yzBBXX8CBdv6kWOGa4YLivQJNjM0ia73oTLsBwJjCB5gu4i7CgbsIey5ThEcOfKziTGFOGHypJeZ7jZ/Gbst4x2/fN9h2eGTNvgk92VrDEWLNmfJXLpIYrRy5b4Fs+9v2/pL0oUncI7FuHLI6PK5lJZGoe8qXNvrry27DesoRLpLPmNkTw9yEcxPWJMR+S/AFbfpAZqxwUNQAAAABJRU5ErkJggg=="`; + +exports[`config config/css/rewrite-url-css-variables exported tests should rewrite the css url() in css variables 1`] = `"5d8d67b36a3d70a5cea9.png"`; + +exports[`config config/css/rewrite-url-css-variables exported tests should rewrite the css url() in css variables 2`] = `"5d8d67b36a3d70a5cea9.png"`; + +exports[`config config/css/rewrite-url-with-css-filename exported tests should rewrite the css url() with publicPath and ~@ prefix 1`] = `"/image/logo.5d8d67b3.png"`; + +exports[`config config/css/rewrite-url-with-css-filename exported tests should rewrite the css url() with publicPath when output.cssFilename is set 1`] = `"/image/logo.5d8d67b3.png"`; + +exports[`config config/css/urls exported tests css urls should works 1`] = ` +"/* @supports (background-image: url(\\"unknown.png\\")) { + div { + a195: url(\\"img.png\\"); + } +} */ + +div { + a13: green url(data:image/png;base64,AAA) url(http://example.com/image.jpg) url(//example.com/image.png) xyz; +} + +div { + a14: url(\\"data:image/svg+xml;charset=utf-8,\\"); +} + +div { + a15: url(data:image/svg+xml;charset=utf-8,%3Csvg%20xmlns%3D%27http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%27%20viewBox%3D%270%200%2042%2026%27%20fill%3D%27%2523007aff%27%3E%3Crect%20width%3D%274%27%20height%3D%274%27%2F%3E%3Crect%20x%3D%278%27%20y%3D%271%27%20width%3D%2734%27%20height%3D%272%27%2F%3E%3Crect%20y%3D%2711%27%20width%3D%274%27%20height%3D%274%27%2F%3E%3Crect%20x%3D%278%27%20y%3D%2712%27%20width%3D%2734%27%20height%3D%272%27%2F%3E%3Crect%20y%3D%2722%27%20width%3D%274%27%20height%3D%274%27%2F%3E%3Crect%20x%3D%278%27%20y%3D%2723%27%20width%3D%2734%27%20height%3D%272%27%2F%3E%3C%2Fsvg%3E); +} + +div { + a16: url('data:image/svg+xml;charset=utf-8,#filter'); +} + +div { + a17: url(\\"data:image/svg+xml;charset=utf-8,%3Csvg%20xmlns%3D%5C%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%5C%22%3E%3Cfilter%20id%3D%5C%22filter%5C%22%3E%3CfeGaussianBlur%20in%3D%5C%22SourceAlpha%5C%22%20stdDeviation%3D%5C%220%5C%22%20%2F%3E%3CfeOffset%20dx%3D%5C%221%5C%22%20dy%3D%5C%222%5C%22%20result%3D%5C%22offsetblur%5C%22%20%2F%3E%3CfeFlood%20flood-color%3D%5C%22rgba(255%2C255%2C255%2C1)%5C%22%20%2F%3E%3CfeComposite%20in2%3D%5C%22offsetblur%5C%22%20operator%3D%5C%22in%5C%22%20%2F%3E%3CfeMerge%3E%3CfeMergeNode%20%2F%3E%3CfeMergeNode%20in%3D%5C%22SourceGraphic%5C%22%20%2F%3E%3C%2FfeMerge%3E%3C%2Ffilter%3E%3C%2Fsvg%3E%23filter\\"); +} + +div { + a18: url(#highlight); +} + +div { + a19: url(#line-marker); +} + +div { + a148: url('data:image/svg+xml,%3Csvg xmlns=\\"http://www.w3.org/2000/svg\\"%3E%3Crect width=\\"100%25\\" height=\\"100%25\\" style=\\"stroke: rgb(223,224,225); stroke-width: 2px; fill: none; stroke-dasharray: 6px 3px\\" /%3E%3C/svg%3E'); + a149: url('data:image/svg+xml,%3Csvg xmlns=\\"http://www.w3.org/2000/svg\\"%3E%3Crect width=\\"100%25\\" height=\\"100%25\\" style=\\"stroke: rgb(223,224,225); stroke-width: 2px; fill: none; stroke-dasharray: 6px 3px\\" /%3E%3C/svg%3E'); + a150: url('data:image/svg+xml,%3Csvg xmlns=\\"http://www.w3.org/2000/svg\\"%3E%3Crect width=\\"100%25\\" height=\\"100%25\\" style=\\"stroke: rgb(223,224,225); stroke-width: 2px; fill: none; stroke-dasharray: 6px 3px\\" /%3E%3C/svg%3E'); + a151: url('data:image/svg+xml;utf8,'); + a152: url('data:image/svg+xml;utf8,'); +} + +div { + a1: url(); + a114: url(09a1a1112c577c279435.png); +} + +div { + a143: url(data:image/svg+xml;charset=UTF-8,%3C%3Fxml%20version%3D%221.0%22%20encoding%3D%22utf-8%22%3F%3E%0A%3C!DOCTYPE%20svg%20PUBLIC%20%22-%2F%2FW3C%2F%2FDTD%20SVG%201.1%2F%2FEN%22%20%22http%3A%2F%2Fwww.w3.org%2FGraphics%2FSVG%2F1.1%2FDTD%2Fsvg11.dtd%22%3E%0A%3Csvg%20version%3D%221.1%22%20id%3D%22Layer_1%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20xmlns%3Axlink%3D%22http%3A%2F%2Fwww.w3.org%2F1999%2Fxlink%22%20x%3D%220px%22%20y%3D%220px%22%0A%09%20width%3D%22191px%22%20height%3D%22191px%22%20viewBox%3D%220%200%20191%20191%22%20enable-background%3D%22new%200%200%20191%20191%22%20xml%3Aspace%3D%22preserve%22%3E%0A%3Cpath%20fill%3D%22%23636363%22%20d%3D%22M95.5%2C0C42.8%2C0%2C0%2C42.8%2C0%2C95.5S42.8%2C191%2C95.5%2C191S191%2C148.2%2C191%2C95.5S148.2%2C0%2C95.5%2C0z%20M95.5%2C187.6%0A%09c-50.848%2C0-92.1-41.25-92.1-92.1c0-50.848%2C41.252-92.1%2C92.1-92.1c50.85%2C0%2C92.1%2C41.252%2C92.1%2C92.1%0A%09C187.6%2C146.35%2C146.35%2C187.6%2C95.5%2C187.6z%22%2F%3E%0A%3Cg%3E%0A%09%3Cpath%20fill%3D%22%23636363%22%20d%3D%22M92.9%2C10v8.6H91v-6.5c-0.1%2C0.1-0.2%2C0.2-0.4%2C0.3c-0.2%2C0.1-0.3%2C0.2-0.4%2C0.2c-0.1%2C0-0.3%2C0.1-0.5%2C0.2%0A%09%09c-0.2%2C0.1-0.3%2C0.1-0.5%2C0.1v-1.6c0.5-0.1%2C0.9-0.3%2C1.4-0.5c0.5-0.2%2C0.8-0.5%2C1.2-0.7h1.1V10z%22%2F%3E%0A%09%3Cpath%20fill%3D%22%23636363%22%20d%3D%22M97.1%2C17.1h3.602v1.5h-5.6V18c0-0.4%2C0.1-0.8%2C0.2-1.2c0.1-0.4%2C0.3-0.6%2C0.5-0.9c0.2-0.3%2C0.5-0.5%2C0.7-0.7%0A%09%09c0.2-0.2%2C0.5-0.4%2C0.7-0.6c0.199-0.2%2C0.5-0.3%2C0.6-0.5c0.102-0.2%2C0.301-0.3%2C0.5-0.5c0.2-0.2%2C0.2-0.3%2C0.301-0.5%0A%09%09c0.101-0.2%2C0.101-0.3%2C0.101-0.5c0-0.4-0.101-0.6-0.3-0.8c-0.2-0.2-0.4-0.3-0.801-0.3c-0.699%2C0-1.399%2C0.3-2.101%2C0.9v-1.6%0A%09%09c0.7-0.5%2C1.5-0.7%2C2.5-0.7c0.399%2C0%2C0.8%2C0.1%2C1.101%2C0.2c0.301%2C0.1%2C0.601%2C0.3%2C0.899%2C0.5c0.3%2C0.2%2C0.399%2C0.5%2C0.5%2C0.8%0A%09%09c0.101%2C0.3%2C0.2%2C0.6%2C0.2%2C1s-0.102%2C0.7-0.2%2C1c-0.099%2C0.3-0.3%2C0.6-0.5%2C0.8c-0.2%2C0.2-0.399%2C0.5-0.7%2C0.7c-0.3%2C0.2-0.5%2C0.4-0.8%2C0.6%0A%09%09c-0.2%2C0.1-0.399%2C0.3-0.5%2C0.4s-0.3%2C0.3-0.5%2C0.4s-0.2%2C0.3-0.3%2C0.4C97.1%2C17%2C97.1%2C17%2C97.1%2C17.1z%22%2F%3E%0A%3C%2Fg%3E%0A%3Cg%3E%0A%09%3Cpath%20fill%3D%22%23636363%22%20d%3D%22M15%2C95.4c0%2C0.7-0.1%2C1.4-0.2%2C2c-0.1%2C0.6-0.4%2C1.1-0.7%2C1.5C13.8%2C99.3%2C13.4%2C99.6%2C12.9%2C99.8s-1%2C0.3-1.5%2C0.3%0A%09%09c-0.7%2C0-1.3-0.1-1.8-0.3v-1.5c0.4%2C0.3%2C1%2C0.4%2C1.6%2C0.4c0.6%2C0%2C1.1-0.2%2C1.5-0.7c0.4-0.5%2C0.5-1.1%2C0.5-1.9l0%2C0%0A%09%09C12.8%2C96.7%2C12.3%2C96.9%2C11.5%2C96.9c-0.3%2C0-0.7-0.102-1-0.2c-0.3-0.101-0.5-0.3-0.8-0.5c-0.3-0.2-0.4-0.5-0.5-0.8%0A%09%09c-0.1-0.3-0.2-0.7-0.2-1c0-0.4%2C0.1-0.8%2C0.2-1.2c0.1-0.4%2C0.3-0.7%2C0.6-0.9c0.3-0.2%2C0.6-0.5%2C0.9-0.6c0.3-0.1%2C0.8-0.2%2C1.2-0.2%0A%09%09c0.5%2C0%2C0.9%2C0.1%2C1.2%2C0.3c0.3%2C0.2%2C0.7%2C0.4%2C0.9%2C0.8s0.5%2C0.7%2C0.6%2C1.2S15%2C94.8%2C15%2C95.4z%20M13.1%2C94.4c0-0.2%2C0-0.4-0.1-0.6%0A%09%09c-0.1-0.2-0.1-0.4-0.2-0.5c-0.1-0.1-0.2-0.2-0.4-0.3c-0.2-0.1-0.3-0.1-0.5-0.1c-0.2%2C0-0.3%2C0-0.4%2C0.1s-0.3%2C0.2-0.3%2C0.3%0A%09%09c0%2C0.1-0.2%2C0.3-0.2%2C0.4c0%2C0.1-0.1%2C0.4-0.1%2C0.6c0%2C0.2%2C0%2C0.4%2C0.1%2C0.6c0.1%2C0.2%2C0.1%2C0.3%2C0.2%2C0.4c0.1%2C0.1%2C0.2%2C0.2%2C0.4%2C0.3%0A%09%09c0.2%2C0.1%2C0.3%2C0.1%2C0.5%2C0.1c0.2%2C0%2C0.3%2C0%2C0.4-0.1s0.2-0.2%2C0.3-0.3c0.1-0.1%2C0.2-0.2%2C0.2-0.4C13%2C94.7%2C13.1%2C94.6%2C13.1%2C94.4z%22%2F%3E%0A%3C%2Fg%3E%0A%3Cg%3E%0A%09%3Cpath%20fill%3D%22%23636363%22%20d%3D%22M176%2C99.7V98.1c0.6%2C0.4%2C1.2%2C0.602%2C2%2C0.602c0.5%2C0%2C0.8-0.102%2C1.1-0.301c0.301-0.199%2C0.4-0.5%2C0.4-0.801%0A%09%09c0-0.398-0.2-0.699-0.5-0.898c-0.3-0.2-0.8-0.301-1.3-0.301h-0.802V95h0.701c1.101%2C0%2C1.601-0.4%2C1.601-1.1c0-0.7-0.4-1-1.302-1%0A%09%09c-0.6%2C0-1.1%2C0.2-1.6%2C0.5v-1.5c0.6-0.3%2C1.301-0.4%2C2.1-0.4c0.9%2C0%2C1.5%2C0.2%2C2%2C0.6s0.701%2C0.9%2C0.701%2C1.5c0%2C1.1-0.601%2C1.8-1.701%2C2.1l0%2C0%0A%09%09c0.602%2C0.1%2C1.102%2C0.3%2C1.4%2C0.6s0.5%2C0.8%2C0.5%2C1.3c0%2C0.801-0.3%2C1.4-0.9%2C1.9c-0.6%2C0.5-1.398%2C0.7-2.398%2C0.7%0A%09%09C177.2%2C100.1%2C176.5%2C100%2C176%2C99.7z%22%2F%3E%0A%3C%2Fg%3E%0A%3Cg%3E%0A%09%3Cpath%20fill%3D%22%23636363%22%20d%3D%22M98.5%2C179.102c0%2C0.398-0.1%2C0.799-0.2%2C1.199C98.2%2C180.7%2C98%2C181%2C97.7%2C181.2s-0.601%2C0.5-0.9%2C0.601%0A%09%09c-0.3%2C0.1-0.7%2C0.199-1.2%2C0.199c-0.5%2C0-0.9-0.1-1.3-0.3c-0.4-0.2-0.7-0.399-0.9-0.8c-0.2-0.4-0.5-0.7-0.6-1.2%0A%09%09c-0.1-0.5-0.2-1-0.2-1.601c0-0.699%2C0.1-1.399%2C0.3-2c0.2-0.601%2C0.4-1.101%2C0.8-1.5c0.4-0.399%2C0.7-0.699%2C1.2-1c0.5-0.3%2C1-0.3%2C1.6-0.3%0A%09%09c0.6%2C0%2C1.2%2C0.101%2C1.5%2C0.199v1.5c-0.4-0.199-0.9-0.399-1.4-0.399c-0.3%2C0-0.6%2C0.101-0.8%2C0.2c-0.2%2C0.101-0.5%2C0.3-0.7%2C0.5%0A%09%09c-0.2%2C0.199-0.3%2C0.5-0.4%2C0.8c-0.1%2C0.301-0.2%2C0.7-0.2%2C1.101l0%2C0c0.4-0.601%2C1-0.8%2C1.8-0.8c0.3%2C0%2C0.7%2C0.1%2C0.9%2C0.199%0A%09%09c0.2%2C0.101%2C0.5%2C0.301%2C0.7%2C0.5c0.199%2C0.2%2C0.398%2C0.5%2C0.5%2C0.801C98.5%2C178.2%2C98.5%2C178.7%2C98.5%2C179.102z%20M96.7%2C179.2%0A%09%09c0-0.899-0.4-1.399-1.1-1.399c-0.2%2C0-0.3%2C0-0.5%2C0.1c-0.2%2C0.101-0.3%2C0.201-0.4%2C0.301c-0.1%2C0.101-0.2%2C0.199-0.2%2C0.4%0A%09%09c0%2C0.199-0.1%2C0.299-0.1%2C0.5c0%2C0.199%2C0%2C0.398%2C0.1%2C0.6s0.1%2C0.3%2C0.2%2C0.5c0.1%2C0.199%2C0.2%2C0.199%2C0.4%2C0.3c0.2%2C0.101%2C0.3%2C0.101%2C0.5%2C0.101%0A%09%09c0.2%2C0%2C0.3%2C0%2C0.5-0.101c0.2-0.101%2C0.301-0.199%2C0.301-0.3c0-0.1%2C0.199-0.301%2C0.199-0.399C96.6%2C179.7%2C96.7%2C179.4%2C96.7%2C179.2z%22%2F%3E%0A%3C%2Fg%3E%0A%3Ccircle%20fill%3D%22%23636363%22%20cx%3D%2295%22%20cy%3D%2295%22%20r%3D%227%22%2F%3E%0A%3C%2Fsvg%3E%0A) + 50% 50%/191px no-repeat; +} + +head{--webpack--120:&_13;}" +`; + +exports[`config config/optimization/minimizer-esm-asset exported tests minimizing an asset file of esm type should success 1`] = `"console.log(import.meta.url);export const a=1;"`; + +exports[`config config/optimization/minimizer-swc-extract-comments exported tests should keep the extracted license file stable 1`] = ` +"/** + * bar + * @license MIT + */ + +/** + * baz + * @license MIT + */ + +/** + * foo + * @license MIT + */ + +/** + * relative + * @license MIT + */" +`; + +exports[`config config/plugins/chunk-modules exported tests chunk-modules 1`] = ` +Object { + "515": Object { + "entryModules": Array [], + "modules": Array [ + Object { + "context": "", + "identifier": "/async.js", + "resource": "/async.js", + }, + ], + }, + "909": Object { + "entryModules": Array [ + Object { + "context": "", + "identifier": "/index.js", + "resource": "/index.js", + }, + ], + "modules": Array [ + Object { + "context": "", + "identifier": "/index.js", + "resource": "/index.js", + }, + Object { + "identifier": "external node-commonjs \\"fs\\"", + }, + Object { + "identifier": "external node-commonjs \\"path\\"", + }, + ], + }, +} +`; + +exports[`config config/schemes/data-imports exported tests data imports 1`] = ` +".red{color: red;} +.b{color: green} +.a { color: palegreen; };;; + +.bad { + a: url(data:text/bad-base64;base64,abcd?#iefix); + b: url(\\"data:text/bad-base64;base64, abcd?#iefix\\"); +} + + /* .b{color: green} */ + + + +.class { + a: url(26a611d6d05cbb01e459.svg); + b: url(26a611d6d05cbb01e459.svg); + c: url(26a611d6d05cbb01e459); + d: url(26a611d6d05cbb01e459); +} + +head{--webpack--909:&_653,Ā47ĄĀ645ą_49Ď571;}" +`; diff --git a/packages/rspack-test-tools/tests/errorCases/error-test-push.js b/packages/rspack-test-tools/tests/errorCases/error-test-push.js index c989426664f4..a8581db71891 100644 --- a/packages/rspack-test-tools/tests/errorCases/error-test-push.js +++ b/packages/rspack-test-tools/tests/errorCases/error-test-push.js @@ -20,7 +20,7 @@ module.exports = { Object { "message": " × Error: test push\\n │ at xxx\\n │ at xxx\\n │ at xxx\\n │ at xxx\\n │ at xxx\\n │ at xxx\\n", "moduleTrace": Array [], - "stack": "Error: test push\\n at Object.fn (packages/rspack-test-tools/tests/errorCases/error-test-push.js:10:31)\\n at next (packages/rspack-lite-tapable/src/index.ts:773:10)\\n at AsyncSeriesHook.callAsyncStageRange (packages/rspack-lite-tapable/src/index.ts:790:3)\\n at AsyncSeriesHook.callAsync (packages/rspack-lite-tapable/src/index.ts:218:15)\\n at packages/rspack/src/Compiler.ts:613:29\\n at packages/rspack/src/Compiler.ts:660:15", + "stack": "Error: test push\\n at Object.fn (packages/rspack-test-tools/tests/errorCases/error-test-push.js:10:31)\\n at next (packages/rspack-lite-tapable/dist/index.js:530:25)\\n at AsyncSeriesHook.callAsyncStageRange (packages/rspack-lite-tapable/dist/index.js:550:9)\\n at AsyncSeriesHook.callAsync (packages/rspack-lite-tapable/dist/index.js:88:21)\\n at packages/rspack/dist/Compiler.js:458:41\\n at packages/rspack/dist/Compiler.js:525:23", }, Object { "message": " × Module not found: Can't resolve './answer' in 'packages/rspack-test-tools/tests/fixtures/errors/resolve-fail-esm'\\n ╭────\\n 1 │ import { answer } from './answer'\\n · ──────────\\n ╰────\\n help: Did you mean './answer.js'?\\n \\n The request './answer' failed to resolve only because it was resolved as fully specified,\\n probably because the origin is strict EcmaScript Module,\\n e. g. a module with javascript mimetype, a '*.mjs' file, or a '*.js' file where the package.json contains '\\"type\\": \\"module\\"'.\\n \\n The extension in the request is mandatory for it to be fully specified.\\n Add the extension to the request.\\n", diff --git a/packages/rspack-test-tools/tests/errorCases/error-test-shift.js b/packages/rspack-test-tools/tests/errorCases/error-test-shift.js index a991f4037897..2dc75ab462e1 100644 --- a/packages/rspack-test-tools/tests/errorCases/error-test-shift.js +++ b/packages/rspack-test-tools/tests/errorCases/error-test-shift.js @@ -24,7 +24,7 @@ module.exports = { Object { "message": " × Error: test unshift\\n │ at xxx\\n │ at xxx\\n │ at xxx\\n │ at xxx\\n │ at xxx\\n │ at xxx\\n", "moduleTrace": Array [], - "stack": "Error: test unshift\\n at Object.fn (packages/rspack-test-tools/tests/errorCases/error-test-shift.js:13:35)\\n at next (packages/rspack-lite-tapable/src/index.ts:773:10)\\n at AsyncSeriesHook.callAsyncStageRange (packages/rspack-lite-tapable/src/index.ts:790:3)\\n at AsyncSeriesHook.callAsync (packages/rspack-lite-tapable/src/index.ts:218:15)\\n at packages/rspack/src/Compiler.ts:613:29\\n at packages/rspack/src/Compiler.ts:660:15", + "stack": "Error: test unshift\\n at Object.fn (packages/rspack-test-tools/tests/errorCases/error-test-shift.js:13:35)\\n at next (packages/rspack-lite-tapable/dist/index.js:530:25)\\n at AsyncSeriesHook.callAsyncStageRange (packages/rspack-lite-tapable/dist/index.js:550:9)\\n at AsyncSeriesHook.callAsync (packages/rspack-lite-tapable/dist/index.js:88:21)\\n at packages/rspack/dist/Compiler.js:458:41\\n at packages/rspack/dist/Compiler.js:525:23", }, ], "warnings": Array [], diff --git a/packages/rspack-test-tools/tests/errorCases/error-test-splice-1.js b/packages/rspack-test-tools/tests/errorCases/error-test-splice-1.js index 59eec7a025d6..6c82b9306a63 100644 --- a/packages/rspack-test-tools/tests/errorCases/error-test-splice-1.js +++ b/packages/rspack-test-tools/tests/errorCases/error-test-splice-1.js @@ -20,7 +20,7 @@ module.exports = { Object { "message": " × Error: test splice\\n │ at xxx\\n │ at xxx\\n │ at xxx\\n │ at xxx\\n │ at xxx\\n │ at xxx\\n", "moduleTrace": Array [], - "stack": "Error: test splice\\n at Object.fn (packages/rspack-test-tools/tests/errorCases/error-test-splice-1.js:10:39)\\n at next (packages/rspack-lite-tapable/src/index.ts:773:10)\\n at AsyncSeriesHook.callAsyncStageRange (packages/rspack-lite-tapable/src/index.ts:790:3)\\n at AsyncSeriesHook.callAsync (packages/rspack-lite-tapable/src/index.ts:218:15)\\n at packages/rspack/src/Compiler.ts:613:29\\n at packages/rspack/src/Compiler.ts:660:15", + "stack": "Error: test splice\\n at Object.fn (packages/rspack-test-tools/tests/errorCases/error-test-splice-1.js:10:39)\\n at next (packages/rspack-lite-tapable/dist/index.js:530:25)\\n at AsyncSeriesHook.callAsyncStageRange (packages/rspack-lite-tapable/dist/index.js:550:9)\\n at AsyncSeriesHook.callAsync (packages/rspack-lite-tapable/dist/index.js:88:21)\\n at packages/rspack/dist/Compiler.js:458:41\\n at packages/rspack/dist/Compiler.js:525:23", }, ], "warnings": Array [], diff --git a/packages/rspack-test-tools/tests/errorCases/error-test-splice-2.js b/packages/rspack-test-tools/tests/errorCases/error-test-splice-2.js index a9385ca472a2..6491e84e3d95 100644 --- a/packages/rspack-test-tools/tests/errorCases/error-test-splice-2.js +++ b/packages/rspack-test-tools/tests/errorCases/error-test-splice-2.js @@ -20,7 +20,7 @@ module.exports = { Object { "message": " × Error: test splice\\n │ at xxx\\n │ at xxx\\n │ at xxx\\n │ at xxx\\n │ at xxx\\n │ at xxx\\n", "moduleTrace": Array [], - "stack": "Error: test splice\\n at Object.fn (packages/rspack-test-tools/tests/errorCases/error-test-splice-2.js:10:39)\\n at next (packages/rspack-lite-tapable/src/index.ts:773:10)\\n at AsyncSeriesHook.callAsyncStageRange (packages/rspack-lite-tapable/src/index.ts:790:3)\\n at AsyncSeriesHook.callAsync (packages/rspack-lite-tapable/src/index.ts:218:15)\\n at packages/rspack/src/Compiler.ts:613:29\\n at packages/rspack/src/Compiler.ts:660:15", + "stack": "Error: test splice\\n at Object.fn (packages/rspack-test-tools/tests/errorCases/error-test-splice-2.js:10:39)\\n at next (packages/rspack-lite-tapable/dist/index.js:530:25)\\n at AsyncSeriesHook.callAsyncStageRange (packages/rspack-lite-tapable/dist/index.js:550:9)\\n at AsyncSeriesHook.callAsync (packages/rspack-lite-tapable/dist/index.js:88:21)\\n at packages/rspack/dist/Compiler.js:458:41\\n at packages/rspack/dist/Compiler.js:525:23", }, Object { "message": " × Module not found: Can't resolve './answer' in 'packages/rspack-test-tools/tests/fixtures/errors/resolve-fail-esm'\\n ╭────\\n 1 │ import { answer } from './answer'\\n · ──────────\\n ╰────\\n help: Did you mean './answer.js'?\\n \\n The request './answer' failed to resolve only because it was resolved as fully specified,\\n probably because the origin is strict EcmaScript Module,\\n e. g. a module with javascript mimetype, a '*.mjs' file, or a '*.js' file where the package.json contains '\\"type\\": \\"module\\"'.\\n \\n The extension in the request is mandatory for it to be fully specified.\\n Add the extension to the request.\\n", diff --git a/packages/rspack-test-tools/tests/errorCases/warning-test-push.js b/packages/rspack-test-tools/tests/errorCases/warning-test-push.js index 4d6330591c0d..323d2e333a50 100644 --- a/packages/rspack-test-tools/tests/errorCases/warning-test-push.js +++ b/packages/rspack-test-tools/tests/errorCases/warning-test-push.js @@ -21,7 +21,7 @@ module.exports = { Object { "message": " ⚠ Error: test push\\n │ at xxx\\n │ at xxx\\n │ at xxx\\n │ at xxx\\n │ at xxx\\n │ at xxx\\n", "moduleTrace": Array [], - "stack": "Error: test push\\n at Object.fn (packages/rspack-test-tools/tests/errorCases/warning-test-push.js:10:33)\\n at next (packages/rspack-lite-tapable/src/index.ts:773:10)\\n at AsyncSeriesHook.callAsyncStageRange (packages/rspack-lite-tapable/src/index.ts:790:3)\\n at AsyncSeriesHook.callAsync (packages/rspack-lite-tapable/src/index.ts:218:15)\\n at packages/rspack/src/Compiler.ts:613:29\\n at packages/rspack/src/Compiler.ts:660:15", + "stack": "Error: test push\\n at Object.fn (packages/rspack-test-tools/tests/errorCases/warning-test-push.js:10:33)\\n at next (packages/rspack-lite-tapable/dist/index.js:530:25)\\n at AsyncSeriesHook.callAsyncStageRange (packages/rspack-lite-tapable/dist/index.js:550:9)\\n at AsyncSeriesHook.callAsync (packages/rspack-lite-tapable/dist/index.js:88:21)\\n at packages/rspack/dist/Compiler.js:458:41\\n at packages/rspack/dist/Compiler.js:525:23", }, Object { "message": " ⚠ Module parse warning:\\n ╰─▶ ⚠ Unsupported feature: require.main.require() is not supported by Rspack.\\n ╭────\\n 1 │ require.main.require('./file');\\n · ──────────────────────────────\\n ╰────\\n \\n", diff --git a/packages/rspack-test-tools/tests/errorCases/warning-test-shift.js b/packages/rspack-test-tools/tests/errorCases/warning-test-shift.js index 6c3a50882fa2..1b75531b0322 100644 --- a/packages/rspack-test-tools/tests/errorCases/warning-test-shift.js +++ b/packages/rspack-test-tools/tests/errorCases/warning-test-shift.js @@ -25,7 +25,7 @@ module.exports = { Object { "message": " ⚠ Error: test unshift\\n │ at xxx\\n │ at xxx\\n │ at xxx\\n │ at xxx\\n │ at xxx\\n │ at xxx\\n", "moduleTrace": Array [], - "stack": "Error: test unshift\\n at Object.fn (packages/rspack-test-tools/tests/errorCases/warning-test-shift.js:13:37)\\n at next (packages/rspack-lite-tapable/src/index.ts:773:10)\\n at AsyncSeriesHook.callAsyncStageRange (packages/rspack-lite-tapable/src/index.ts:790:3)\\n at AsyncSeriesHook.callAsync (packages/rspack-lite-tapable/src/index.ts:218:15)\\n at packages/rspack/src/Compiler.ts:613:29\\n at packages/rspack/src/Compiler.ts:660:15", + "stack": "Error: test unshift\\n at Object.fn (packages/rspack-test-tools/tests/errorCases/warning-test-shift.js:13:37)\\n at next (packages/rspack-lite-tapable/dist/index.js:530:25)\\n at AsyncSeriesHook.callAsyncStageRange (packages/rspack-lite-tapable/dist/index.js:550:9)\\n at AsyncSeriesHook.callAsync (packages/rspack-lite-tapable/dist/index.js:88:21)\\n at packages/rspack/dist/Compiler.js:458:41\\n at packages/rspack/dist/Compiler.js:525:23", }, ], } diff --git a/packages/rspack-test-tools/tests/errorCases/warning-test-splice-1.js b/packages/rspack-test-tools/tests/errorCases/warning-test-splice-1.js index c5caee97b97e..e2e6f5d14c6b 100644 --- a/packages/rspack-test-tools/tests/errorCases/warning-test-splice-1.js +++ b/packages/rspack-test-tools/tests/errorCases/warning-test-splice-1.js @@ -21,7 +21,7 @@ module.exports = { Object { "message": " ⚠ Error: test splice\\n │ at xxx\\n │ at xxx\\n │ at xxx\\n │ at xxx\\n │ at xxx\\n │ at xxx\\n", "moduleTrace": Array [], - "stack": "Error: test splice\\n at Object.fn (packages/rspack-test-tools/tests/errorCases/warning-test-splice-1.js:10:41)\\n at next (packages/rspack-lite-tapable/src/index.ts:773:10)\\n at AsyncSeriesHook.callAsyncStageRange (packages/rspack-lite-tapable/src/index.ts:790:3)\\n at AsyncSeriesHook.callAsync (packages/rspack-lite-tapable/src/index.ts:218:15)\\n at packages/rspack/src/Compiler.ts:613:29\\n at packages/rspack/src/Compiler.ts:660:15", + "stack": "Error: test splice\\n at Object.fn (packages/rspack-test-tools/tests/errorCases/warning-test-splice-1.js:10:41)\\n at next (packages/rspack-lite-tapable/dist/index.js:530:25)\\n at AsyncSeriesHook.callAsyncStageRange (packages/rspack-lite-tapable/dist/index.js:550:9)\\n at AsyncSeriesHook.callAsync (packages/rspack-lite-tapable/dist/index.js:88:21)\\n at packages/rspack/dist/Compiler.js:458:41\\n at packages/rspack/dist/Compiler.js:525:23", }, ], } diff --git a/packages/rspack-test-tools/tests/errorCases/warning-test-splice-2.js b/packages/rspack-test-tools/tests/errorCases/warning-test-splice-2.js index 81411f16cdc1..b614b5994ffd 100644 --- a/packages/rspack-test-tools/tests/errorCases/warning-test-splice-2.js +++ b/packages/rspack-test-tools/tests/errorCases/warning-test-splice-2.js @@ -21,7 +21,7 @@ module.exports = { Object { "message": " ⚠ Error: test splice\\n │ at xxx\\n │ at xxx\\n │ at xxx\\n │ at xxx\\n │ at xxx\\n │ at xxx\\n", "moduleTrace": Array [], - "stack": "Error: test splice\\n at Object.fn (packages/rspack-test-tools/tests/errorCases/warning-test-splice-2.js:10:41)\\n at next (packages/rspack-lite-tapable/src/index.ts:773:10)\\n at AsyncSeriesHook.callAsyncStageRange (packages/rspack-lite-tapable/src/index.ts:790:3)\\n at AsyncSeriesHook.callAsync (packages/rspack-lite-tapable/src/index.ts:218:15)\\n at packages/rspack/src/Compiler.ts:613:29\\n at packages/rspack/src/Compiler.ts:660:15", + "stack": "Error: test splice\\n at Object.fn (packages/rspack-test-tools/tests/errorCases/warning-test-splice-2.js:10:41)\\n at next (packages/rspack-lite-tapable/dist/index.js:530:25)\\n at AsyncSeriesHook.callAsyncStageRange (packages/rspack-lite-tapable/dist/index.js:550:9)\\n at AsyncSeriesHook.callAsync (packages/rspack-lite-tapable/dist/index.js:88:21)\\n at packages/rspack/dist/Compiler.js:458:41\\n at packages/rspack/dist/Compiler.js:525:23", }, Object { "message": " ⚠ Module parse warning:\\n ╰─▶ ⚠ Unsupported feature: require.main.require() is not supported by Rspack.\\n ╭────\\n 1 │ require.main.require('./file');\\n · ──────────────────────────────\\n ╰────\\n \\n", diff --git a/packages/rspack-test-tools/tests/hotCases/css/parser-and-generator-states/index.js b/packages/rspack-test-tools/tests/hotCases/css/parser-and-generator-states/index.js index 69dd6e9cdfe1..c9b9f020775e 100644 --- a/packages/rspack-test-tools/tests/hotCases/css/parser-and-generator-states/index.js +++ b/packages/rspack-test-tools/tests/hotCases/css/parser-and-generator-states/index.js @@ -3,7 +3,7 @@ import style from './index.module.css'; it("should store and resume css parser and generator states", (done) => { expect(style['btnInfoIsDisabled']).toBe('./index.module.css__btn-info_is-disabled'); module.hot.accept("./index.module.css", () => { - expect(style['btnInfoIsDisabled']).toBe('./index.module.css__btn-info_is-disabled'); + expect(style['btnInfoIsEnabled']).toBe('./index.module.css__btn-info_is-enabled'); done(); }); NEXT(require("../../update")(done)); diff --git a/packages/rspack-test-tools/tests/hotCases/css/parser-and-generator-states/index.module.css b/packages/rspack-test-tools/tests/hotCases/css/parser-and-generator-states/index.module.css index 6892dac590ac..9e1b7492a7b3 100644 --- a/packages/rspack-test-tools/tests/hotCases/css/parser-and-generator-states/index.module.css +++ b/packages/rspack-test-tools/tests/hotCases/css/parser-and-generator-states/index.module.css @@ -4,6 +4,6 @@ --- -.btn-info_is-disabled { +.btn-info_is-enabled { color: red; } \ No newline at end of file diff --git a/packages/rspack-test-tools/tests/hotCases/css/parser-and-generator-states/test.config.js b/packages/rspack-test-tools/tests/hotCases/css/parser-and-generator-states/test.config.js new file mode 100644 index 000000000000..5424297748be --- /dev/null +++ b/packages/rspack-test-tools/tests/hotCases/css/parser-and-generator-states/test.config.js @@ -0,0 +1,3 @@ +module.exports = { + documentType: 'fake' +} diff --git a/packages/rspack-test-tools/tests/watchCases/context/out-of-context/0/src/index.js b/packages/rspack-test-tools/tests/watchCases/context/out-of-context/0/src/index.js index 78aa741a604e..a497b91ee755 100644 --- a/packages/rspack-test-tools/tests/watchCases/context/out-of-context/0/src/index.js +++ b/packages/rspack-test-tools/tests/watchCases/context/out-of-context/0/src/index.js @@ -1,7 +1,7 @@ require("./foo.less"); -const fs = require("fs"); -const path = require("path"); +const fs = __non_webpack_require__("fs"); +const path = __non_webpack_require__("path"); it("should detect changes for loader fileDependency which out of context", function () { const less = fs.readFileSync(path.resolve(__dirname, "bundle.css"), "utf-8"); diff --git a/packages/rspack-test-tools/tests/watchCases/context/out-of-context/rspack.config.js b/packages/rspack-test-tools/tests/watchCases/context/out-of-context/rspack.config.js index 26f9f792a6ff..d3155078c7d3 100644 --- a/packages/rspack-test-tools/tests/watchCases/context/out-of-context/rspack.config.js +++ b/packages/rspack-test-tools/tests/watchCases/context/out-of-context/rspack.config.js @@ -1,6 +1,11 @@ /** @type {import('@rspack/core').Configuration} */ module.exports = { entry: "./src/index", + target: 'web', + node: false, + output: { + publicPath: '/' + }, module: { rules: [ { diff --git a/packages/rspack-test-tools/tests/watchCases/context/out-of-context/test.config.js b/packages/rspack-test-tools/tests/watchCases/context/out-of-context/test.config.js new file mode 100644 index 000000000000..933fb49f3892 --- /dev/null +++ b/packages/rspack-test-tools/tests/watchCases/context/out-of-context/test.config.js @@ -0,0 +1,6 @@ +module.exports = { + documentType: 'fake', + findBundle() { + return ['bundle.css', 'bundle.js'] + } +}