From 94fc3d9ac6b33b8d0af5a8b57161c1819be2b026 Mon Sep 17 00:00:00 2001 From: zoomdong <1344492820@qq.com> Date: Tue, 11 Nov 2025 13:14:04 +0800 Subject: [PATCH 1/2] fix(pack): support parse ~ prefix for less & sass --- .../tests/snapshot/node_modules/antd/reset.css | 5 +++++ .../tests/snapshot/style/less/config.json | 10 ++++++++++ .../tests/snapshot/style/less/input/index.js | 3 +++ .../tests/snapshot/style/less/input/index.less | 1 + ...rates_pack-tests_tests_snapshot_ed9c1e41.css | 11 +++++++++++ ...s_pack-tests_tests_snapshot_ed9c1e41.css.map | 7 +++++++ ..._tests_snapshot_style_less_input_02f480f0.js | 17 +++++++++++++++++ ...ts_snapshot_style_less_input_02f480f0.js.map | 7 +++++++ .../tests/snapshot/style/less/output/main.js | 5 +++++ .../snapshot/style/less/output/main.js.map | 5 +++++ next.js | 2 +- 11 files changed, 72 insertions(+), 1 deletion(-) create mode 100644 crates/pack-tests/tests/snapshot/node_modules/antd/reset.css create mode 100644 crates/pack-tests/tests/snapshot/style/less/config.json create mode 100644 crates/pack-tests/tests/snapshot/style/less/input/index.js create mode 100644 crates/pack-tests/tests/snapshot/style/less/input/index.less create mode 100644 crates/pack-tests/tests/snapshot/style/less/output/crates_pack-tests_tests_snapshot_ed9c1e41.css create mode 100644 crates/pack-tests/tests/snapshot/style/less/output/crates_pack-tests_tests_snapshot_ed9c1e41.css.map create mode 100644 crates/pack-tests/tests/snapshot/style/less/output/crates_pack-tests_tests_snapshot_style_less_input_02f480f0.js create mode 100644 crates/pack-tests/tests/snapshot/style/less/output/crates_pack-tests_tests_snapshot_style_less_input_02f480f0.js.map create mode 100644 crates/pack-tests/tests/snapshot/style/less/output/main.js create mode 100644 crates/pack-tests/tests/snapshot/style/less/output/main.js.map diff --git a/crates/pack-tests/tests/snapshot/node_modules/antd/reset.css b/crates/pack-tests/tests/snapshot/node_modules/antd/reset.css new file mode 100644 index 000000000..2f6a742c4 --- /dev/null +++ b/crates/pack-tests/tests/snapshot/node_modules/antd/reset.css @@ -0,0 +1,5 @@ +.body{ + display: inline-block; + fill: currentColor; + vertical-align: text-bottom; + } \ No newline at end of file diff --git a/crates/pack-tests/tests/snapshot/style/less/config.json b/crates/pack-tests/tests/snapshot/style/less/config.json new file mode 100644 index 000000000..675f94969 --- /dev/null +++ b/crates/pack-tests/tests/snapshot/style/less/config.json @@ -0,0 +1,10 @@ +{ + "config": { + "entry": [ + { + "import": "input/index.js", + "name": "main" + } + ] + } +} \ No newline at end of file diff --git a/crates/pack-tests/tests/snapshot/style/less/input/index.js b/crates/pack-tests/tests/snapshot/style/less/input/index.js new file mode 100644 index 000000000..52755b9dc --- /dev/null +++ b/crates/pack-tests/tests/snapshot/style/less/input/index.js @@ -0,0 +1,3 @@ +import style from './index.less'; + +style; \ No newline at end of file diff --git a/crates/pack-tests/tests/snapshot/style/less/input/index.less b/crates/pack-tests/tests/snapshot/style/less/input/index.less new file mode 100644 index 000000000..1f88f7bb8 --- /dev/null +++ b/crates/pack-tests/tests/snapshot/style/less/input/index.less @@ -0,0 +1 @@ +@import '~antd/reset.css'; \ No newline at end of file diff --git a/crates/pack-tests/tests/snapshot/style/less/output/crates_pack-tests_tests_snapshot_ed9c1e41.css b/crates/pack-tests/tests/snapshot/style/less/output/crates_pack-tests_tests_snapshot_ed9c1e41.css new file mode 100644 index 000000000..5d627aab2 --- /dev/null +++ b/crates/pack-tests/tests/snapshot/style/less/output/crates_pack-tests_tests_snapshot_ed9c1e41.css @@ -0,0 +1,11 @@ +/* [project]/crates/pack-tests/tests/snapshot/node_modules/antd/reset.css [client] (css) */ +.body { + fill: currentColor; + vertical-align: text-bottom; + display: inline-block; +} + +/* [project]/crates/pack-tests/tests/snapshot/style/less/input/index.less.css?modules [client] (css) */ + + +/*# sourceMappingURL=crates_pack-tests_tests_snapshot_ed9c1e41.css.map*/ \ No newline at end of file diff --git a/crates/pack-tests/tests/snapshot/style/less/output/crates_pack-tests_tests_snapshot_ed9c1e41.css.map b/crates/pack-tests/tests/snapshot/style/less/output/crates_pack-tests_tests_snapshot_ed9c1e41.css.map new file mode 100644 index 000000000..d33d17bee --- /dev/null +++ b/crates/pack-tests/tests/snapshot/style/less/output/crates_pack-tests_tests_snapshot_ed9c1e41.css.map @@ -0,0 +1,7 @@ +{ + "version": 3, + "sources": [], + "sections": [ + {"offset": {"line": 1, "column": 0}, "map": {"version":3,"sources":["turbopack:///[project]/crates/pack-tests/tests/snapshot/node_modules/antd/reset.css"],"sourcesContent":[".body{\n display: inline-block;\n fill: currentColor;\n vertical-align: text-bottom;\n }"],"names":[],"mappings":"AAAA","ignoreList":[0]}}, + {"offset": {"line": 8, "column": 0}, "map": {"version":3,"sources":["turbopack:///turbopack:///[project]/crates/pack-tests/tests/snapshot/style/less/input/index.less"],"sourcesContent":["\n@import '~antd/reset.css';"],"names":[],"mappings":""}}] +} \ No newline at end of file diff --git a/crates/pack-tests/tests/snapshot/style/less/output/crates_pack-tests_tests_snapshot_style_less_input_02f480f0.js b/crates/pack-tests/tests/snapshot/style/less/output/crates_pack-tests_tests_snapshot_style_less_input_02f480f0.js new file mode 100644 index 000000000..feef991af --- /dev/null +++ b/crates/pack-tests/tests/snapshot/style/less/output/crates_pack-tests_tests_snapshot_style_less_input_02f480f0.js @@ -0,0 +1,17 @@ +(globalThis.TURBOPACK || (globalThis.TURBOPACK = [])).push([typeof document === "object" ? document.currentScript : undefined, +41, ((__turbopack_context__) => { + +__turbopack_context__.v({ +}); +}), +15, ((__turbopack_context__) => { +"use strict"; + +var __TURBOPACK__imported__module__41__ = __turbopack_context__.i(41); +; +__TURBOPACK__imported__module__41__["default"]; +__turbopack_context__.s([]); +}), +]); + +//# sourceMappingURL=crates_pack-tests_tests_snapshot_style_less_input_02f480f0.js.map \ No newline at end of file diff --git a/crates/pack-tests/tests/snapshot/style/less/output/crates_pack-tests_tests_snapshot_style_less_input_02f480f0.js.map b/crates/pack-tests/tests/snapshot/style/less/output/crates_pack-tests_tests_snapshot_style_less_input_02f480f0.js.map new file mode 100644 index 000000000..a142d154b --- /dev/null +++ b/crates/pack-tests/tests/snapshot/style/less/output/crates_pack-tests_tests_snapshot_style_less_input_02f480f0.js.map @@ -0,0 +1,7 @@ +{ + "version": 3, + "sources": [], + "sections": [ + {"offset": {"line": 3, "column": 0}, "map": {"version":3,"sources":["turbopack:///[project]/crates/pack-tests/tests/snapshot/style/less/input/index.less?modules [client] (css module)"],"sourcesContent":["__turbopack_context__.v({\n});\n"],"names":[],"mappings":"AAAA;AACA"}}, + {"offset": {"line": 9, "column": 0}, "map": {"version":3,"sources":["turbopack:///[project]/crates/pack-tests/tests/snapshot/style/less/input/index.js"],"sourcesContent":["import style from './index.less';\n\nstyle;"],"names":[],"mappings":"AAAA;;AAEA,8CAAK"}}] +} \ No newline at end of file diff --git a/crates/pack-tests/tests/snapshot/style/less/output/main.js b/crates/pack-tests/tests/snapshot/style/less/output/main.js new file mode 100644 index 000000000..2fd4c3a88 --- /dev/null +++ b/crates/pack-tests/tests/snapshot/style/less/output/main.js @@ -0,0 +1,5 @@ +(globalThis.TURBOPACK || (globalThis.TURBOPACK = [])).push([ + typeof document === "object" ? document.currentScript : undefined, + {"otherChunks":["crates_pack-tests_tests_snapshot_ed9c1e41.css","crates_pack-tests_tests_snapshot_style_less_input_02f480f0.js"],"runtimeModuleIds":[15]} +]); +// Dummy runtime diff --git a/crates/pack-tests/tests/snapshot/style/less/output/main.js.map b/crates/pack-tests/tests/snapshot/style/less/output/main.js.map new file mode 100644 index 000000000..c15d7ec00 --- /dev/null +++ b/crates/pack-tests/tests/snapshot/style/less/output/main.js.map @@ -0,0 +1,5 @@ +{ + "version": 3, + "sources": [], + "sections": [] +} \ No newline at end of file diff --git a/next.js b/next.js index be61779e9..ee0e4f638 160000 --- a/next.js +++ b/next.js @@ -1 +1 @@ -Subproject commit be61779e9c293feb5ad46d0e9f78ee4318a61596 +Subproject commit ee0e4f6384c4a22b366d2faded519c4b62750eff From 1a7b904231dbae8019266737fce832bb64bf647c Mon Sep 17 00:00:00 2001 From: zoomdong <1344492820@qq.com> Date: Tue, 11 Nov 2025 14:06:05 +0800 Subject: [PATCH 2/2] chore: remove custom-loader --- .../webpack-loaders/custom-loader/config.json | 4 +--- .../Error evaluating Node.js code-7dd645.txt | 16 ---------------- ...sing ecmascript source code failed-273ff6.txt | 6 ++++++ .../crates_pack-tests_tests_snapshot_fe2230b9.js | 2 +- 4 files changed, 8 insertions(+), 20 deletions(-) delete mode 100644 crates/pack-tests/tests/snapshot/webpack-loaders/custom-loader/issues/Error evaluating Node.js code-7dd645.txt create mode 100644 crates/pack-tests/tests/snapshot/webpack-loaders/custom-loader/issues/Parsing ecmascript source code failed-273ff6.txt diff --git a/crates/pack-tests/tests/snapshot/webpack-loaders/custom-loader/config.json b/crates/pack-tests/tests/snapshot/webpack-loaders/custom-loader/config.json index 8b44fc434..3cf33956f 100644 --- a/crates/pack-tests/tests/snapshot/webpack-loaders/custom-loader/config.json +++ b/crates/pack-tests/tests/snapshot/webpack-loaders/custom-loader/config.json @@ -9,9 +9,7 @@ "module": { "rules": { "*.txt": { - "loaders": [ - "./test-file-loader.js" - ], + "loaders": [], "as": "*.js" } } diff --git a/crates/pack-tests/tests/snapshot/webpack-loaders/custom-loader/issues/Error evaluating Node.js code-7dd645.txt b/crates/pack-tests/tests/snapshot/webpack-loaders/custom-loader/issues/Error evaluating Node.js code-7dd645.txt deleted file mode 100644 index 6bed42469..000000000 --- a/crates/pack-tests/tests/snapshot/webpack-loaders/custom-loader/issues/Error evaluating Node.js code-7dd645.txt +++ /dev/null @@ -1,16 +0,0 @@ -error - [transform] /crates/pack-tests/tests/snapshot/webpack-loaders/custom-loader/input/test.txt Error evaluating Node.js code - - Error: Cannot find module './test-file-loader.js' - Require stack: - - WORKSPACE_ROOT/packages/pack/.turbopack/[turbopack]_runtime.js - - WORKSPACE_ROOT/packages/pack/.turbopack/webpack-loaders.js - [at Function._resolveFilename (node:internal/modules/cjs/loader:1401:15)] - [at Function.resolve (node:internal/modules/helpers:145:19)] - [at externalRequire.resolve (WORKSPACE_ROOT/packages/pack/.turbopack/[turbopack]_runtime.js:533:20)] - [at WORKSPACE_ROOT/packages/pack/.turbopack/__8b1e0af0.js:385:86] - [at ] - [at WORKSPACE_ROOT/packages/pack/.turbopack/__8b1e0af0.js:384:41] - [at ] - [at transform (WORKSPACE_ROOT/packages/pack/.turbopack/__8b1e0af0.js:133:12)] - [at run (WORKSPACE_ROOT/packages/pack/.turbopack/__c7ae8543.js:443:37)] - [at run (WORKSPACE_ROOT/packages/pack/.turbopack/__c7ae8543.js:464:25)] \ No newline at end of file diff --git a/crates/pack-tests/tests/snapshot/webpack-loaders/custom-loader/issues/Parsing ecmascript source code failed-273ff6.txt b/crates/pack-tests/tests/snapshot/webpack-loaders/custom-loader/issues/Parsing ecmascript source code failed-273ff6.txt new file mode 100644 index 000000000..1fcf5bf2f --- /dev/null +++ b/crates/pack-tests/tests/snapshot/webpack-loaders/custom-loader/issues/Parsing ecmascript source code failed-273ff6.txt @@ -0,0 +1,6 @@ +error - [analysis] /crates/pack-tests/tests/snapshot/webpack-loaders/custom-loader/input/test.txt.js:1:7 Parsing ecmascript source code failed + + v--v + 1 + loader test + + ^--^ + + Expected ';', '}' or \ No newline at end of file diff --git a/crates/pack-tests/tests/snapshot/webpack-loaders/custom-loader/output/crates_pack-tests_tests_snapshot_fe2230b9.js b/crates/pack-tests/tests/snapshot/webpack-loaders/custom-loader/output/crates_pack-tests_tests_snapshot_fe2230b9.js index a428e7d3a..cd25b5145 100644 --- a/crates/pack-tests/tests/snapshot/webpack-loaders/custom-loader/output/crates_pack-tests_tests_snapshot_fe2230b9.js +++ b/crates/pack-tests/tests/snapshot/webpack-loaders/custom-loader/output/crates_pack-tests_tests_snapshot_fe2230b9.js @@ -15,7 +15,7 @@ __turbopack_context__.s([ }), 6, ((__turbopack_context__, module, exports) => { -const e = new Error("Could not parse module '[project]/crates/pack-tests/tests/snapshot/webpack-loaders/custom-loader/input/test.txt.js', file not found"); +const e = new Error("Could not parse module '[project]/crates/pack-tests/tests/snapshot/webpack-loaders/custom-loader/input/test.txt.js'\n\nExpected ';', '}' or "); e.code = 'MODULE_UNPARSABLE'; throw e; }),