From aff28d2432e70fead703b4118d8a5e3a4dc71410 Mon Sep 17 00:00:00 2001 From: neverland Date: Sun, 19 Jul 2026 18:23:11 +0800 Subject: [PATCH 1/3] chore: use ESM package configuration in examples --- package.json | 1 + rsbuild/express/package.json | 2 +- .../express/{rsbuild.config.mjs => rsbuild.config.js} | 0 rsbuild/express/{server.mjs => server.js} | 0 rsbuild/fastify/package.json | 2 +- .../fastify/{rsbuild.config.mjs => rsbuild.config.js} | 0 rsbuild/fastify/{server.mjs => server.js} | 0 rsbuild/ssr-express-with-manifest/package.json | 4 ++-- .../{prod-server.mjs => prod-server.js} | 0 .../{rsbuild.config.mjs => rsbuild.config.js} | 0 .../{server.mjs => server.js} | 0 rsbuild/ssr-express/package.json | 4 ++-- .../ssr-express/{prod-server.mjs => prod-server.js} | 0 .../{rsbuild.config.mjs => rsbuild.config.js} | 0 rsbuild/ssr-express/{server.mjs => server.js} | 0 rsdoctor/rspack/package.json | 1 + .../rspack/{rspack.config.mjs => rspack.config.js} | 0 rslib/module-federation/package.json | 1 + .../{postcss.config.mjs => postcss.config.js} | 0 .../{postcss.config.mjs => postcss.config.js} | 0 rspack/basic-ts/package.json | 1 + .../basic-ts/{rspack.config.mjs => rspack.config.js} | 0 rspack/basic/package.json | 1 + rspack/basic/{rspack.config.mjs => rspack.config.js} | 0 rspack/basic/src/index.js | 2 +- rspack/builtin-swc-loader/package.json | 1 + .../{rspack.config.mjs => rspack.config.js} | 0 rspack/builtin-swc-loader/src/index.jsx | 2 +- rspack/bundle-splitting/index.js | 6 +++--- rspack/bundle-splitting/package.json | 1 + .../{rspack.config.mjs => rspack.config.js} | 0 .../case-sensitive-paths-webpack-plugin/package.json | 1 + .../{rspack.config.mjs => rspack.config.js} | 0 .../case-sensitive-paths-webpack-plugin/src/index.js | 2 +- rspack/code-splitting/index.js | 4 ++-- rspack/code-splitting/package.json | 1 + .../{rspack.config.mjs => rspack.config.js} | 0 rspack/common-libs/lib1/package.json | 1 + rspack/common-libs/lib1/src/index.ts | 4 ++-- rspack/common-libs/lib1/tsconfig.json | 2 +- rspack/common-libs/lib2/package.json | 1 + rspack/common-libs/lib2/src/index.ts | 4 ++-- rspack/common-libs/lib2/tsconfig.json | 2 +- rspack/common-libs/lib3/package.json | 1 + rspack/cra-ts/package.json | 1 + rspack/cra-ts/{rspack.config.mjs => rspack.config.js} | 0 rspack/cra/package.json | 1 + rspack/cra/{rspack.config.mjs => rspack.config.js} | 0 rspack/cra/src/App.test.js | 2 +- rspack/cra/src/index.jsx | 4 ++-- rspack/css-chunking-plugin/package.json | 1 + .../{rspack.config.mjs => rspack.config.js} | 0 rspack/css-chunking-plugin/src/index.js | 2 +- rspack/css-parser-generator-options/package.json | 1 + .../{rspack.config.mjs => rspack.config.js} | 0 rspack/dll-reference/index.js | 4 ++-- rspack/dll-reference/package.json | 1 + .../{rspack.config.mjs => rspack.config.js} | 0 rspack/dll/package.json | 1 + rspack/dll/{rspack.config.mjs => rspack.config.js} | 0 rspack/emotion/package.json | 1 + rspack/emotion/{rspack.config.mjs => rspack.config.js} | 0 rspack/eslint/{eslint.config.mjs => eslint.config.js} | 0 rspack/eslint/package.json | 3 ++- rspack/eslint/{rspack.config.mjs => rspack.config.js} | 0 ...spack.config.loader.mjs => rspack.config.loader.js} | 0 rspack/eslint/src/index.js | 2 +- rspack/express/package.json | 1 + rspack/express/{rspack.config.mjs => rspack.config.js} | 5 ++++- rspack/extract-license/package.json | 1 + .../{rspack.config.mjs => rspack.config.js} | 0 rspack/extract-license/src/index.js | 3 ++- .../generate-package-json-webpack-plugin/package.json | 1 + .../{rspack.config.mjs => rspack.config.js} | 0 rspack/hooks-after-resolve/package.json | 1 + .../{rspack.config.mjs => rspack.config.js} | 0 rspack/hooks-after-resolve/src/index.js | 2 +- rspack/html-webpack-plugin/package.json | 1 + .../{rspack.config.mjs => rspack.config.js} | 0 rspack/http-import/package.json | 1 + .../{rspack.config.mjs => rspack.config.js} | 0 rspack/inline-const-enum/package.json | 1 + .../{rspack.config.mjs => rspack.config.js} | 0 rspack/inline-const/package.json | 1 + .../{rspack.config.mjs => rspack.config.js} | 0 rspack/inline-enum/package.json | 1 + .../{rspack.config.mjs => rspack.config.js} | 0 rspack/javascript-api/package.json | 1 + rspack/lazy-compilation-server/dev.js | 6 +++--- rspack/lazy-compilation-server/package.json | 1 + rspack/lazy-compilation-server/src/index.js | 4 ++-- rspack/library-cjs/package.json | 1 + .../{rspack.config.mjs => rspack.config.js} | 1 + rspack/library-cjs/src/index.js | 4 ++-- rspack/library-esm/package.json | 1 + .../{rspack.config.mjs => rspack.config.js} | 0 rspack/library-esm/src/index.js | 4 ++-- rspack/library-umd/package.json | 1 + .../{rspack.config.mjs => rspack.config.js} | 0 rspack/library-umd/src/index.js | 4 ++-- rspack/license-webpack-plugin/package.json | 1 + .../{rspack.config.mjs => rspack.config.js} | 0 rspack/lightingcss-loader/package.json | 1 + .../{rspack.config.mjs => rspack.config.js} | 0 rspack/lightingcss-loader/src/index.js | 2 +- rspack/loader-compat/package.json | 1 + .../{rspack.config.mjs => rspack.config.js} | 3 +++ rspack/minify-test/a.js | 2 +- rspack/minify-test/a2.js | 2 +- rspack/minify-test/b.js | 2 +- rspack/minify-test/index.js | 10 +++++----- .../{rspack.config.mjs => rspack.config.js} | 0 rspack/module-federation-v1.5/app/package.json | 1 + .../app/{rspack.config.mjs => rspack.config.js} | 0 rspack/module-federation-v1.5/app/src/bootstrap.js | 2 +- rspack/module-federation-v1.5/app/src/index.js | 2 +- rspack/module-federation-v1.5/lib1/package.json | 1 + .../lib1/{rspack.config.mjs => rspack.config.js} | 0 rspack/module-federation-v1.5/lib1/src/bootstrap.js | 2 +- rspack/module-federation-v1.5/lib1/src/index.js | 2 +- rspack/module-federation-v1.5/lib2/package.json | 1 + .../lib2/{rspack.config.mjs => rspack.config.js} | 0 rspack/module-federation-v1.5/package.json | 1 + rspack/module-federation-v1/app/package.json | 1 + .../app/{rspack.config.mjs => rspack.config.js} | 0 rspack/module-federation-v1/app/src/bootstrap.js | 2 +- rspack/module-federation-v1/app/src/index.js | 2 +- rspack/module-federation-v1/lib1/package.json | 1 + .../lib1/{rspack.config.mjs => rspack.config.js} | 0 rspack/module-federation-v1/lib1/src/bootstrap.js | 2 +- rspack/module-federation-v1/lib1/src/index.js | 2 +- rspack/module-federation-v1/lib2/package.json | 1 + .../lib2/{rspack.config.mjs => rspack.config.js} | 0 rspack/module-federation-v1/package.json | 1 + rspack/monaco-editor-js/package.json | 1 + .../{rspack.config.mjs => rspack.config.js} | 0 rspack/monaco-editor-ts-react/package.json | 1 + .../{rspack.config.mjs => rspack.config.js} | 0 rspack/monaco-editor-webpack-plugin/index.js | 2 +- rspack/monaco-editor-webpack-plugin/package.json | 1 + .../{rspack.config.mjs => rspack.config.js} | 0 rspack/multi-entry/index.js | 4 ++-- rspack/multi-entry/package.json | 1 + .../{rspack.config.mjs => rspack.config.js} | 0 rspack/nest-alias/package.json | 1 + .../nest-alias/{rspack.config.mjs => rspack.config.js} | 0 rspack/nestjs/package.json | 3 ++- rspack/nestjs/{rspack.config.mjs => rspack.config.js} | 3 ++- rspack/next-rspack-app-router/next.config.js | 4 ++-- rspack/next-rspack-app-router/package.json | 1 + rspack/next-rspack-page-router/next.config.js | 4 ++-- rspack/next-rspack-page-router/package.json | 1 + rspack/node-globals-shim/package.json | 1 + .../{rspack.config.mjs => rspack.config.js} | 0 rspack/node-globals-shim/src/index.js | 4 ++-- rspack/node-polyfill/package.json | 1 + .../{rspack.config.mjs => rspack.config.js} | 0 rspack/node-polyfill/src/index.js | 5 +++-- rspack/node-polyfill/src/logger.js | 4 ++-- rspack/perfsee/package.json | 1 + rspack/perfsee/{rspack.config.mjs => rspack.config.js} | 0 rspack/perfsee/src/index.js | 2 +- rspack/polyfill/package.json | 1 + .../polyfill/{rspack.config.mjs => rspack.config.js} | 0 rspack/polyfill/src/index.js | 2 +- rspack/postcss-loader/package.json | 1 + .../{rspack.config.mjs => rspack.config.js} | 0 rspack/preact-refresh/package.json | 1 + .../{rspack.config.mjs => rspack.config.js} | 0 rspack/preact-refresh/src/index.jsx | 2 +- rspack/preact/package.json | 1 + rspack/preact/{rspack.config.mjs => rspack.config.js} | 0 rspack/preact/src/index.jsx | 2 +- rspack/proxy/package.json | 1 + rspack/proxy/{rspack.config.mjs => rspack.config.js} | 0 rspack/react-compiler-babel-ts/babel.config.js | 2 +- rspack/react-compiler-babel-ts/package.json | 1 + .../{rspack.config.mjs => rspack.config.js} | 0 rspack/react-compiler-babel/babel.config.js | 2 +- rspack/react-compiler-babel/package.json | 1 + .../{rspack.config.mjs => rspack.config.js} | 0 rspack/react-compiler-babel/src/index.jsx | 2 +- rspack/react-refresh-babel-loader/package.json | 1 + .../{rspack.config.mjs => rspack.config.js} | 0 rspack/react-refresh-esm/package.json | 1 + .../{rspack.config.mjs => rspack.config.js} | 0 rspack/react-refresh/package.json | 1 + .../{rspack.config.mjs => rspack.config.js} | 0 rspack/react-with-extract-css/package.json | 1 + .../{rspack.config.mjs => rspack.config.js} | 0 rspack/react-with-extract-css/src/index.jsx | 2 +- rspack/react-with-less/package.json | 1 + .../{rspack.config.mjs => rspack.config.js} | 0 rspack/react-with-less/src/index.jsx | 2 +- rspack/react-with-sass/package.json | 1 + .../{rspack.config.mjs => rspack.config.js} | 0 rspack/react-with-sass/src/index.jsx | 2 +- rspack/react/package.json | 1 + rspack/react/{rspack.config.mjs => rspack.config.js} | 0 rspack/react/src/index.jsx | 2 +- rspack/rspack-manifest-plugin/package.json | 1 + .../{rspack.config.mjs => rspack.config.js} | 0 rspack/rspack-manifest-plugin/test.js | 10 +++++----- rspack/rspack-rsc/rspack.config.js | 2 ++ rspack/rspack-rsc/server.js | 2 +- rspack/sentry/package.json | 1 + rspack/sentry/{rspack.config.mjs => rspack.config.js} | 0 rspack/sentry/src/index.js | 2 +- rspack/solid/package.json | 1 + rspack/solid/{rspack.config.mjs => rspack.config.js} | 0 rspack/solid/src/App.jsx | 2 +- rspack/solid/src/index.jsx | 2 +- rspack/source-map-with-vscode-debugging/package.json | 1 + .../{rspack.config.mjs => rspack.config.js} | 0 rspack/stats/package.json | 1 + rspack/stats/{rspack.config.mjs => rspack.config.js} | 0 rspack/stats/src/index.js | 2 +- rspack/styled-components/package.json | 1 + .../{rspack.config.mjs => rspack.config.js} | 0 rspack/svgr/package.json | 1 + rspack/svgr/{rspack.config.mjs => rspack.config.js} | 0 rspack/terser-webpack-plugin/package.json | 1 + .../{rspack.config.mjs => rspack.config.js} | 0 rspack/treeshaking-transform-imports/package.json | 1 + .../{rspack.config.mjs => rspack.config.js} | 0 rspack/treeshaking-transform-imports/src/a.js | 2 +- rspack/treeshaking-transform-imports/src/index.js | 2 +- rspack/treeshaking-transform-imports/src/sdk.js | 6 +++--- rspack/ts-checker-rspack-plugin/package.json | 1 + .../{rspack.config.mjs => rspack.config.js} | 0 rspack/type-reexports-presence/package.json | 1 + .../{rspack.config.mjs => rspack.config.js} | 0 rspack/vanilla-extract-css/package.json | 1 + .../{rspack.config.mjs => rspack.config.js} | 0 rspack/vue-jsx/package.json | 1 + rspack/vue-jsx/{rspack.config.mjs => rspack.config.js} | 0 rspack/vue-jsx/src/main.jsx | 2 +- rspack/vue-tsx/package.json | 1 + rspack/vue-tsx/{rspack.config.mjs => rspack.config.js} | 0 rspack/vue-vanilla/package.json | 1 + .../{rspack.config.mjs => rspack.config.js} | 0 rspack/vue/package.json | 1 + rspack/vue/{rspack.config.mjs => rspack.config.js} | 0 rspack/wasm-simple/example.js | 2 +- rspack/wasm-simple/package.json | 1 + .../{rspack.config.mjs => rspack.config.js} | 0 rspack/webpack-bundle-analyzer/package.json | 1 + .../{rspack.config.mjs => rspack.config.js} | 0 rspack/webpack-stats-plugin/package.json | 1 + .../{rspack.config.mjs => rspack.config.js} | 0 rspack/worker-inline/package.json | 1 + .../{rspack.config.mjs => rspack.config.js} | 0 rspack/worker/chat-worker.js | 2 +- rspack/worker/example.js | 2 +- rspack/worker/fib-worker.js | 2 +- rspack/worker/package.json | 1 + rspack/worker/{rspack.config.mjs => rspack.config.js} | 0 rspack/worklet/loader/worklet-loader.js | 7 ++++--- rspack/worklet/package.json | 1 + rspack/worklet/{rspack.config.mjs => rspack.config.js} | 0 rspack/worklet/src/index.js | 4 ++-- rspack/worklet/src/worklet/complex.worklet.js | 2 +- .../{rstest.config.mts => rstest.config.ts} | 0 263 files changed, 216 insertions(+), 111 deletions(-) rename rsbuild/express/{rsbuild.config.mjs => rsbuild.config.js} (100%) rename rsbuild/express/{server.mjs => server.js} (100%) rename rsbuild/fastify/{rsbuild.config.mjs => rsbuild.config.js} (100%) rename rsbuild/fastify/{server.mjs => server.js} (100%) rename rsbuild/ssr-express-with-manifest/{prod-server.mjs => prod-server.js} (100%) rename rsbuild/ssr-express-with-manifest/{rsbuild.config.mjs => rsbuild.config.js} (100%) rename rsbuild/ssr-express-with-manifest/{server.mjs => server.js} (100%) rename rsbuild/ssr-express/{prod-server.mjs => prod-server.js} (100%) rename rsbuild/ssr-express/{rsbuild.config.mjs => rsbuild.config.js} (100%) rename rsbuild/ssr-express/{server.mjs => server.js} (100%) rename rsdoctor/rspack/{rspack.config.mjs => rspack.config.js} (100%) rename rslib/react-tailwindcss-v3/{postcss.config.mjs => postcss.config.js} (100%) rename rslib/react-tailwindcss/{postcss.config.mjs => postcss.config.js} (100%) rename rspack/basic-ts/{rspack.config.mjs => rspack.config.js} (100%) rename rspack/basic/{rspack.config.mjs => rspack.config.js} (100%) rename rspack/builtin-swc-loader/{rspack.config.mjs => rspack.config.js} (100%) rename rspack/bundle-splitting/{rspack.config.mjs => rspack.config.js} (100%) rename rspack/case-sensitive-paths-webpack-plugin/{rspack.config.mjs => rspack.config.js} (100%) rename rspack/code-splitting/{rspack.config.mjs => rspack.config.js} (100%) rename rspack/cra-ts/{rspack.config.mjs => rspack.config.js} (100%) rename rspack/cra/{rspack.config.mjs => rspack.config.js} (100%) rename rspack/css-chunking-plugin/{rspack.config.mjs => rspack.config.js} (100%) rename rspack/css-parser-generator-options/{rspack.config.mjs => rspack.config.js} (100%) rename rspack/dll-reference/{rspack.config.mjs => rspack.config.js} (100%) rename rspack/dll/{rspack.config.mjs => rspack.config.js} (100%) rename rspack/emotion/{rspack.config.mjs => rspack.config.js} (100%) rename rspack/eslint/{eslint.config.mjs => eslint.config.js} (100%) rename rspack/eslint/{rspack.config.mjs => rspack.config.js} (100%) rename rspack/eslint/{rspack.config.loader.mjs => rspack.config.loader.js} (100%) rename rspack/express/{rspack.config.mjs => rspack.config.js} (93%) rename rspack/extract-license/{rspack.config.mjs => rspack.config.js} (100%) rename rspack/generate-package-json-webpack-plugin/{rspack.config.mjs => rspack.config.js} (100%) rename rspack/hooks-after-resolve/{rspack.config.mjs => rspack.config.js} (100%) rename rspack/html-webpack-plugin/{rspack.config.mjs => rspack.config.js} (100%) rename rspack/http-import/{rspack.config.mjs => rspack.config.js} (100%) rename rspack/inline-const-enum/{rspack.config.mjs => rspack.config.js} (100%) rename rspack/inline-const/{rspack.config.mjs => rspack.config.js} (100%) rename rspack/inline-enum/{rspack.config.mjs => rspack.config.js} (100%) rename rspack/library-cjs/{rspack.config.mjs => rspack.config.js} (92%) rename rspack/library-esm/{rspack.config.mjs => rspack.config.js} (100%) rename rspack/library-umd/{rspack.config.mjs => rspack.config.js} (100%) rename rspack/license-webpack-plugin/{rspack.config.mjs => rspack.config.js} (100%) rename rspack/lightingcss-loader/{rspack.config.mjs => rspack.config.js} (100%) rename rspack/loader-compat/{rspack.config.mjs => rspack.config.js} (98%) rename rspack/minify-test/{rspack.config.mjs => rspack.config.js} (100%) rename rspack/module-federation-v1.5/app/{rspack.config.mjs => rspack.config.js} (100%) rename rspack/module-federation-v1.5/lib1/{rspack.config.mjs => rspack.config.js} (100%) rename rspack/module-federation-v1.5/lib2/{rspack.config.mjs => rspack.config.js} (100%) rename rspack/module-federation-v1/app/{rspack.config.mjs => rspack.config.js} (100%) rename rspack/module-federation-v1/lib1/{rspack.config.mjs => rspack.config.js} (100%) rename rspack/module-federation-v1/lib2/{rspack.config.mjs => rspack.config.js} (100%) rename rspack/monaco-editor-js/{rspack.config.mjs => rspack.config.js} (100%) rename rspack/monaco-editor-ts-react/{rspack.config.mjs => rspack.config.js} (100%) rename rspack/monaco-editor-webpack-plugin/{rspack.config.mjs => rspack.config.js} (100%) rename rspack/multi-entry/{rspack.config.mjs => rspack.config.js} (100%) rename rspack/nest-alias/{rspack.config.mjs => rspack.config.js} (100%) rename rspack/nestjs/{rspack.config.mjs => rspack.config.js} (97%) rename rspack/node-globals-shim/{rspack.config.mjs => rspack.config.js} (100%) rename rspack/node-polyfill/{rspack.config.mjs => rspack.config.js} (100%) rename rspack/perfsee/{rspack.config.mjs => rspack.config.js} (100%) rename rspack/polyfill/{rspack.config.mjs => rspack.config.js} (100%) rename rspack/postcss-loader/{rspack.config.mjs => rspack.config.js} (100%) rename rspack/preact-refresh/{rspack.config.mjs => rspack.config.js} (100%) rename rspack/preact/{rspack.config.mjs => rspack.config.js} (100%) rename rspack/proxy/{rspack.config.mjs => rspack.config.js} (100%) rename rspack/react-compiler-babel-ts/{rspack.config.mjs => rspack.config.js} (100%) rename rspack/react-compiler-babel/{rspack.config.mjs => rspack.config.js} (100%) rename rspack/react-refresh-babel-loader/{rspack.config.mjs => rspack.config.js} (100%) rename rspack/react-refresh-esm/{rspack.config.mjs => rspack.config.js} (100%) rename rspack/react-refresh/{rspack.config.mjs => rspack.config.js} (100%) rename rspack/react-with-extract-css/{rspack.config.mjs => rspack.config.js} (100%) rename rspack/react-with-less/{rspack.config.mjs => rspack.config.js} (100%) rename rspack/react-with-sass/{rspack.config.mjs => rspack.config.js} (100%) rename rspack/react/{rspack.config.mjs => rspack.config.js} (100%) rename rspack/rspack-manifest-plugin/{rspack.config.mjs => rspack.config.js} (100%) rename rspack/sentry/{rspack.config.mjs => rspack.config.js} (100%) rename rspack/solid/{rspack.config.mjs => rspack.config.js} (100%) rename rspack/source-map-with-vscode-debugging/{rspack.config.mjs => rspack.config.js} (100%) rename rspack/stats/{rspack.config.mjs => rspack.config.js} (100%) rename rspack/styled-components/{rspack.config.mjs => rspack.config.js} (100%) rename rspack/svgr/{rspack.config.mjs => rspack.config.js} (100%) rename rspack/terser-webpack-plugin/{rspack.config.mjs => rspack.config.js} (100%) rename rspack/treeshaking-transform-imports/{rspack.config.mjs => rspack.config.js} (100%) rename rspack/ts-checker-rspack-plugin/{rspack.config.mjs => rspack.config.js} (100%) rename rspack/type-reexports-presence/{rspack.config.mjs => rspack.config.js} (100%) rename rspack/vanilla-extract-css/{rspack.config.mjs => rspack.config.js} (100%) rename rspack/vue-jsx/{rspack.config.mjs => rspack.config.js} (100%) rename rspack/vue-tsx/{rspack.config.mjs => rspack.config.js} (100%) rename rspack/vue-vanilla/{rspack.config.mjs => rspack.config.js} (100%) rename rspack/vue/{rspack.config.mjs => rspack.config.js} (100%) rename rspack/wasm-simple/{rspack.config.mjs => rspack.config.js} (100%) rename rspack/webpack-bundle-analyzer/{rspack.config.mjs => rspack.config.js} (100%) rename rspack/webpack-stats-plugin/{rspack.config.mjs => rspack.config.js} (100%) rename rspack/worker-inline/{rspack.config.mjs => rspack.config.js} (100%) rename rspack/worker/{rspack.config.mjs => rspack.config.js} (100%) rename rspack/worklet/{rspack.config.mjs => rspack.config.js} (100%) rename rstest/rspack-adapter/{rstest.config.mts => rstest.config.ts} (100%) diff --git a/package.json b/package.json index 543ee39d6..9122f526c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,7 @@ { "name": "rstack-examples", "version": "1.0.0", + "type": "module", "description": "Repository for examples of rstack", "license": "MIT", "scripts": { diff --git a/rsbuild/express/package.json b/rsbuild/express/package.json index b0cf16eb2..ac39cd9d3 100644 --- a/rsbuild/express/package.json +++ b/rsbuild/express/package.json @@ -5,7 +5,7 @@ "type": "module", "scripts": { "build": "rsbuild build", - "dev": "node ./server.mjs", + "dev": "node ./server.js", "preview": "rsbuild preview" }, "devDependencies": { diff --git a/rsbuild/express/rsbuild.config.mjs b/rsbuild/express/rsbuild.config.js similarity index 100% rename from rsbuild/express/rsbuild.config.mjs rename to rsbuild/express/rsbuild.config.js diff --git a/rsbuild/express/server.mjs b/rsbuild/express/server.js similarity index 100% rename from rsbuild/express/server.mjs rename to rsbuild/express/server.js diff --git a/rsbuild/fastify/package.json b/rsbuild/fastify/package.json index adafd7be8..8b98b3a12 100644 --- a/rsbuild/fastify/package.json +++ b/rsbuild/fastify/package.json @@ -5,7 +5,7 @@ "type": "module", "scripts": { "build": "rsbuild build", - "dev": "node ./server.mjs", + "dev": "node ./server.js", "preview": "rsbuild preview" }, "devDependencies": { diff --git a/rsbuild/fastify/rsbuild.config.mjs b/rsbuild/fastify/rsbuild.config.js similarity index 100% rename from rsbuild/fastify/rsbuild.config.mjs rename to rsbuild/fastify/rsbuild.config.js diff --git a/rsbuild/fastify/server.mjs b/rsbuild/fastify/server.js similarity index 100% rename from rsbuild/fastify/server.mjs rename to rsbuild/fastify/server.js diff --git a/rsbuild/ssr-express-with-manifest/package.json b/rsbuild/ssr-express-with-manifest/package.json index 129969cc0..318c59699 100644 --- a/rsbuild/ssr-express-with-manifest/package.json +++ b/rsbuild/ssr-express-with-manifest/package.json @@ -5,8 +5,8 @@ "type": "module", "scripts": { "build": "rsbuild build", - "dev": "cross-env NODE_OPTIONS=\"--experimental-vm-modules --no-warnings\" node ./server.mjs", - "preview": "node ./prod-server.mjs" + "dev": "cross-env NODE_OPTIONS=\"--experimental-vm-modules --no-warnings\" node ./server.js", + "preview": "node ./prod-server.js" }, "dependencies": { "react": "^19.2.7", diff --git a/rsbuild/ssr-express-with-manifest/prod-server.mjs b/rsbuild/ssr-express-with-manifest/prod-server.js similarity index 100% rename from rsbuild/ssr-express-with-manifest/prod-server.mjs rename to rsbuild/ssr-express-with-manifest/prod-server.js diff --git a/rsbuild/ssr-express-with-manifest/rsbuild.config.mjs b/rsbuild/ssr-express-with-manifest/rsbuild.config.js similarity index 100% rename from rsbuild/ssr-express-with-manifest/rsbuild.config.mjs rename to rsbuild/ssr-express-with-manifest/rsbuild.config.js diff --git a/rsbuild/ssr-express-with-manifest/server.mjs b/rsbuild/ssr-express-with-manifest/server.js similarity index 100% rename from rsbuild/ssr-express-with-manifest/server.mjs rename to rsbuild/ssr-express-with-manifest/server.js diff --git a/rsbuild/ssr-express/package.json b/rsbuild/ssr-express/package.json index 57d112568..fe6dde099 100644 --- a/rsbuild/ssr-express/package.json +++ b/rsbuild/ssr-express/package.json @@ -5,8 +5,8 @@ "type": "module", "scripts": { "build": "rsbuild build", - "dev": "cross-env NODE_OPTIONS=\"--experimental-vm-modules --no-warnings\" node ./server.mjs", - "preview": "node ./prod-server.mjs" + "dev": "cross-env NODE_OPTIONS=\"--experimental-vm-modules --no-warnings\" node ./server.js", + "preview": "node ./prod-server.js" }, "dependencies": { "react": "^19.2.7", diff --git a/rsbuild/ssr-express/prod-server.mjs b/rsbuild/ssr-express/prod-server.js similarity index 100% rename from rsbuild/ssr-express/prod-server.mjs rename to rsbuild/ssr-express/prod-server.js diff --git a/rsbuild/ssr-express/rsbuild.config.mjs b/rsbuild/ssr-express/rsbuild.config.js similarity index 100% rename from rsbuild/ssr-express/rsbuild.config.mjs rename to rsbuild/ssr-express/rsbuild.config.js diff --git a/rsbuild/ssr-express/server.mjs b/rsbuild/ssr-express/server.js similarity index 100% rename from rsbuild/ssr-express/server.mjs rename to rsbuild/ssr-express/server.js diff --git a/rsdoctor/rspack/package.json b/rsdoctor/rspack/package.json index f61ae5780..8269978db 100644 --- a/rsdoctor/rspack/package.json +++ b/rsdoctor/rspack/package.json @@ -2,6 +2,7 @@ "name": "@rsdoctor-example/rspack", "version": "0.1.1", "private": true, + "type": "module", "scripts": { "build": "NODE_ENV=production rspack build", "build:analysis": "RSDOCTOR=true NODE_ENV=production rspack build", diff --git a/rsdoctor/rspack/rspack.config.mjs b/rsdoctor/rspack/rspack.config.js similarity index 100% rename from rsdoctor/rspack/rspack.config.mjs rename to rsdoctor/rspack/rspack.config.js diff --git a/rslib/module-federation/package.json b/rslib/module-federation/package.json index 25e211b7b..68172aec5 100644 --- a/rslib/module-federation/package.json +++ b/rslib/module-federation/package.json @@ -1,6 +1,7 @@ { "name": "@rslib-example/module-federation", "private": true, + "type": "module", "scripts": { "build:lib": "pnpm --filter rslib-mf-react-component run build", "dev:all:host": "pnpm dev:host & pnpm dev:mf & pnpm dev:remote", diff --git a/rslib/react-tailwindcss-v3/postcss.config.mjs b/rslib/react-tailwindcss-v3/postcss.config.js similarity index 100% rename from rslib/react-tailwindcss-v3/postcss.config.mjs rename to rslib/react-tailwindcss-v3/postcss.config.js diff --git a/rslib/react-tailwindcss/postcss.config.mjs b/rslib/react-tailwindcss/postcss.config.js similarity index 100% rename from rslib/react-tailwindcss/postcss.config.mjs rename to rslib/react-tailwindcss/postcss.config.js diff --git a/rspack/basic-ts/package.json b/rspack/basic-ts/package.json index 5f853bde3..b6b062e1d 100644 --- a/rspack/basic-ts/package.json +++ b/rspack/basic-ts/package.json @@ -2,6 +2,7 @@ "name": "@rspack-example/basic-ts", "version": "1.0.0", "private": true, + "type": "module", "license": "MIT", "scripts": { "build": "rspack build", diff --git a/rspack/basic-ts/rspack.config.mjs b/rspack/basic-ts/rspack.config.js similarity index 100% rename from rspack/basic-ts/rspack.config.mjs rename to rspack/basic-ts/rspack.config.js diff --git a/rspack/basic/package.json b/rspack/basic/package.json index 56a66a215..5d6a90cc2 100644 --- a/rspack/basic/package.json +++ b/rspack/basic/package.json @@ -2,6 +2,7 @@ "name": "@rspack-example/basic", "version": "1.0.0", "private": true, + "type": "module", "license": "MIT", "scripts": { "build": "rspack build", diff --git a/rspack/basic/rspack.config.mjs b/rspack/basic/rspack.config.js similarity index 100% rename from rspack/basic/rspack.config.mjs rename to rspack/basic/rspack.config.js diff --git a/rspack/basic/src/index.js b/rspack/basic/src/index.js index cfbdbfb89..6cde9f2b5 100644 --- a/rspack/basic/src/index.js +++ b/rspack/basic/src/index.js @@ -1,4 +1,4 @@ -import { answer } from './answer'; +import { answer } from './answer.js'; function render() { document.getElementById('root').innerHTML = `the answer to the universe is ${answer}`; } diff --git a/rspack/builtin-swc-loader/package.json b/rspack/builtin-swc-loader/package.json index 782bfdf7f..cc2e70737 100644 --- a/rspack/builtin-swc-loader/package.json +++ b/rspack/builtin-swc-loader/package.json @@ -2,6 +2,7 @@ "name": "@rspack-example/builtin-swc-loader", "version": "1.0.0", "private": true, + "type": "module", "license": "MIT", "scripts": { "build": "rspack build", diff --git a/rspack/builtin-swc-loader/rspack.config.mjs b/rspack/builtin-swc-loader/rspack.config.js similarity index 100% rename from rspack/builtin-swc-loader/rspack.config.mjs rename to rspack/builtin-swc-loader/rspack.config.js diff --git a/rspack/builtin-swc-loader/src/index.jsx b/rspack/builtin-swc-loader/src/index.jsx index d1fdc49b6..d9a4c3cc1 100644 --- a/rspack/builtin-swc-loader/src/index.jsx +++ b/rspack/builtin-swc-loader/src/index.jsx @@ -1,7 +1,7 @@ import React from 'react'; import ReactDOM from 'react-dom/client'; import './index.css'; -import App from './App'; +import App from './App.jsx'; import { answer } from 'lib3'; graphql` fragment Foo on Bar { diff --git a/rspack/bundle-splitting/index.js b/rspack/bundle-splitting/index.js index d71b971cb..55ade7fc8 100644 --- a/rspack/bundle-splitting/index.js +++ b/rspack/bundle-splitting/index.js @@ -1,4 +1,4 @@ -import { common } from './common'; -import { inline } from './inline'; -import { manual } from './manual'; +import { common } from './common.js'; +import { inline } from './inline.js'; +import { manual } from './manual.js'; console.log('all:', manual, inline, common); diff --git a/rspack/bundle-splitting/package.json b/rspack/bundle-splitting/package.json index 6152ecfbc..4559d591f 100644 --- a/rspack/bundle-splitting/package.json +++ b/rspack/bundle-splitting/package.json @@ -2,6 +2,7 @@ "name": "@rspack-example/bundle-splitting", "version": "1.0.0", "private": true, + "type": "module", "license": "MIT", "scripts": { "build": "rspack build", diff --git a/rspack/bundle-splitting/rspack.config.mjs b/rspack/bundle-splitting/rspack.config.js similarity index 100% rename from rspack/bundle-splitting/rspack.config.mjs rename to rspack/bundle-splitting/rspack.config.js diff --git a/rspack/case-sensitive-paths-webpack-plugin/package.json b/rspack/case-sensitive-paths-webpack-plugin/package.json index e4d83ca89..2cc28664f 100644 --- a/rspack/case-sensitive-paths-webpack-plugin/package.json +++ b/rspack/case-sensitive-paths-webpack-plugin/package.json @@ -1,6 +1,7 @@ { "name": "@rspack-example/case-sensitive-paths-webpack-plugin", "private": true, + "type": "module", "scripts": { "build": "rspack build || echo 'make-ci-happy'", "dev": "rspack dev" diff --git a/rspack/case-sensitive-paths-webpack-plugin/rspack.config.mjs b/rspack/case-sensitive-paths-webpack-plugin/rspack.config.js similarity index 100% rename from rspack/case-sensitive-paths-webpack-plugin/rspack.config.mjs rename to rspack/case-sensitive-paths-webpack-plugin/rspack.config.js diff --git a/rspack/case-sensitive-paths-webpack-plugin/src/index.js b/rspack/case-sensitive-paths-webpack-plugin/src/index.js index 056f1781f..619ba471b 100644 --- a/rspack/case-sensitive-paths-webpack-plugin/src/index.js +++ b/rspack/case-sensitive-paths-webpack-plugin/src/index.js @@ -1,2 +1,2 @@ -import { answer } from './Answer'; +import { answer } from './Answer.js'; console.log('answer', answer); diff --git a/rspack/code-splitting/index.js b/rspack/code-splitting/index.js index b3366333c..d5df5b0c1 100644 --- a/rspack/code-splitting/index.js +++ b/rspack/code-splitting/index.js @@ -1,7 +1,7 @@ -import { something } from './static'; +import { something } from './static.js'; const a = 10; async function render() { - const { answer } = await import('./answer'); + const { answer } = await import('./answer.js'); console.log('a:', a); console.log('answer:', answer); console.log('static:', something); diff --git a/rspack/code-splitting/package.json b/rspack/code-splitting/package.json index a31b21e47..cf4100d2c 100644 --- a/rspack/code-splitting/package.json +++ b/rspack/code-splitting/package.json @@ -2,6 +2,7 @@ "name": "@rspack-example/code-splitting", "version": "1.0.0", "private": true, + "type": "module", "license": "MIT", "scripts": { "build": "rspack build", diff --git a/rspack/code-splitting/rspack.config.mjs b/rspack/code-splitting/rspack.config.js similarity index 100% rename from rspack/code-splitting/rspack.config.mjs rename to rspack/code-splitting/rspack.config.js diff --git a/rspack/common-libs/lib1/package.json b/rspack/common-libs/lib1/package.json index 72978dfe7..bd5e44465 100644 --- a/rspack/common-libs/lib1/package.json +++ b/rspack/common-libs/lib1/package.json @@ -1,6 +1,7 @@ { "name": "lib1", "version": "1.0.0", + "type": "module", "main": "dist/index.js", "source": "src/index.ts", "scripts": { diff --git a/rspack/common-libs/lib1/src/index.ts b/rspack/common-libs/lib1/src/index.ts index 6d24bce71..ebc02e4e3 100644 --- a/rspack/common-libs/lib1/src/index.ts +++ b/rspack/common-libs/lib1/src/index.ts @@ -1,5 +1,5 @@ -import { tab } from '@components/tab'; +import { tab } from '@components/tab.js'; console.log('button', tab); -export * from '@components/tab'; +export * from '@components/tab.js'; diff --git a/rspack/common-libs/lib1/tsconfig.json b/rspack/common-libs/lib1/tsconfig.json index d7a0a23f5..51e5e88a2 100644 --- a/rspack/common-libs/lib1/tsconfig.json +++ b/rspack/common-libs/lib1/tsconfig.json @@ -4,7 +4,7 @@ "outDir": "dist", "rootDir": "src", "paths": { - "@components/*": ["./src/components/*"] + "@components/*.js": ["./src/components/*.ts"] } }, "include": ["src"] diff --git a/rspack/common-libs/lib2/package.json b/rspack/common-libs/lib2/package.json index ebd682126..ff5774987 100644 --- a/rspack/common-libs/lib2/package.json +++ b/rspack/common-libs/lib2/package.json @@ -1,6 +1,7 @@ { "name": "lib2", "version": "1.0.0", + "type": "module", "main": "dist/index.js", "source": "src/index.ts", "scripts": { diff --git a/rspack/common-libs/lib2/src/index.ts b/rspack/common-libs/lib2/src/index.ts index 10820dd55..fe5039a55 100644 --- a/rspack/common-libs/lib2/src/index.ts +++ b/rspack/common-libs/lib2/src/index.ts @@ -1,5 +1,5 @@ -import { button } from '@components/button'; +import { button } from '@components/button.js'; console.log('button', button); -export * from '@components/button'; +export * from '@components/button.js'; diff --git a/rspack/common-libs/lib2/tsconfig.json b/rspack/common-libs/lib2/tsconfig.json index d7a0a23f5..51e5e88a2 100644 --- a/rspack/common-libs/lib2/tsconfig.json +++ b/rspack/common-libs/lib2/tsconfig.json @@ -4,7 +4,7 @@ "outDir": "dist", "rootDir": "src", "paths": { - "@components/*": ["./src/components/*"] + "@components/*.js": ["./src/components/*.ts"] } }, "include": ["src"] diff --git a/rspack/common-libs/lib3/package.json b/rspack/common-libs/lib3/package.json index 92b29f00c..193eb2360 100644 --- a/rspack/common-libs/lib3/package.json +++ b/rspack/common-libs/lib3/package.json @@ -1,6 +1,7 @@ { "name": "lib3", "version": "1.0.0", + "type": "module", "main": "src/index.js", "license": "MIT" } diff --git a/rspack/cra-ts/package.json b/rspack/cra-ts/package.json index a42ef1740..2c87597a2 100644 --- a/rspack/cra-ts/package.json +++ b/rspack/cra-ts/package.json @@ -2,6 +2,7 @@ "name": "@rspack-example/cra-app-ts", "version": "0.1.1", "private": true, + "type": "module", "scripts": { "build": "rspack build", "dev": "rspack dev" diff --git a/rspack/cra-ts/rspack.config.mjs b/rspack/cra-ts/rspack.config.js similarity index 100% rename from rspack/cra-ts/rspack.config.mjs rename to rspack/cra-ts/rspack.config.js diff --git a/rspack/cra/package.json b/rspack/cra/package.json index 007cc6f24..80b749a0d 100644 --- a/rspack/cra/package.json +++ b/rspack/cra/package.json @@ -2,6 +2,7 @@ "name": "@rspack-example/cra-app", "version": "0.1.0", "private": true, + "type": "module", "scripts": { "build": "rspack build", "dev": "rspack dev" diff --git a/rspack/cra/rspack.config.mjs b/rspack/cra/rspack.config.js similarity index 100% rename from rspack/cra/rspack.config.mjs rename to rspack/cra/rspack.config.js diff --git a/rspack/cra/src/App.test.js b/rspack/cra/src/App.test.js index 1f03afeec..a466f5293 100644 --- a/rspack/cra/src/App.test.js +++ b/rspack/cra/src/App.test.js @@ -1,5 +1,5 @@ import { render, screen } from '@testing-library/react'; -import App from './App'; +import App from './App.jsx'; test('renders learn react link', () => { render(); diff --git a/rspack/cra/src/index.jsx b/rspack/cra/src/index.jsx index 9168dc413..de476c1cf 100644 --- a/rspack/cra/src/index.jsx +++ b/rspack/cra/src/index.jsx @@ -1,8 +1,8 @@ import React from 'react'; import ReactDOM from 'react-dom/client'; import './index.css'; -import App from './App'; -import reportWebVitals from './reportWebVitals'; +import App from './App.jsx'; +import reportWebVitals from './reportWebVitals.js'; const root = ReactDOM.createRoot(document.getElementById('root')); root.render( diff --git a/rspack/css-chunking-plugin/package.json b/rspack/css-chunking-plugin/package.json index 2c4e7b5f5..eda152ec7 100644 --- a/rspack/css-chunking-plugin/package.json +++ b/rspack/css-chunking-plugin/package.json @@ -2,6 +2,7 @@ "name": "@rspack-example/css-chunking-plugin", "version": "1.0.0", "private": true, + "type": "module", "license": "MIT", "scripts": { "build": "rspack build", diff --git a/rspack/css-chunking-plugin/rspack.config.mjs b/rspack/css-chunking-plugin/rspack.config.js similarity index 100% rename from rspack/css-chunking-plugin/rspack.config.mjs rename to rspack/css-chunking-plugin/rspack.config.js diff --git a/rspack/css-chunking-plugin/src/index.js b/rspack/css-chunking-plugin/src/index.js index 9ed7facad..1b1b9da11 100644 --- a/rspack/css-chunking-plugin/src/index.js +++ b/rspack/css-chunking-plugin/src/index.js @@ -1 +1 @@ -import('./page'); +import('./page.js'); diff --git a/rspack/css-parser-generator-options/package.json b/rspack/css-parser-generator-options/package.json index f849fd294..a67a4fdec 100644 --- a/rspack/css-parser-generator-options/package.json +++ b/rspack/css-parser-generator-options/package.json @@ -2,6 +2,7 @@ "name": "@rspack-example/css-parser-generator-options", "version": "1.0.0", "private": true, + "type": "module", "license": "MIT", "scripts": { "build": "rspack build", diff --git a/rspack/css-parser-generator-options/rspack.config.mjs b/rspack/css-parser-generator-options/rspack.config.js similarity index 100% rename from rspack/css-parser-generator-options/rspack.config.mjs rename to rspack/css-parser-generator-options/rspack.config.js diff --git a/rspack/dll-reference/index.js b/rspack/dll-reference/index.js index 7b4f638e8..bd0600e75 100644 --- a/rspack/dll-reference/index.js +++ b/rspack/dll-reference/index.js @@ -1,5 +1,5 @@ -import a from '../dll/a'; -import alpha from '../dll/alpha'; +import a from '../dll/a.ts'; +import alpha from '../dll/alpha.ts'; import beta from 'beta/beta'; import b from 'beta/b'; import c from 'beta/c'; diff --git a/rspack/dll-reference/package.json b/rspack/dll-reference/package.json index 1348f9308..772322cee 100644 --- a/rspack/dll-reference/package.json +++ b/rspack/dll-reference/package.json @@ -1,6 +1,7 @@ { "name": "@rspack-example/dll-reference-plugin", "private": true, + "type": "module", "scripts": { "build": "rspack build || echo 'make-ci-happy'", "dev": "rspack dev" diff --git a/rspack/dll-reference/rspack.config.mjs b/rspack/dll-reference/rspack.config.js similarity index 100% rename from rspack/dll-reference/rspack.config.mjs rename to rspack/dll-reference/rspack.config.js diff --git a/rspack/dll/package.json b/rspack/dll/package.json index 6c9f11864..4bcf4989d 100644 --- a/rspack/dll/package.json +++ b/rspack/dll/package.json @@ -1,6 +1,7 @@ { "name": "@rspack-example/dll-plugin", "private": true, + "type": "module", "scripts": { "build": "rspack build || echo 'make-ci-happy'", "dev": "rspack dev" diff --git a/rspack/dll/rspack.config.mjs b/rspack/dll/rspack.config.js similarity index 100% rename from rspack/dll/rspack.config.mjs rename to rspack/dll/rspack.config.js diff --git a/rspack/emotion/package.json b/rspack/emotion/package.json index 1f4cc6f7c..424c2325a 100644 --- a/rspack/emotion/package.json +++ b/rspack/emotion/package.json @@ -2,6 +2,7 @@ "name": "@rspack-example/emotion", "version": "1.0.0", "private": true, + "type": "module", "license": "MIT", "scripts": { "build": "rspack build", diff --git a/rspack/emotion/rspack.config.mjs b/rspack/emotion/rspack.config.js similarity index 100% rename from rspack/emotion/rspack.config.mjs rename to rspack/emotion/rspack.config.js diff --git a/rspack/eslint/eslint.config.mjs b/rspack/eslint/eslint.config.js similarity index 100% rename from rspack/eslint/eslint.config.mjs rename to rspack/eslint/eslint.config.js diff --git a/rspack/eslint/package.json b/rspack/eslint/package.json index e1cddb257..4e3e94548 100644 --- a/rspack/eslint/package.json +++ b/rspack/eslint/package.json @@ -2,11 +2,12 @@ "name": "@rspack-example/eslint", "version": "1.0.0", "private": true, + "type": "module", "license": "MIT", "scripts": { "build": "rspack build", "dev": "rspack serve -c", - "dev:loader": "rspack serve -c rspack.config.loader.mjs" + "dev:loader": "rspack serve -c rspack.config.loader.js" }, "devDependencies": { "@rspack/cli": "2.1.4", diff --git a/rspack/eslint/rspack.config.mjs b/rspack/eslint/rspack.config.js similarity index 100% rename from rspack/eslint/rspack.config.mjs rename to rspack/eslint/rspack.config.js diff --git a/rspack/eslint/rspack.config.loader.mjs b/rspack/eslint/rspack.config.loader.js similarity index 100% rename from rspack/eslint/rspack.config.loader.mjs rename to rspack/eslint/rspack.config.loader.js diff --git a/rspack/eslint/src/index.js b/rspack/eslint/src/index.js index cfbdbfb89..6cde9f2b5 100644 --- a/rspack/eslint/src/index.js +++ b/rspack/eslint/src/index.js @@ -1,4 +1,4 @@ -import { answer } from './answer'; +import { answer } from './answer.js'; function render() { document.getElementById('root').innerHTML = `the answer to the universe is ${answer}`; } diff --git a/rspack/express/package.json b/rspack/express/package.json index 89596fba9..f8d51ad79 100644 --- a/rspack/express/package.json +++ b/rspack/express/package.json @@ -2,6 +2,7 @@ "name": "@rspack-example/express", "version": "1.0.0", "private": true, + "type": "module", "license": "MIT", "scripts": { "build": "cross-env BUILD=true rspack build", diff --git a/rspack/express/rspack.config.mjs b/rspack/express/rspack.config.js similarity index 93% rename from rspack/express/rspack.config.mjs rename to rspack/express/rspack.config.js index daabc3ef5..89991aebd 100644 --- a/rspack/express/rspack.config.mjs +++ b/rspack/express/rspack.config.js @@ -8,6 +8,9 @@ export default defineConfig({ entry: { main: ['@rspack/core/hot/poll?100', './src/main.ts'], }, + output: { + filename: '[name].cjs', + }, resolve: { extensions: ['...', '.ts', '.tsx', '.jsx'], }, @@ -39,7 +42,7 @@ export default defineConfig({ plugins: [ !process.env.BUILD && new RunScriptWebpackPlugin({ - name: 'main.js', + name: 'main.cjs', autoRestart: false, }), ], diff --git a/rspack/extract-license/package.json b/rspack/extract-license/package.json index 329e485b1..d76a398d0 100644 --- a/rspack/extract-license/package.json +++ b/rspack/extract-license/package.json @@ -2,6 +2,7 @@ "name": "@rspack-example/extract-license", "version": "1.0.0", "private": true, + "type": "module", "license": "MIT", "scripts": { "build": "rspack build", diff --git a/rspack/extract-license/rspack.config.mjs b/rspack/extract-license/rspack.config.js similarity index 100% rename from rspack/extract-license/rspack.config.mjs rename to rspack/extract-license/rspack.config.js diff --git a/rspack/extract-license/src/index.js b/rspack/extract-license/src/index.js index 066b9bfda..8875b5b4c 100644 --- a/rspack/extract-license/src/index.js +++ b/rspack/extract-license/src/index.js @@ -9,5 +9,6 @@ * Utility functions for the foo package. * @license Apache-2.0 */ -const add = require('lodash').add; +import { add } from 'lodash'; + console.log('result:', add(10, 32)); diff --git a/rspack/generate-package-json-webpack-plugin/package.json b/rspack/generate-package-json-webpack-plugin/package.json index b4d2dc5df..e3a779063 100644 --- a/rspack/generate-package-json-webpack-plugin/package.json +++ b/rspack/generate-package-json-webpack-plugin/package.json @@ -1,6 +1,7 @@ { "name": "@rspack-example/generate-package-json-webpack-plugin", "private": true, + "type": "module", "scripts": { "build": "rspack build" }, diff --git a/rspack/generate-package-json-webpack-plugin/rspack.config.mjs b/rspack/generate-package-json-webpack-plugin/rspack.config.js similarity index 100% rename from rspack/generate-package-json-webpack-plugin/rspack.config.mjs rename to rspack/generate-package-json-webpack-plugin/rspack.config.js diff --git a/rspack/hooks-after-resolve/package.json b/rspack/hooks-after-resolve/package.json index 7d4091c7a..8c4a6157e 100644 --- a/rspack/hooks-after-resolve/package.json +++ b/rspack/hooks-after-resolve/package.json @@ -2,6 +2,7 @@ "name": "@rspack-example/hooks-after-resolve", "version": "1.0.0", "private": true, + "type": "module", "license": "MIT", "scripts": { "build": "rspack build", diff --git a/rspack/hooks-after-resolve/rspack.config.mjs b/rspack/hooks-after-resolve/rspack.config.js similarity index 100% rename from rspack/hooks-after-resolve/rspack.config.mjs rename to rspack/hooks-after-resolve/rspack.config.js diff --git a/rspack/hooks-after-resolve/src/index.js b/rspack/hooks-after-resolve/src/index.js index cc88a2bed..5e53837b9 100644 --- a/rspack/hooks-after-resolve/src/index.js +++ b/rspack/hooks-after-resolve/src/index.js @@ -1,4 +1,4 @@ -import { answer } from './answer'; +import { answer } from './answer.js'; function render() { document.getElementById('root').innerHTML = `the answer to the universe is ${answer}`; diff --git a/rspack/html-webpack-plugin/package.json b/rspack/html-webpack-plugin/package.json index 40cdfd6a1..c679125f7 100644 --- a/rspack/html-webpack-plugin/package.json +++ b/rspack/html-webpack-plugin/package.json @@ -1,6 +1,7 @@ { "name": "@rspack-example/html-webpack-plugin_5", "private": true, + "type": "module", "scripts": { "build": "rspack build", "dev": "rspack dev" diff --git a/rspack/html-webpack-plugin/rspack.config.mjs b/rspack/html-webpack-plugin/rspack.config.js similarity index 100% rename from rspack/html-webpack-plugin/rspack.config.mjs rename to rspack/html-webpack-plugin/rspack.config.js diff --git a/rspack/http-import/package.json b/rspack/http-import/package.json index 49c5b2327..c81b8a15e 100644 --- a/rspack/http-import/package.json +++ b/rspack/http-import/package.json @@ -2,6 +2,7 @@ "name": "@rspack-example/http-import", "version": "1.0.0", "private": true, + "type": "module", "license": "MIT", "scripts": { "build": "rspack build", diff --git a/rspack/http-import/rspack.config.mjs b/rspack/http-import/rspack.config.js similarity index 100% rename from rspack/http-import/rspack.config.mjs rename to rspack/http-import/rspack.config.js diff --git a/rspack/inline-const-enum/package.json b/rspack/inline-const-enum/package.json index 5d2bba024..6ccd618ca 100644 --- a/rspack/inline-const-enum/package.json +++ b/rspack/inline-const-enum/package.json @@ -2,6 +2,7 @@ "name": "@rspack-example/inline-const-enum", "version": "1.0.0", "private": true, + "type": "module", "license": "MIT", "scripts": { "build": "rspack build" diff --git a/rspack/inline-const-enum/rspack.config.mjs b/rspack/inline-const-enum/rspack.config.js similarity index 100% rename from rspack/inline-const-enum/rspack.config.mjs rename to rspack/inline-const-enum/rspack.config.js diff --git a/rspack/inline-const/package.json b/rspack/inline-const/package.json index 5dc2ecdcb..8141ce3e4 100644 --- a/rspack/inline-const/package.json +++ b/rspack/inline-const/package.json @@ -2,6 +2,7 @@ "name": "@rspack-example/inline-const", "version": "1.0.0", "private": true, + "type": "module", "license": "MIT", "scripts": { "build": "rspack build" diff --git a/rspack/inline-const/rspack.config.mjs b/rspack/inline-const/rspack.config.js similarity index 100% rename from rspack/inline-const/rspack.config.mjs rename to rspack/inline-const/rspack.config.js diff --git a/rspack/inline-enum/package.json b/rspack/inline-enum/package.json index 58f8998e6..5a74b6656 100644 --- a/rspack/inline-enum/package.json +++ b/rspack/inline-enum/package.json @@ -2,6 +2,7 @@ "name": "@rspack-example/inline-enum", "version": "1.0.0", "private": true, + "type": "module", "license": "MIT", "scripts": { "build": "rspack build" diff --git a/rspack/inline-enum/rspack.config.mjs b/rspack/inline-enum/rspack.config.js similarity index 100% rename from rspack/inline-enum/rspack.config.mjs rename to rspack/inline-enum/rspack.config.js diff --git a/rspack/javascript-api/package.json b/rspack/javascript-api/package.json index f529cd1f0..2a11a61ef 100644 --- a/rspack/javascript-api/package.json +++ b/rspack/javascript-api/package.json @@ -2,6 +2,7 @@ "name": "@rspack-example/javascript-api", "version": "1.0.0", "private": true, + "type": "module", "license": "MIT", "scripts": { "build": "tsc" diff --git a/rspack/lazy-compilation-server/dev.js b/rspack/lazy-compilation-server/dev.js index a3b3c550b..cacf770cc 100644 --- a/rspack/lazy-compilation-server/dev.js +++ b/rspack/lazy-compilation-server/dev.js @@ -1,9 +1,9 @@ -const { rspack } = require('@rspack/core'); -const { RspackDevServer } = require('@rspack/dev-server'); +import { rspack } from '@rspack/core'; +import { RspackDevServer } from '@rspack/dev-server'; const compiler = rspack({ entry: './src/index.js', - context: __dirname, + context: import.meta.dirname, plugins: [new rspack.HtmlRspackPlugin()], lazyCompilation: { backend: { diff --git a/rspack/lazy-compilation-server/package.json b/rspack/lazy-compilation-server/package.json index 4b9e01af1..b78ec493f 100644 --- a/rspack/lazy-compilation-server/package.json +++ b/rspack/lazy-compilation-server/package.json @@ -1,6 +1,7 @@ { "name": "@rspack-example/use-custom-server-for-lazy-compilation", "private": true, + "type": "module", "scripts": { "dev": "node ./dev.js" }, diff --git a/rspack/lazy-compilation-server/src/index.js b/rspack/lazy-compilation-server/src/index.js index 54eb92adc..c8ceeb29d 100644 --- a/rspack/lazy-compilation-server/src/index.js +++ b/rspack/lazy-compilation-server/src/index.js @@ -1,4 +1,4 @@ -import info from './info'; +import info from './info.js'; const text = document.createElement('text'); @@ -7,7 +7,7 @@ text.textContent = info; document.body.appendChild(text); document.addEventListener('click', () => { - import('./show-msg'); + import('./show-msg.js'); }); module.hot.accept('./info', () => { diff --git a/rspack/library-cjs/package.json b/rspack/library-cjs/package.json index f9fc8f8de..5cb274a94 100644 --- a/rspack/library-cjs/package.json +++ b/rspack/library-cjs/package.json @@ -2,6 +2,7 @@ "name": "@rspack-example/library-cjs", "version": "1.0.0", "private": true, + "type": "module", "license": "MIT", "sideEffects": [ "**/*.css", diff --git a/rspack/library-cjs/rspack.config.mjs b/rspack/library-cjs/rspack.config.js similarity index 92% rename from rspack/library-cjs/rspack.config.mjs rename to rspack/library-cjs/rspack.config.js index 8c67a476e..97d5a1411 100644 --- a/rspack/library-cjs/rspack.config.mjs +++ b/rspack/library-cjs/rspack.config.js @@ -9,6 +9,7 @@ export default defineConfig({ externalsType: 'commonjs', output: { chunkFormat: 'commonjs', + filename: '[name].cjs', library: { type: 'commonjs', }, diff --git a/rspack/library-cjs/src/index.js b/rspack/library-cjs/src/index.js index 3bbd841e7..4cb0a5f97 100644 --- a/rspack/library-cjs/src/index.js +++ b/rspack/library-cjs/src/index.js @@ -1,2 +1,2 @@ -export * from './answer'; -export * from './secret'; +export * from './answer.js'; +export * from './secret.js'; diff --git a/rspack/library-esm/package.json b/rspack/library-esm/package.json index 0a6b5b449..2331290f7 100644 --- a/rspack/library-esm/package.json +++ b/rspack/library-esm/package.json @@ -2,6 +2,7 @@ "name": "@rspack-example/library-esm", "version": "1.0.0", "private": true, + "type": "module", "license": "MIT", "sideEffects": [ "**/*.css", diff --git a/rspack/library-esm/rspack.config.mjs b/rspack/library-esm/rspack.config.js similarity index 100% rename from rspack/library-esm/rspack.config.mjs rename to rspack/library-esm/rspack.config.js diff --git a/rspack/library-esm/src/index.js b/rspack/library-esm/src/index.js index 3bbd841e7..4cb0a5f97 100644 --- a/rspack/library-esm/src/index.js +++ b/rspack/library-esm/src/index.js @@ -1,2 +1,2 @@ -export * from './answer'; -export * from './secret'; +export * from './answer.js'; +export * from './secret.js'; diff --git a/rspack/library-umd/package.json b/rspack/library-umd/package.json index d942dc38a..0532883e8 100644 --- a/rspack/library-umd/package.json +++ b/rspack/library-umd/package.json @@ -2,6 +2,7 @@ "name": "@rspack-example/library-umd", "version": "1.0.0", "private": true, + "type": "module", "license": "MIT", "sideEffects": [ "**/*.css", diff --git a/rspack/library-umd/rspack.config.mjs b/rspack/library-umd/rspack.config.js similarity index 100% rename from rspack/library-umd/rspack.config.mjs rename to rspack/library-umd/rspack.config.js diff --git a/rspack/library-umd/src/index.js b/rspack/library-umd/src/index.js index 3bbd841e7..4cb0a5f97 100644 --- a/rspack/library-umd/src/index.js +++ b/rspack/library-umd/src/index.js @@ -1,2 +1,2 @@ -export * from './answer'; -export * from './secret'; +export * from './answer.js'; +export * from './secret.js'; diff --git a/rspack/license-webpack-plugin/package.json b/rspack/license-webpack-plugin/package.json index a1fb4ba72..13f8c9904 100644 --- a/rspack/license-webpack-plugin/package.json +++ b/rspack/license-webpack-plugin/package.json @@ -1,6 +1,7 @@ { "name": "@rspack-example/license-webpack-plugin_4", "private": true, + "type": "module", "scripts": { "build": "rspack build" }, diff --git a/rspack/license-webpack-plugin/rspack.config.mjs b/rspack/license-webpack-plugin/rspack.config.js similarity index 100% rename from rspack/license-webpack-plugin/rspack.config.mjs rename to rspack/license-webpack-plugin/rspack.config.js diff --git a/rspack/lightingcss-loader/package.json b/rspack/lightingcss-loader/package.json index 822f730b5..b7fc6d988 100644 --- a/rspack/lightingcss-loader/package.json +++ b/rspack/lightingcss-loader/package.json @@ -2,6 +2,7 @@ "name": "@rspack-example/lightningcss-loader", "version": "1.0.0", "private": true, + "type": "module", "license": "MIT", "scripts": { "build": "rspack build", diff --git a/rspack/lightingcss-loader/rspack.config.mjs b/rspack/lightingcss-loader/rspack.config.js similarity index 100% rename from rspack/lightingcss-loader/rspack.config.mjs rename to rspack/lightingcss-loader/rspack.config.js diff --git a/rspack/lightingcss-loader/src/index.js b/rspack/lightingcss-loader/src/index.js index 5b5512bd3..71f6dfda3 100644 --- a/rspack/lightingcss-loader/src/index.js +++ b/rspack/lightingcss-loader/src/index.js @@ -1,5 +1,5 @@ import './index.css'; -import { answer } from './answer'; +import { answer } from './answer.js'; function render() { document.getElementById('root').innerHTML = `
the answer to the universe is ${answer}
`; diff --git a/rspack/loader-compat/package.json b/rspack/loader-compat/package.json index 6d08ac266..1f83a632b 100644 --- a/rspack/loader-compat/package.json +++ b/rspack/loader-compat/package.json @@ -2,6 +2,7 @@ "name": "@rspack-example/loader-compat", "version": "1.0.0", "private": true, + "type": "module", "license": "MIT", "scripts": { "build": "rspack build", diff --git a/rspack/loader-compat/rspack.config.mjs b/rspack/loader-compat/rspack.config.js similarity index 98% rename from rspack/loader-compat/rspack.config.mjs rename to rspack/loader-compat/rspack.config.js index 736d92b31..18675b7a1 100644 --- a/rspack/loader-compat/rspack.config.mjs +++ b/rspack/loader-compat/rspack.config.js @@ -8,6 +8,9 @@ export default defineConfig({ }, target: 'node', externalsType: 'commonjs', + output: { + filename: '[name].cjs', + }, resolve: { extensions: ['...', '.ts', '.tsx', '.jsx'], }, diff --git a/rspack/minify-test/a.js b/rspack/minify-test/a.js index 2e7700bc6..0ed5c3008 100644 --- a/rspack/minify-test/a.js +++ b/rspack/minify-test/a.js @@ -1 +1 @@ -module.exports = 'a'; +export default 'a'; diff --git a/rspack/minify-test/a2.js b/rspack/minify-test/a2.js index cc6026722..c0101ef60 100644 --- a/rspack/minify-test/a2.js +++ b/rspack/minify-test/a2.js @@ -1 +1 @@ -module.exports = 'a2'; +export default 'a2'; diff --git a/rspack/minify-test/b.js b/rspack/minify-test/b.js index 3df3888fc..a68ac2819 100644 --- a/rspack/minify-test/b.js +++ b/rspack/minify-test/b.js @@ -1 +1 @@ -module.exports = 'b'; +export default 'b'; diff --git a/rspack/minify-test/index.js b/rspack/minify-test/index.js index 95996ce72..37689ba46 100644 --- a/rspack/minify-test/index.js +++ b/rspack/minify-test/index.js @@ -1,17 +1,17 @@ -const fs = require('fs'); -const path = require('path'); +import fs from 'node:fs'; +import path from 'node:path'; it('[minify-test]: chunk a should not be minified', () => { - const content = fs.readFileSync(path.resolve(__dirname, 'a.js'), 'utf-8'); + const content = fs.readFileSync(path.resolve(import.meta.dirname, 'a.js'), 'utf-8'); expect(content).toMatch('\n'); }); it('[minify-test]: chunk b should not be minified', () => { - const content = fs.readFileSync(path.resolve(__dirname, 'b.js'), 'utf-8'); + const content = fs.readFileSync(path.resolve(import.meta.dirname, 'b.js'), 'utf-8'); expect(content).toMatch('\n'); }); it('[minify-test]: chunk a2 should be minified', () => { - const content = fs.readFileSync(path.resolve(__dirname, 'a2.js'), 'utf-8'); + const content = fs.readFileSync(path.resolve(import.meta.dirname, 'a2.js'), 'utf-8'); expect(content).not.toMatch('\n'); }); diff --git a/rspack/minify-test/rspack.config.mjs b/rspack/minify-test/rspack.config.js similarity index 100% rename from rspack/minify-test/rspack.config.mjs rename to rspack/minify-test/rspack.config.js diff --git a/rspack/module-federation-v1.5/app/package.json b/rspack/module-federation-v1.5/app/package.json index befd87507..8810f6cc7 100644 --- a/rspack/module-federation-v1.5/app/package.json +++ b/rspack/module-federation-v1.5/app/package.json @@ -2,6 +2,7 @@ "name": "@rspack-example/module-federation-v1.5-app", "version": "1.0.0", "private": true, + "type": "module", "scripts": { "dev": "rspack dev", "build": "cross-env NODE_ENV=production rspack build", diff --git a/rspack/module-federation-v1.5/app/rspack.config.mjs b/rspack/module-federation-v1.5/app/rspack.config.js similarity index 100% rename from rspack/module-federation-v1.5/app/rspack.config.mjs rename to rspack/module-federation-v1.5/app/rspack.config.js diff --git a/rspack/module-federation-v1.5/app/src/bootstrap.js b/rspack/module-federation-v1.5/app/src/bootstrap.js index 8b61f13f5..bff1d1140 100644 --- a/rspack/module-federation-v1.5/app/src/bootstrap.js +++ b/rspack/module-federation-v1.5/app/src/bootstrap.js @@ -1,5 +1,5 @@ import { createRoot } from 'react-dom/client'; // <- this is a shared module, but used as usual -import App from './App'; +import App from './App.js'; // load app const el = document.createElement('main'); diff --git a/rspack/module-federation-v1.5/app/src/index.js b/rspack/module-federation-v1.5/app/src/index.js index 9da4575b7..285e25976 100644 --- a/rspack/module-federation-v1.5/app/src/index.js +++ b/rspack/module-federation-v1.5/app/src/index.js @@ -7,7 +7,7 @@ // This also requires an async boundary (import()) // At this point shared modules initialized and remote modules are loaded -import('./bootstrap'); +import('./bootstrap.js'); // It's possible to place more code here to do stuff on page init // but it can't use any of the shared modules or remote modules. diff --git a/rspack/module-federation-v1.5/lib1/package.json b/rspack/module-federation-v1.5/lib1/package.json index 7051c2ebf..261b144b8 100644 --- a/rspack/module-federation-v1.5/lib1/package.json +++ b/rspack/module-federation-v1.5/lib1/package.json @@ -2,6 +2,7 @@ "name": "@rspack-example/module-federation-v1.5-lib1", "version": "1.0.0", "private": true, + "type": "module", "scripts": { "dev": "rspack dev", "build": "cross-env NODE_ENV=production rspack build", diff --git a/rspack/module-federation-v1.5/lib1/rspack.config.mjs b/rspack/module-federation-v1.5/lib1/rspack.config.js similarity index 100% rename from rspack/module-federation-v1.5/lib1/rspack.config.mjs rename to rspack/module-federation-v1.5/lib1/rspack.config.js diff --git a/rspack/module-federation-v1.5/lib1/src/bootstrap.js b/rspack/module-federation-v1.5/lib1/src/bootstrap.js index 126347f47..e52fe9901 100644 --- a/rspack/module-federation-v1.5/lib1/src/bootstrap.js +++ b/rspack/module-federation-v1.5/lib1/src/bootstrap.js @@ -1,5 +1,5 @@ import { createRoot } from 'react-dom/client'; -import Component from './Component'; +import Component from './Component.js'; import { de } from 'date-fns/locale'; const el = document.createElement('main'); diff --git a/rspack/module-federation-v1.5/lib1/src/index.js b/rspack/module-federation-v1.5/lib1/src/index.js index b93c7a026..d390836af 100644 --- a/rspack/module-federation-v1.5/lib1/src/index.js +++ b/rspack/module-federation-v1.5/lib1/src/index.js @@ -1 +1 @@ -import('./bootstrap'); +import('./bootstrap.js'); diff --git a/rspack/module-federation-v1.5/lib2/package.json b/rspack/module-federation-v1.5/lib2/package.json index 79c9368fc..5694f5735 100644 --- a/rspack/module-federation-v1.5/lib2/package.json +++ b/rspack/module-federation-v1.5/lib2/package.json @@ -2,6 +2,7 @@ "name": "@rspack-example/module-federation-v1.5-lib2", "version": "1.0.0", "private": true, + "type": "module", "scripts": { "dev": "rspack dev", "build": "cross-env NODE_ENV=production rspack build", diff --git a/rspack/module-federation-v1.5/lib2/rspack.config.mjs b/rspack/module-federation-v1.5/lib2/rspack.config.js similarity index 100% rename from rspack/module-federation-v1.5/lib2/rspack.config.mjs rename to rspack/module-federation-v1.5/lib2/rspack.config.js diff --git a/rspack/module-federation-v1.5/package.json b/rspack/module-federation-v1.5/package.json index fe95048e7..a66719ad5 100644 --- a/rspack/module-federation-v1.5/package.json +++ b/rspack/module-federation-v1.5/package.json @@ -2,6 +2,7 @@ "name": "@rspack-example/module-federation-v1.5", "version": "1.0.0", "private": true, + "type": "module", "license": "MIT", "scripts": { "build": "pnpm --filter \"@rspack-example/module-federation-v1.5-*\" build", diff --git a/rspack/module-federation-v1/app/package.json b/rspack/module-federation-v1/app/package.json index 9537c82a4..f3a66915f 100644 --- a/rspack/module-federation-v1/app/package.json +++ b/rspack/module-federation-v1/app/package.json @@ -2,6 +2,7 @@ "name": "@rspack-example/module-federation-v1-app", "version": "1.0.0", "private": true, + "type": "module", "scripts": { "dev": "rspack dev", "build": "cross-env NODE_ENV=production rspack build", diff --git a/rspack/module-federation-v1/app/rspack.config.mjs b/rspack/module-federation-v1/app/rspack.config.js similarity index 100% rename from rspack/module-federation-v1/app/rspack.config.mjs rename to rspack/module-federation-v1/app/rspack.config.js diff --git a/rspack/module-federation-v1/app/src/bootstrap.js b/rspack/module-federation-v1/app/src/bootstrap.js index 8b61f13f5..bff1d1140 100644 --- a/rspack/module-federation-v1/app/src/bootstrap.js +++ b/rspack/module-federation-v1/app/src/bootstrap.js @@ -1,5 +1,5 @@ import { createRoot } from 'react-dom/client'; // <- this is a shared module, but used as usual -import App from './App'; +import App from './App.js'; // load app const el = document.createElement('main'); diff --git a/rspack/module-federation-v1/app/src/index.js b/rspack/module-federation-v1/app/src/index.js index 9da4575b7..285e25976 100644 --- a/rspack/module-federation-v1/app/src/index.js +++ b/rspack/module-federation-v1/app/src/index.js @@ -7,7 +7,7 @@ // This also requires an async boundary (import()) // At this point shared modules initialized and remote modules are loaded -import('./bootstrap'); +import('./bootstrap.js'); // It's possible to place more code here to do stuff on page init // but it can't use any of the shared modules or remote modules. diff --git a/rspack/module-federation-v1/lib1/package.json b/rspack/module-federation-v1/lib1/package.json index f31c0a5c4..98b53e23a 100644 --- a/rspack/module-federation-v1/lib1/package.json +++ b/rspack/module-federation-v1/lib1/package.json @@ -2,6 +2,7 @@ "name": "@rspack-example/module-federation-v1-lib1", "version": "1.0.0", "private": true, + "type": "module", "scripts": { "dev": "rspack dev", "build": "cross-env NODE_ENV=production rspack build", diff --git a/rspack/module-federation-v1/lib1/rspack.config.mjs b/rspack/module-federation-v1/lib1/rspack.config.js similarity index 100% rename from rspack/module-federation-v1/lib1/rspack.config.mjs rename to rspack/module-federation-v1/lib1/rspack.config.js diff --git a/rspack/module-federation-v1/lib1/src/bootstrap.js b/rspack/module-federation-v1/lib1/src/bootstrap.js index 126347f47..e52fe9901 100644 --- a/rspack/module-federation-v1/lib1/src/bootstrap.js +++ b/rspack/module-federation-v1/lib1/src/bootstrap.js @@ -1,5 +1,5 @@ import { createRoot } from 'react-dom/client'; -import Component from './Component'; +import Component from './Component.js'; import { de } from 'date-fns/locale'; const el = document.createElement('main'); diff --git a/rspack/module-federation-v1/lib1/src/index.js b/rspack/module-federation-v1/lib1/src/index.js index b93c7a026..d390836af 100644 --- a/rspack/module-federation-v1/lib1/src/index.js +++ b/rspack/module-federation-v1/lib1/src/index.js @@ -1 +1 @@ -import('./bootstrap'); +import('./bootstrap.js'); diff --git a/rspack/module-federation-v1/lib2/package.json b/rspack/module-federation-v1/lib2/package.json index 9697b7d40..7c1101847 100644 --- a/rspack/module-federation-v1/lib2/package.json +++ b/rspack/module-federation-v1/lib2/package.json @@ -2,6 +2,7 @@ "name": "@rspack-example/module-federation-v1-lib2", "version": "1.0.0", "private": true, + "type": "module", "scripts": { "dev": "rspack dev", "build": "cross-env NODE_ENV=production rspack build", diff --git a/rspack/module-federation-v1/lib2/rspack.config.mjs b/rspack/module-federation-v1/lib2/rspack.config.js similarity index 100% rename from rspack/module-federation-v1/lib2/rspack.config.mjs rename to rspack/module-federation-v1/lib2/rspack.config.js diff --git a/rspack/module-federation-v1/package.json b/rspack/module-federation-v1/package.json index d0072e33e..6c7634303 100644 --- a/rspack/module-federation-v1/package.json +++ b/rspack/module-federation-v1/package.json @@ -2,6 +2,7 @@ "name": "@rspack-example/module-federation-v1", "version": "1.0.0", "private": true, + "type": "module", "license": "MIT", "scripts": { "build": "pnpm --filter \"@rspack-example/module-federation-v1-*\" build", diff --git a/rspack/monaco-editor-js/package.json b/rspack/monaco-editor-js/package.json index 5778c6d95..50ad374d1 100644 --- a/rspack/monaco-editor-js/package.json +++ b/rspack/monaco-editor-js/package.json @@ -2,6 +2,7 @@ "name": "@rspack-example/monaco-editor-js", "version": "1.0.0", "private": true, + "type": "module", "license": "MIT", "scripts": { "build": "rspack build", diff --git a/rspack/monaco-editor-js/rspack.config.mjs b/rspack/monaco-editor-js/rspack.config.js similarity index 100% rename from rspack/monaco-editor-js/rspack.config.mjs rename to rspack/monaco-editor-js/rspack.config.js diff --git a/rspack/monaco-editor-ts-react/package.json b/rspack/monaco-editor-ts-react/package.json index d61825bd1..6890a3aa9 100644 --- a/rspack/monaco-editor-ts-react/package.json +++ b/rspack/monaco-editor-ts-react/package.json @@ -2,6 +2,7 @@ "name": "@rspack-example/monaco-editor-ts-react", "version": "1.0.0", "private": true, + "type": "module", "license": "MIT", "scripts": { "build": "rspack build", diff --git a/rspack/monaco-editor-ts-react/rspack.config.mjs b/rspack/monaco-editor-ts-react/rspack.config.js similarity index 100% rename from rspack/monaco-editor-ts-react/rspack.config.mjs rename to rspack/monaco-editor-ts-react/rspack.config.js diff --git a/rspack/monaco-editor-webpack-plugin/index.js b/rspack/monaco-editor-webpack-plugin/index.js index 04bddc899..1a22f3280 100644 --- a/rspack/monaco-editor-webpack-plugin/index.js +++ b/rspack/monaco-editor-webpack-plugin/index.js @@ -1,4 +1,4 @@ -import * as monaco from 'monaco-editor/esm/vs/editor/editor.api'; +import * as monaco from 'monaco-editor/esm/vs/editor/editor.api.js'; (function () { // create div to avoid needing a HtmlWebpackPlugin template diff --git a/rspack/monaco-editor-webpack-plugin/package.json b/rspack/monaco-editor-webpack-plugin/package.json index 829266169..b0101a6f9 100644 --- a/rspack/monaco-editor-webpack-plugin/package.json +++ b/rspack/monaco-editor-webpack-plugin/package.json @@ -2,6 +2,7 @@ "name": "@rspack-example/monaco-editor-webpack-plugin", "version": "1.0.0", "private": true, + "type": "module", "license": "MIT", "scripts": { "build": "rspack build", diff --git a/rspack/monaco-editor-webpack-plugin/rspack.config.mjs b/rspack/monaco-editor-webpack-plugin/rspack.config.js similarity index 100% rename from rspack/monaco-editor-webpack-plugin/rspack.config.mjs rename to rspack/monaco-editor-webpack-plugin/rspack.config.js diff --git a/rspack/multi-entry/index.js b/rspack/multi-entry/index.js index b767c3291..c877a74c1 100644 --- a/rspack/multi-entry/index.js +++ b/rspack/multi-entry/index.js @@ -1,7 +1,7 @@ -import { something } from './static'; +import { something } from './static.js'; const a = 10; async function render() { - import('./answer').then((x) => { + import('./answer.js').then((x) => { console.log('x:', x); }); console.log('a:', a); diff --git a/rspack/multi-entry/package.json b/rspack/multi-entry/package.json index b65206be5..213aeb991 100644 --- a/rspack/multi-entry/package.json +++ b/rspack/multi-entry/package.json @@ -2,6 +2,7 @@ "name": "@rspack-example/multi-entry", "version": "1.0.0", "private": true, + "type": "module", "license": "MIT", "scripts": { "build": "rspack build", diff --git a/rspack/multi-entry/rspack.config.mjs b/rspack/multi-entry/rspack.config.js similarity index 100% rename from rspack/multi-entry/rspack.config.mjs rename to rspack/multi-entry/rspack.config.js diff --git a/rspack/nest-alias/package.json b/rspack/nest-alias/package.json index 4dbafc67c..3b19605f3 100644 --- a/rspack/nest-alias/package.json +++ b/rspack/nest-alias/package.json @@ -1,6 +1,7 @@ { "name": "@rspack-example/nest-alias", "version": "1.0.0", + "type": "module", "license": "MIT", "scripts": { "build": "pnpm compile && pnpm bundle", diff --git a/rspack/nest-alias/rspack.config.mjs b/rspack/nest-alias/rspack.config.js similarity index 100% rename from rspack/nest-alias/rspack.config.mjs rename to rspack/nest-alias/rspack.config.js diff --git a/rspack/nestjs/package.json b/rspack/nestjs/package.json index a1ef0de4b..a302b0c01 100644 --- a/rspack/nestjs/package.json +++ b/rspack/nestjs/package.json @@ -2,11 +2,12 @@ "name": "@rspack-example/nestjs", "version": "1.0.0", "private": true, + "type": "module", "license": "MIT", "scripts": { "build": "rspack build", "dev": "cross-env NODE_ENV=development rspack --watch --mode development", - "start": "node dist/main.js" + "start": "node dist/main.cjs" }, "dependencies": { "@nestjs/common": "11.1.9", diff --git a/rspack/nestjs/rspack.config.mjs b/rspack/nestjs/rspack.config.js similarity index 97% rename from rspack/nestjs/rspack.config.mjs rename to rspack/nestjs/rspack.config.js index 5d5be3482..de242c33d 100644 --- a/rspack/nestjs/rspack.config.mjs +++ b/rspack/nestjs/rspack.config.js @@ -14,6 +14,7 @@ export default defineConfig({ }, output: { clean: true, + filename: '[name].cjs', }, resolve: { extensions: ['...', '.ts', '.tsx', '.jsx'], @@ -63,7 +64,7 @@ export default defineConfig({ plugins: isDev ? [ new RunScriptWebpackPlugin({ - name: 'main.js', + name: 'main.cjs', autoRestart: false, }), new rspack.HotModuleReplacementPlugin(), diff --git a/rspack/next-rspack-app-router/next.config.js b/rspack/next-rspack-app-router/next.config.js index f93243c6a..9d9f9f4b8 100644 --- a/rspack/next-rspack-app-router/next.config.js +++ b/rspack/next-rspack-app-router/next.config.js @@ -1,8 +1,8 @@ -const withRspack = require('next-rspack'); +import withRspack from 'next-rspack'; /** @type {import('next').NextConfig} */ const nextConfig = { /* config options here */ }; -module.exports = withRspack(nextConfig); +export default withRspack(nextConfig); diff --git a/rspack/next-rspack-app-router/package.json b/rspack/next-rspack-app-router/package.json index 6116c0636..88a669b8c 100644 --- a/rspack/next-rspack-app-router/package.json +++ b/rspack/next-rspack-app-router/package.json @@ -1,6 +1,7 @@ { "name": "@rspack-example/next-rspack-app-router", "private": true, + "type": "module", "scripts": { "build": "next build", "dev": "next", diff --git a/rspack/next-rspack-page-router/next.config.js b/rspack/next-rspack-page-router/next.config.js index f93243c6a..9d9f9f4b8 100644 --- a/rspack/next-rspack-page-router/next.config.js +++ b/rspack/next-rspack-page-router/next.config.js @@ -1,8 +1,8 @@ -const withRspack = require('next-rspack'); +import withRspack from 'next-rspack'; /** @type {import('next').NextConfig} */ const nextConfig = { /* config options here */ }; -module.exports = withRspack(nextConfig); +export default withRspack(nextConfig); diff --git a/rspack/next-rspack-page-router/package.json b/rspack/next-rspack-page-router/package.json index ed4dfb68c..b2ec602c6 100644 --- a/rspack/next-rspack-page-router/package.json +++ b/rspack/next-rspack-page-router/package.json @@ -1,6 +1,7 @@ { "name": "@rspack-example/next-rspack-page-router", "private": true, + "type": "module", "scripts": { "build": "next build", "dev": "next", diff --git a/rspack/node-globals-shim/package.json b/rspack/node-globals-shim/package.json index 341b77090..1368e7564 100644 --- a/rspack/node-globals-shim/package.json +++ b/rspack/node-globals-shim/package.json @@ -2,6 +2,7 @@ "name": "@rspack-example/node-globals-shim", "version": "1.0.0", "private": true, + "type": "module", "license": "MIT", "scripts": { "build": "rspack build", diff --git a/rspack/node-globals-shim/rspack.config.mjs b/rspack/node-globals-shim/rspack.config.js similarity index 100% rename from rspack/node-globals-shim/rspack.config.mjs rename to rspack/node-globals-shim/rspack.config.js diff --git a/rspack/node-globals-shim/src/index.js b/rspack/node-globals-shim/src/index.js index ef5ad7dee..cffe9f468 100644 --- a/rspack/node-globals-shim/src/index.js +++ b/rspack/node-globals-shim/src/index.js @@ -1,5 +1,5 @@ -import './util'; -import { answer } from './answer'; +import './util.js'; +import { answer } from './answer.js'; function render() { document.getElementById('root').innerHTML = `the answer to the universe is ${answer}`; } diff --git a/rspack/node-polyfill/package.json b/rspack/node-polyfill/package.json index 5d6a6fd36..5a0855935 100644 --- a/rspack/node-polyfill/package.json +++ b/rspack/node-polyfill/package.json @@ -2,6 +2,7 @@ "name": "@rspack-example/node-polyfill", "version": "1.0.0", "private": true, + "type": "module", "license": "MIT", "scripts": { "build": "rspack build", diff --git a/rspack/node-polyfill/rspack.config.mjs b/rspack/node-polyfill/rspack.config.js similarity index 100% rename from rspack/node-polyfill/rspack.config.mjs rename to rspack/node-polyfill/rspack.config.js diff --git a/rspack/node-polyfill/src/index.js b/rspack/node-polyfill/src/index.js index 381576d52..551743d75 100644 --- a/rspack/node-polyfill/src/index.js +++ b/rspack/node-polyfill/src/index.js @@ -1,5 +1,6 @@ -const util = require('util'); -const logger = require('./logger'); +import util from 'util'; +import logger from './logger.js'; + console.log('procss:', process.version); console.log('buffer', Buffer.from('abcd')); console.log('util:', util.format('%s:%s', 'foo', 'bar')); diff --git a/rspack/node-polyfill/src/logger.js b/rspack/node-polyfill/src/logger.js index 0f13d0153..eb9eb5dd1 100644 --- a/rspack/node-polyfill/src/logger.js +++ b/rspack/node-polyfill/src/logger.js @@ -1,3 +1,3 @@ -module.exports = function logger(method, ...args) { +export default function logger(method, ...args) { console[method](...args); -}; +} diff --git a/rspack/perfsee/package.json b/rspack/perfsee/package.json index 95ca2c88f..8f95a59e6 100644 --- a/rspack/perfsee/package.json +++ b/rspack/perfsee/package.json @@ -2,6 +2,7 @@ "name": "@rspack-example/perfsee", "version": "1.0.0", "private": true, + "type": "module", "license": "MIT", "scripts": { "analyze": "PERFSEE_AUDIT=true rspack build", diff --git a/rspack/perfsee/rspack.config.mjs b/rspack/perfsee/rspack.config.js similarity index 100% rename from rspack/perfsee/rspack.config.mjs rename to rspack/perfsee/rspack.config.js diff --git a/rspack/perfsee/src/index.js b/rspack/perfsee/src/index.js index cfbdbfb89..6cde9f2b5 100644 --- a/rspack/perfsee/src/index.js +++ b/rspack/perfsee/src/index.js @@ -1,4 +1,4 @@ -import { answer } from './answer'; +import { answer } from './answer.js'; function render() { document.getElementById('root').innerHTML = `the answer to the universe is ${answer}`; } diff --git a/rspack/polyfill/package.json b/rspack/polyfill/package.json index eaa3aa413..15c20ec50 100644 --- a/rspack/polyfill/package.json +++ b/rspack/polyfill/package.json @@ -2,6 +2,7 @@ "name": "@rspack-example/polyfill", "version": "1.0.0", "private": true, + "type": "module", "license": "MIT", "scripts": { "build": "rspack build", diff --git a/rspack/polyfill/rspack.config.mjs b/rspack/polyfill/rspack.config.js similarity index 100% rename from rspack/polyfill/rspack.config.mjs rename to rspack/polyfill/rspack.config.js diff --git a/rspack/polyfill/src/index.js b/rspack/polyfill/src/index.js index cfbdbfb89..6cde9f2b5 100644 --- a/rspack/polyfill/src/index.js +++ b/rspack/polyfill/src/index.js @@ -1,4 +1,4 @@ -import { answer } from './answer'; +import { answer } from './answer.js'; function render() { document.getElementById('root').innerHTML = `the answer to the universe is ${answer}`; } diff --git a/rspack/postcss-loader/package.json b/rspack/postcss-loader/package.json index b7d4683f0..959f45e9c 100644 --- a/rspack/postcss-loader/package.json +++ b/rspack/postcss-loader/package.json @@ -2,6 +2,7 @@ "name": "@rspack-example/postcss-loader", "version": "1.0.0", "private": true, + "type": "module", "license": "MIT", "scripts": { "build": "rspack build", diff --git a/rspack/postcss-loader/rspack.config.mjs b/rspack/postcss-loader/rspack.config.js similarity index 100% rename from rspack/postcss-loader/rspack.config.mjs rename to rspack/postcss-loader/rspack.config.js diff --git a/rspack/preact-refresh/package.json b/rspack/preact-refresh/package.json index 81f3dca4c..75bb44443 100644 --- a/rspack/preact-refresh/package.json +++ b/rspack/preact-refresh/package.json @@ -2,6 +2,7 @@ "name": "@rspack-example/preact-refresh", "version": "1.0.0", "private": true, + "type": "module", "license": "MIT", "scripts": { "build": "rspack build", diff --git a/rspack/preact-refresh/rspack.config.mjs b/rspack/preact-refresh/rspack.config.js similarity index 100% rename from rspack/preact-refresh/rspack.config.mjs rename to rspack/preact-refresh/rspack.config.js diff --git a/rspack/preact-refresh/src/index.jsx b/rspack/preact-refresh/src/index.jsx index 4f7c4b906..f6395651d 100644 --- a/rspack/preact-refresh/src/index.jsx +++ b/rspack/preact-refresh/src/index.jsx @@ -1,7 +1,7 @@ import React from 'react'; import ReactDOM from 'react-dom/client'; import './index.css'; -import App from './App'; +import App from './App.jsx'; const root = ReactDOM.createRoot(document.getElementById('root')); root.render(); diff --git a/rspack/preact/package.json b/rspack/preact/package.json index 63bdae9bd..158945159 100644 --- a/rspack/preact/package.json +++ b/rspack/preact/package.json @@ -2,6 +2,7 @@ "name": "@rspack-example/preact", "version": "1.0.0", "private": true, + "type": "module", "license": "MIT", "scripts": { "build": "rspack build", diff --git a/rspack/preact/rspack.config.mjs b/rspack/preact/rspack.config.js similarity index 100% rename from rspack/preact/rspack.config.mjs rename to rspack/preact/rspack.config.js diff --git a/rspack/preact/src/index.jsx b/rspack/preact/src/index.jsx index 793e2b837..5917c5feb 100644 --- a/rspack/preact/src/index.jsx +++ b/rspack/preact/src/index.jsx @@ -1,7 +1,7 @@ import React from 'react'; import ReactDOM from 'react-dom/client'; import './index.css'; -import App from './App'; +import App from './App.jsx'; const root = ReactDOM.createRoot(document.getElementById('root')); root.render(); diff --git a/rspack/proxy/package.json b/rspack/proxy/package.json index 9c3ca8398..38d7ad48f 100644 --- a/rspack/proxy/package.json +++ b/rspack/proxy/package.json @@ -2,6 +2,7 @@ "name": "@rspack-example/proxy", "version": "1.0.0", "private": true, + "type": "module", "license": "MIT", "scripts": { "build": "rspack build", diff --git a/rspack/proxy/rspack.config.mjs b/rspack/proxy/rspack.config.js similarity index 100% rename from rspack/proxy/rspack.config.mjs rename to rspack/proxy/rspack.config.js diff --git a/rspack/react-compiler-babel-ts/babel.config.js b/rspack/react-compiler-babel-ts/babel.config.js index 3c6e5ebf4..ef9edeb4f 100644 --- a/rspack/react-compiler-babel-ts/babel.config.js +++ b/rspack/react-compiler-babel-ts/babel.config.js @@ -3,7 +3,7 @@ const ReactCompilerConfig = { /* ... */ }; -module.exports = { +export default { plugins: [ ['babel-plugin-react-compiler', ReactCompilerConfig], // must run first! '@babel/plugin-syntax-jsx', diff --git a/rspack/react-compiler-babel-ts/package.json b/rspack/react-compiler-babel-ts/package.json index ddc6a701e..5aa426aac 100644 --- a/rspack/react-compiler-babel-ts/package.json +++ b/rspack/react-compiler-babel-ts/package.json @@ -2,6 +2,7 @@ "name": "@rspack-example/react-compiler-babel-ts", "version": "1.0.0", "private": true, + "type": "module", "license": "MIT", "scripts": { "build": "rspack build", diff --git a/rspack/react-compiler-babel-ts/rspack.config.mjs b/rspack/react-compiler-babel-ts/rspack.config.js similarity index 100% rename from rspack/react-compiler-babel-ts/rspack.config.mjs rename to rspack/react-compiler-babel-ts/rspack.config.js diff --git a/rspack/react-compiler-babel/babel.config.js b/rspack/react-compiler-babel/babel.config.js index 6202686fc..93c24e056 100644 --- a/rspack/react-compiler-babel/babel.config.js +++ b/rspack/react-compiler-babel/babel.config.js @@ -3,7 +3,7 @@ const ReactCompilerConfig = { /* ... */ }; -module.exports = { +export default { plugins: [ ['babel-plugin-react-compiler', ReactCompilerConfig], // must run first! '@babel/plugin-syntax-jsx', diff --git a/rspack/react-compiler-babel/package.json b/rspack/react-compiler-babel/package.json index 273d7a603..31bf60fb0 100644 --- a/rspack/react-compiler-babel/package.json +++ b/rspack/react-compiler-babel/package.json @@ -2,6 +2,7 @@ "name": "@rspack-example/react-compiler-babel", "version": "1.0.0", "private": true, + "type": "module", "license": "MIT", "scripts": { "build": "rspack build", diff --git a/rspack/react-compiler-babel/rspack.config.mjs b/rspack/react-compiler-babel/rspack.config.js similarity index 100% rename from rspack/react-compiler-babel/rspack.config.mjs rename to rspack/react-compiler-babel/rspack.config.js diff --git a/rspack/react-compiler-babel/src/index.jsx b/rspack/react-compiler-babel/src/index.jsx index dac4ede38..87da8bf7f 100644 --- a/rspack/react-compiler-babel/src/index.jsx +++ b/rspack/react-compiler-babel/src/index.jsx @@ -1,7 +1,7 @@ import React from 'react'; import ReactDOM from 'react-dom/client'; import './index.css'; -import App from './App'; +import App from './App.jsx'; const root = ReactDOM.createRoot(document.getElementById('root')); root.render( diff --git a/rspack/react-refresh-babel-loader/package.json b/rspack/react-refresh-babel-loader/package.json index db3eabcf1..3d2563384 100644 --- a/rspack/react-refresh-babel-loader/package.json +++ b/rspack/react-refresh-babel-loader/package.json @@ -2,6 +2,7 @@ "name": "@rspack-example/rspack-react-refresh-with-babel-loader", "version": "1.0.0", "private": true, + "type": "module", "license": "MIT", "scripts": { "build": "cross-env NODE_ENV=production rspack build", diff --git a/rspack/react-refresh-babel-loader/rspack.config.mjs b/rspack/react-refresh-babel-loader/rspack.config.js similarity index 100% rename from rspack/react-refresh-babel-loader/rspack.config.mjs rename to rspack/react-refresh-babel-loader/rspack.config.js diff --git a/rspack/react-refresh-esm/package.json b/rspack/react-refresh-esm/package.json index 9dfa7c5a2..8d277e767 100644 --- a/rspack/react-refresh-esm/package.json +++ b/rspack/react-refresh-esm/package.json @@ -2,6 +2,7 @@ "name": "@rspack-example/rspack-react-refresh-esm", "version": "1.0.0", "private": true, + "type": "module", "license": "MIT", "scripts": { "build": "cross-env NODE_ENV=production rspack build", diff --git a/rspack/react-refresh-esm/rspack.config.mjs b/rspack/react-refresh-esm/rspack.config.js similarity index 100% rename from rspack/react-refresh-esm/rspack.config.mjs rename to rspack/react-refresh-esm/rspack.config.js diff --git a/rspack/react-refresh/package.json b/rspack/react-refresh/package.json index 54ebbe4a2..1f9099cb8 100644 --- a/rspack/react-refresh/package.json +++ b/rspack/react-refresh/package.json @@ -2,6 +2,7 @@ "name": "@rspack-example/rspack-react-refresh", "version": "1.0.0", "private": true, + "type": "module", "license": "MIT", "scripts": { "build": "cross-env NODE_ENV=production rspack build", diff --git a/rspack/react-refresh/rspack.config.mjs b/rspack/react-refresh/rspack.config.js similarity index 100% rename from rspack/react-refresh/rspack.config.mjs rename to rspack/react-refresh/rspack.config.js diff --git a/rspack/react-with-extract-css/package.json b/rspack/react-with-extract-css/package.json index 6fe773a89..b7c8b32b8 100644 --- a/rspack/react-with-extract-css/package.json +++ b/rspack/react-with-extract-css/package.json @@ -2,6 +2,7 @@ "name": "@rspack-example/react-example-css-extract", "version": "1.0.0", "private": true, + "type": "module", "license": "MIT", "scripts": { "build": "rspack build", diff --git a/rspack/react-with-extract-css/rspack.config.mjs b/rspack/react-with-extract-css/rspack.config.js similarity index 100% rename from rspack/react-with-extract-css/rspack.config.mjs rename to rspack/react-with-extract-css/rspack.config.js diff --git a/rspack/react-with-extract-css/src/index.jsx b/rspack/react-with-extract-css/src/index.jsx index b22747728..df3dfb4db 100644 --- a/rspack/react-with-extract-css/src/index.jsx +++ b/rspack/react-with-extract-css/src/index.jsx @@ -1,7 +1,7 @@ import React from 'react'; import ReactDOM from 'react-dom'; import './styles.less'; -import HelloWorld from './components/hello-world'; +import HelloWorld from './components/hello-world.jsx'; function App() { return ( diff --git a/rspack/react-with-less/package.json b/rspack/react-with-less/package.json index 04b8e3c93..35e27c913 100644 --- a/rspack/react-with-less/package.json +++ b/rspack/react-with-less/package.json @@ -2,6 +2,7 @@ "name": "@rspack-example/react-example-less", "version": "1.0.0", "private": true, + "type": "module", "license": "MIT", "scripts": { "build": "rspack build", diff --git a/rspack/react-with-less/rspack.config.mjs b/rspack/react-with-less/rspack.config.js similarity index 100% rename from rspack/react-with-less/rspack.config.mjs rename to rspack/react-with-less/rspack.config.js diff --git a/rspack/react-with-less/src/index.jsx b/rspack/react-with-less/src/index.jsx index b22747728..df3dfb4db 100644 --- a/rspack/react-with-less/src/index.jsx +++ b/rspack/react-with-less/src/index.jsx @@ -1,7 +1,7 @@ import React from 'react'; import ReactDOM from 'react-dom'; import './styles.less'; -import HelloWorld from './components/hello-world'; +import HelloWorld from './components/hello-world.jsx'; function App() { return ( diff --git a/rspack/react-with-sass/package.json b/rspack/react-with-sass/package.json index f8d82bc62..0e7eb1a74 100644 --- a/rspack/react-with-sass/package.json +++ b/rspack/react-with-sass/package.json @@ -2,6 +2,7 @@ "name": "@rspack-example/react-example-sass", "version": "1.0.0", "private": true, + "type": "module", "license": "MIT", "scripts": { "build": "rspack build", diff --git a/rspack/react-with-sass/rspack.config.mjs b/rspack/react-with-sass/rspack.config.js similarity index 100% rename from rspack/react-with-sass/rspack.config.mjs rename to rspack/react-with-sass/rspack.config.js diff --git a/rspack/react-with-sass/src/index.jsx b/rspack/react-with-sass/src/index.jsx index ce9f0b007..4e92ed510 100644 --- a/rspack/react-with-sass/src/index.jsx +++ b/rspack/react-with-sass/src/index.jsx @@ -1,6 +1,6 @@ import ReactDOM from 'react-dom'; import './styles.scss'; -import HelloWorld from './components/hello-world'; +import HelloWorld from './components/hello-world.jsx'; function App() { return ( diff --git a/rspack/react/package.json b/rspack/react/package.json index 89f8b1756..b98627ed4 100644 --- a/rspack/react/package.json +++ b/rspack/react/package.json @@ -2,6 +2,7 @@ "name": "@rspack-example/react", "version": "1.0.0", "private": true, + "type": "module", "license": "MIT", "scripts": { "build": "rspack build", diff --git a/rspack/react/rspack.config.mjs b/rspack/react/rspack.config.js similarity index 100% rename from rspack/react/rspack.config.mjs rename to rspack/react/rspack.config.js diff --git a/rspack/react/src/index.jsx b/rspack/react/src/index.jsx index dac4ede38..87da8bf7f 100644 --- a/rspack/react/src/index.jsx +++ b/rspack/react/src/index.jsx @@ -1,7 +1,7 @@ import React from 'react'; import ReactDOM from 'react-dom/client'; import './index.css'; -import App from './App'; +import App from './App.jsx'; const root = ReactDOM.createRoot(document.getElementById('root')); root.render( diff --git a/rspack/rspack-manifest-plugin/package.json b/rspack/rspack-manifest-plugin/package.json index 87e8e1d18..0c4eb84c1 100644 --- a/rspack/rspack-manifest-plugin/package.json +++ b/rspack/rspack-manifest-plugin/package.json @@ -1,6 +1,7 @@ { "name": "@rspack-example/rspack-manifest-plugin_4", "private": true, + "type": "module", "scripts": { "build": "rspack build", "test": "node ./test.js" diff --git a/rspack/rspack-manifest-plugin/rspack.config.mjs b/rspack/rspack-manifest-plugin/rspack.config.js similarity index 100% rename from rspack/rspack-manifest-plugin/rspack.config.mjs rename to rspack/rspack-manifest-plugin/rspack.config.js diff --git a/rspack/rspack-manifest-plugin/test.js b/rspack/rspack-manifest-plugin/test.js index 1172958e6..ef0588dfc 100644 --- a/rspack/rspack-manifest-plugin/test.js +++ b/rspack/rspack-manifest-plugin/test.js @@ -1,10 +1,10 @@ -const { test } = require('node:test'); -const assert = require('node:assert'); -const fs = require('node:fs'); -const path = require('node:path'); +import assert from 'node:assert'; +import fs from 'node:fs'; +import path from 'node:path'; +import { test } from 'node:test'; test('should have manifest', async (t) => { - const manifest = path.resolve(__dirname, 'dist', 'rspack-manifest.json'); + const manifest = path.resolve(import.meta.dirname, 'dist', 'rspack-manifest.json'); assert(fs.existsSync(manifest)); const manifestJson = JSON.parse(await fs.promises.readFile(manifest, 'utf-8')); assert(manifestJson.files['main.js'] === 'main.js'); diff --git a/rspack/rspack-rsc/rspack.config.js b/rspack/rspack-rsc/rspack.config.js index 67fe75108..307c38b55 100644 --- a/rspack/rspack-rsc/rspack.config.js +++ b/rspack/rspack-rsc/rspack.config.js @@ -121,6 +121,8 @@ export function createRspackConfig({ }, output: { path: path.join(import.meta.dirname, 'dist'), + filename: '[name].js', + chunkFilename: '[id].js', module: true, chunkFormat: 'module', chunkLoading: 'import', diff --git a/rspack/rspack-rsc/server.js b/rspack/rspack-rsc/server.js index 19cbac01d..123d3c923 100644 --- a/rspack/rspack-rsc/server.js +++ b/rspack/rspack-rsc/server.js @@ -72,7 +72,7 @@ app.use(hotMiddleware); function createServerWorker() { return new Promise((resolve, reject) => { - const workerPath = path.join(import.meta.dirname, 'dist/main.mjs'); + const workerPath = path.join(import.meta.dirname, 'dist/main.js'); const worker = new Worker(workerPath, { type: 'module', }); diff --git a/rspack/sentry/package.json b/rspack/sentry/package.json index b83f9fe52..b46fb19ec 100644 --- a/rspack/sentry/package.json +++ b/rspack/sentry/package.json @@ -2,6 +2,7 @@ "name": "@rspack-example/sentry", "version": "1.0.0", "private": true, + "type": "module", "license": "MIT", "scripts": { "build": "rspack build", diff --git a/rspack/sentry/rspack.config.mjs b/rspack/sentry/rspack.config.js similarity index 100% rename from rspack/sentry/rspack.config.mjs rename to rspack/sentry/rspack.config.js diff --git a/rspack/sentry/src/index.js b/rspack/sentry/src/index.js index cfbdbfb89..6cde9f2b5 100644 --- a/rspack/sentry/src/index.js +++ b/rspack/sentry/src/index.js @@ -1,4 +1,4 @@ -import { answer } from './answer'; +import { answer } from './answer.js'; function render() { document.getElementById('root').innerHTML = `the answer to the universe is ${answer}`; } diff --git a/rspack/solid/package.json b/rspack/solid/package.json index 766e87843..92955e558 100644 --- a/rspack/solid/package.json +++ b/rspack/solid/package.json @@ -2,6 +2,7 @@ "name": "@rspack-example/solid", "version": "1.0.0", "private": true, + "type": "module", "license": "MIT", "scripts": { "build": "rspack build", diff --git a/rspack/solid/rspack.config.mjs b/rspack/solid/rspack.config.js similarity index 100% rename from rspack/solid/rspack.config.mjs rename to rspack/solid/rspack.config.js diff --git a/rspack/solid/src/App.jsx b/rspack/solid/src/App.jsx index f79c152f5..9fbc3b84e 100644 --- a/rspack/solid/src/App.jsx +++ b/rspack/solid/src/App.jsx @@ -1,7 +1,7 @@ import logo from './logo.svg'; import styles from './App.module.css'; import { createSignal } from 'solid-js'; -import Message from './Message'; +import Message from './Message.jsx'; function App() { const [count, setCount] = createSignal(1); const increment = () => setCount(count() + 1); diff --git a/rspack/solid/src/index.jsx b/rspack/solid/src/index.jsx index 27c0e53ad..053dbf022 100644 --- a/rspack/solid/src/index.jsx +++ b/rspack/solid/src/index.jsx @@ -2,6 +2,6 @@ import { render } from 'solid-js/web'; import './index.css'; -import App from './App'; +import App from './App.jsx'; render(() => , document.getElementById('root')); diff --git a/rspack/source-map-with-vscode-debugging/package.json b/rspack/source-map-with-vscode-debugging/package.json index e12cf54c9..1245c55f3 100644 --- a/rspack/source-map-with-vscode-debugging/package.json +++ b/rspack/source-map-with-vscode-debugging/package.json @@ -2,6 +2,7 @@ "name": "@rspack-example/source-map-with-vscode-debugging", "version": "1.0.0", "private": true, + "type": "module", "license": "MIT", "scripts": { "build": "rspack build", diff --git a/rspack/source-map-with-vscode-debugging/rspack.config.mjs b/rspack/source-map-with-vscode-debugging/rspack.config.js similarity index 100% rename from rspack/source-map-with-vscode-debugging/rspack.config.mjs rename to rspack/source-map-with-vscode-debugging/rspack.config.js diff --git a/rspack/stats/package.json b/rspack/stats/package.json index 8b633c715..baac7c6e5 100644 --- a/rspack/stats/package.json +++ b/rspack/stats/package.json @@ -2,6 +2,7 @@ "name": "@rspack-example/stats", "version": "1.0.0", "private": true, + "type": "module", "license": "MIT", "scripts": { "build": "rspack build", diff --git a/rspack/stats/rspack.config.mjs b/rspack/stats/rspack.config.js similarity index 100% rename from rspack/stats/rspack.config.mjs rename to rspack/stats/rspack.config.js diff --git a/rspack/stats/src/index.js b/rspack/stats/src/index.js index cfbdbfb89..6cde9f2b5 100644 --- a/rspack/stats/src/index.js +++ b/rspack/stats/src/index.js @@ -1,4 +1,4 @@ -import { answer } from './answer'; +import { answer } from './answer.js'; function render() { document.getElementById('root').innerHTML = `the answer to the universe is ${answer}`; } diff --git a/rspack/styled-components/package.json b/rspack/styled-components/package.json index e8ec5b589..201aef5b0 100644 --- a/rspack/styled-components/package.json +++ b/rspack/styled-components/package.json @@ -2,6 +2,7 @@ "name": "@rspack-example/styled-components", "version": "1.0.0", "private": true, + "type": "module", "license": "MIT", "scripts": { "build": "rspack build", diff --git a/rspack/styled-components/rspack.config.mjs b/rspack/styled-components/rspack.config.js similarity index 100% rename from rspack/styled-components/rspack.config.mjs rename to rspack/styled-components/rspack.config.js diff --git a/rspack/svgr/package.json b/rspack/svgr/package.json index b7a6c3df3..e245fc899 100644 --- a/rspack/svgr/package.json +++ b/rspack/svgr/package.json @@ -2,6 +2,7 @@ "name": "@rspack-example/svgr", "version": "1.0.0", "private": true, + "type": "module", "license": "MIT", "scripts": { "build": "rspack build", diff --git a/rspack/svgr/rspack.config.mjs b/rspack/svgr/rspack.config.js similarity index 100% rename from rspack/svgr/rspack.config.mjs rename to rspack/svgr/rspack.config.js diff --git a/rspack/terser-webpack-plugin/package.json b/rspack/terser-webpack-plugin/package.json index 5e9b44e28..24e9cf58a 100644 --- a/rspack/terser-webpack-plugin/package.json +++ b/rspack/terser-webpack-plugin/package.json @@ -1,6 +1,7 @@ { "name": "@rspack-example/terser-webpack-plugin_5", "private": true, + "type": "module", "scripts": { "build": "rspack build" }, diff --git a/rspack/terser-webpack-plugin/rspack.config.mjs b/rspack/terser-webpack-plugin/rspack.config.js similarity index 100% rename from rspack/terser-webpack-plugin/rspack.config.mjs rename to rspack/terser-webpack-plugin/rspack.config.js diff --git a/rspack/treeshaking-transform-imports/package.json b/rspack/treeshaking-transform-imports/package.json index 5de73156a..c94a0a127 100644 --- a/rspack/treeshaking-transform-imports/package.json +++ b/rspack/treeshaking-transform-imports/package.json @@ -2,6 +2,7 @@ "name": "@rspack-example/treeshaking-transform-imports", "version": "1.0.0", "private": true, + "type": "module", "license": "MIT", "scripts": { "build": "rspack build", diff --git a/rspack/treeshaking-transform-imports/rspack.config.mjs b/rspack/treeshaking-transform-imports/rspack.config.js similarity index 100% rename from rspack/treeshaking-transform-imports/rspack.config.mjs rename to rspack/treeshaking-transform-imports/rspack.config.js diff --git a/rspack/treeshaking-transform-imports/src/a.js b/rspack/treeshaking-transform-imports/src/a.js index 115ff9df1..358dbaeac 100644 --- a/rspack/treeshaking-transform-imports/src/a.js +++ b/rspack/treeshaking-transform-imports/src/a.js @@ -1,2 +1,2 @@ -import { b } from './sdk'; +import { b } from './sdk.js'; export const a = b; diff --git a/rspack/treeshaking-transform-imports/src/index.js b/rspack/treeshaking-transform-imports/src/index.js index 2cfcb9234..999287a1f 100644 --- a/rspack/treeshaking-transform-imports/src/index.js +++ b/rspack/treeshaking-transform-imports/src/index.js @@ -1,2 +1,2 @@ -import { a } from './sdk'; +import { a } from './sdk.js'; console.log(a); diff --git a/rspack/treeshaking-transform-imports/src/sdk.js b/rspack/treeshaking-transform-imports/src/sdk.js index c2357812d..f8a71bd15 100644 --- a/rspack/treeshaking-transform-imports/src/sdk.js +++ b/rspack/treeshaking-transform-imports/src/sdk.js @@ -1,3 +1,3 @@ -export { a } from './a'; -export { b } from './b'; -export { c } from './c'; +export { a } from './a.js'; +export { b } from './b.js'; +export { c } from './c.js'; diff --git a/rspack/ts-checker-rspack-plugin/package.json b/rspack/ts-checker-rspack-plugin/package.json index 9c207cd76..4f42a2809 100644 --- a/rspack/ts-checker-rspack-plugin/package.json +++ b/rspack/ts-checker-rspack-plugin/package.json @@ -1,6 +1,7 @@ { "name": "@rspack-example/ts-checker-rspack-plugin", "private": true, + "type": "module", "scripts": { "build": "rspack build || echo 'make-ci-happy'", "dev": "rspack dev" diff --git a/rspack/ts-checker-rspack-plugin/rspack.config.mjs b/rspack/ts-checker-rspack-plugin/rspack.config.js similarity index 100% rename from rspack/ts-checker-rspack-plugin/rspack.config.mjs rename to rspack/ts-checker-rspack-plugin/rspack.config.js diff --git a/rspack/type-reexports-presence/package.json b/rspack/type-reexports-presence/package.json index 2551816ce..6f3c99a7a 100644 --- a/rspack/type-reexports-presence/package.json +++ b/rspack/type-reexports-presence/package.json @@ -2,6 +2,7 @@ "name": "@rspack-example/type-reexports-presence", "version": "1.0.0", "private": true, + "type": "module", "license": "MIT", "scripts": { "build": "rspack build" diff --git a/rspack/type-reexports-presence/rspack.config.mjs b/rspack/type-reexports-presence/rspack.config.js similarity index 100% rename from rspack/type-reexports-presence/rspack.config.mjs rename to rspack/type-reexports-presence/rspack.config.js diff --git a/rspack/vanilla-extract-css/package.json b/rspack/vanilla-extract-css/package.json index 5757865a2..ad96bda88 100644 --- a/rspack/vanilla-extract-css/package.json +++ b/rspack/vanilla-extract-css/package.json @@ -2,6 +2,7 @@ "name": "@rspack-example/vanilla-extract", "version": "0.0.25", "private": true, + "type": "module", "main": "src/index.ts", "scripts": { "build": "rspack build", diff --git a/rspack/vanilla-extract-css/rspack.config.mjs b/rspack/vanilla-extract-css/rspack.config.js similarity index 100% rename from rspack/vanilla-extract-css/rspack.config.mjs rename to rspack/vanilla-extract-css/rspack.config.js diff --git a/rspack/vue-jsx/package.json b/rspack/vue-jsx/package.json index d55745c90..00f0eef51 100644 --- a/rspack/vue-jsx/package.json +++ b/rspack/vue-jsx/package.json @@ -2,6 +2,7 @@ "name": "@rspack-example/vue-jsx", "version": "1.0.0", "private": true, + "type": "module", "scripts": { "build": "rspack build", "dev": "rspack dev" diff --git a/rspack/vue-jsx/rspack.config.mjs b/rspack/vue-jsx/rspack.config.js similarity index 100% rename from rspack/vue-jsx/rspack.config.mjs rename to rspack/vue-jsx/rspack.config.js diff --git a/rspack/vue-jsx/src/main.jsx b/rspack/vue-jsx/src/main.jsx index 5ae2eef9f..49078b8e5 100644 --- a/rspack/vue-jsx/src/main.jsx +++ b/rspack/vue-jsx/src/main.jsx @@ -1,5 +1,5 @@ import { createApp } from 'vue'; -import App from './App'; +import App from './App.jsx'; import './index.css'; createApp(App).mount('#app'); diff --git a/rspack/vue-tsx/package.json b/rspack/vue-tsx/package.json index c86c3743d..2c1ec49f7 100644 --- a/rspack/vue-tsx/package.json +++ b/rspack/vue-tsx/package.json @@ -2,6 +2,7 @@ "name": "@rspack-example/vue-tsx", "version": "1.0.0", "private": true, + "type": "module", "scripts": { "build": "rspack build", "dev": "rspack dev" diff --git a/rspack/vue-tsx/rspack.config.mjs b/rspack/vue-tsx/rspack.config.js similarity index 100% rename from rspack/vue-tsx/rspack.config.mjs rename to rspack/vue-tsx/rspack.config.js diff --git a/rspack/vue-vanilla/package.json b/rspack/vue-vanilla/package.json index a913bc142..bc902b1c5 100644 --- a/rspack/vue-vanilla/package.json +++ b/rspack/vue-vanilla/package.json @@ -2,6 +2,7 @@ "name": "@rspack-example/vue-vanilla", "version": "1.0.0", "private": true, + "type": "module", "license": "MIT", "scripts": { "build": "rspack build", diff --git a/rspack/vue-vanilla/rspack.config.mjs b/rspack/vue-vanilla/rspack.config.js similarity index 100% rename from rspack/vue-vanilla/rspack.config.mjs rename to rspack/vue-vanilla/rspack.config.js diff --git a/rspack/vue/package.json b/rspack/vue/package.json index e11b23cda..a7a2b77c6 100644 --- a/rspack/vue/package.json +++ b/rspack/vue/package.json @@ -2,6 +2,7 @@ "name": "@rspack-example/vue", "version": "1.0.0", "private": true, + "type": "module", "license": "MIT", "scripts": { "build": "rspack build", diff --git a/rspack/vue/rspack.config.mjs b/rspack/vue/rspack.config.js similarity index 100% rename from rspack/vue/rspack.config.mjs rename to rspack/vue/rspack.config.js diff --git a/rspack/wasm-simple/example.js b/rspack/wasm-simple/example.js index 59bb5d4fa..7ffd41d20 100644 --- a/rspack/wasm-simple/example.js +++ b/rspack/wasm-simple/example.js @@ -5,7 +5,7 @@ import { factorialJavascript, fibonacci, fibonacciJavascript, -} from './math'; +} from './math.js'; console.log(add(22, 2200)); console.log(mathAdd(10, 101)); diff --git a/rspack/wasm-simple/package.json b/rspack/wasm-simple/package.json index 15e5541af..df27c5450 100644 --- a/rspack/wasm-simple/package.json +++ b/rspack/wasm-simple/package.json @@ -2,6 +2,7 @@ "name": "@rspack-example/wasm-complex", "version": "1.0.0", "private": true, + "type": "module", "license": "MIT", "main": "example.js", "scripts": { diff --git a/rspack/wasm-simple/rspack.config.mjs b/rspack/wasm-simple/rspack.config.js similarity index 100% rename from rspack/wasm-simple/rspack.config.mjs rename to rspack/wasm-simple/rspack.config.js diff --git a/rspack/webpack-bundle-analyzer/package.json b/rspack/webpack-bundle-analyzer/package.json index 05e292aeb..11a968db4 100644 --- a/rspack/webpack-bundle-analyzer/package.json +++ b/rspack/webpack-bundle-analyzer/package.json @@ -1,6 +1,7 @@ { "name": "@rspack-example/webpack-bundle-analyzer_4", "private": true, + "type": "module", "scripts": { "build": "rspack build", "dev": "rspack dev" diff --git a/rspack/webpack-bundle-analyzer/rspack.config.mjs b/rspack/webpack-bundle-analyzer/rspack.config.js similarity index 100% rename from rspack/webpack-bundle-analyzer/rspack.config.mjs rename to rspack/webpack-bundle-analyzer/rspack.config.js diff --git a/rspack/webpack-stats-plugin/package.json b/rspack/webpack-stats-plugin/package.json index a579a1ea2..b89054234 100644 --- a/rspack/webpack-stats-plugin/package.json +++ b/rspack/webpack-stats-plugin/package.json @@ -1,6 +1,7 @@ { "name": "@rspack-example/webpack-stats-plugin", "private": true, + "type": "module", "scripts": { "build": "rspack build" }, diff --git a/rspack/webpack-stats-plugin/rspack.config.mjs b/rspack/webpack-stats-plugin/rspack.config.js similarity index 100% rename from rspack/webpack-stats-plugin/rspack.config.mjs rename to rspack/webpack-stats-plugin/rspack.config.js diff --git a/rspack/worker-inline/package.json b/rspack/worker-inline/package.json index 60cd6c151..182e3ffa8 100644 --- a/rspack/worker-inline/package.json +++ b/rspack/worker-inline/package.json @@ -2,6 +2,7 @@ "name": "@rspack-example/worker-inline", "version": "1.0.0", "private": true, + "type": "module", "license": "MIT", "scripts": { "build": "rspack build", diff --git a/rspack/worker-inline/rspack.config.mjs b/rspack/worker-inline/rspack.config.js similarity index 100% rename from rspack/worker-inline/rspack.config.mjs rename to rspack/worker-inline/rspack.config.js diff --git a/rspack/worker/chat-worker.js b/rspack/worker/chat-worker.js index 305437a65..0388e1a94 100644 --- a/rspack/worker/chat-worker.js +++ b/rspack/worker/chat-worker.js @@ -1,4 +1,4 @@ -import { history, add } from './chat-module'; +import { history, add } from './chat-module.js'; onconnect = function (e) { console.log(e); diff --git a/rspack/worker/example.js b/rspack/worker/example.js index a826dcfe1..3fe97a12d 100644 --- a/rspack/worker/example.js +++ b/rspack/worker/example.js @@ -71,7 +71,7 @@ chatWorker.port.onmessage = (event) => { fib1.addEventListener('change', async () => { try { const value = parseInt(fib1.value, 10); - const { fibonacci } = await import('./fibonacci'); + const { fibonacci } = await import('./fibonacci.js'); const result = fibonacci(value); output1.innerText = `fib(${value}) = ${result}`; } catch (e) { diff --git a/rspack/worker/fib-worker.js b/rspack/worker/fib-worker.js index cb5e94615..18b51659e 100644 --- a/rspack/worker/fib-worker.js +++ b/rspack/worker/fib-worker.js @@ -1,5 +1,5 @@ onmessage = async (event) => { - const { fibonacci } = await import('./fibonacci'); + const { fibonacci } = await import('./fibonacci.js'); const value = JSON.parse(event.data); postMessage(`fib(${value}) = ${fibonacci(value)}`); }; diff --git a/rspack/worker/package.json b/rspack/worker/package.json index 0626e17a0..4299981a7 100644 --- a/rspack/worker/package.json +++ b/rspack/worker/package.json @@ -2,6 +2,7 @@ "name": "@rspack-example/worker", "version": "1.0.0", "private": true, + "type": "module", "license": "MIT", "main": "example.js", "scripts": { diff --git a/rspack/worker/rspack.config.mjs b/rspack/worker/rspack.config.js similarity index 100% rename from rspack/worker/rspack.config.mjs rename to rspack/worker/rspack.config.js diff --git a/rspack/worklet/loader/worklet-loader.js b/rspack/worklet/loader/worklet-loader.js index 021e89e58..fcb2aa43e 100644 --- a/rspack/worklet/loader/worklet-loader.js +++ b/rspack/worklet/loader/worklet-loader.js @@ -1,5 +1,6 @@ -const esbuild = require('esbuild'); -module.exports = function workletLoader(source) { +import esbuild from 'esbuild'; + +export default function workletLoader(source) { const result = esbuild.buildSync({ entryPoints: [this.resource], write: false, @@ -7,4 +8,4 @@ module.exports = function workletLoader(source) { }); const content = result.outputFiles[0].text; return content; -}; +} diff --git a/rspack/worklet/package.json b/rspack/worklet/package.json index fa0913c8a..6ac4c6f16 100644 --- a/rspack/worklet/package.json +++ b/rspack/worklet/package.json @@ -2,6 +2,7 @@ "name": "@rspack-example/worklet", "version": "1.0.0", "private": true, + "type": "module", "license": "MIT", "scripts": { "build": "rspack build", diff --git a/rspack/worklet/rspack.config.mjs b/rspack/worklet/rspack.config.js similarity index 100% rename from rspack/worklet/rspack.config.mjs rename to rspack/worklet/rspack.config.js diff --git a/rspack/worklet/src/index.js b/rspack/worklet/src/index.js index c46deeee4..783a5b4b4 100644 --- a/rspack/worklet/src/index.js +++ b/rspack/worklet/src/index.js @@ -1,5 +1,5 @@ -import simpleWorklet from './worklet/simple.worklet?url'; -import complexWorklet from './worklet/complex.worklet'; +import simpleWorklet from './worklet/simple.worklet.js?url'; +import complexWorklet from './worklet/complex.worklet.js'; let context = new AudioContext(); context.audioWorklet.addModule(simpleWorklet).then(() => { diff --git a/rspack/worklet/src/worklet/complex.worklet.js b/rspack/worklet/src/worklet/complex.worklet.js index b450ed174..b7089bdf3 100644 --- a/rspack/worklet/src/worklet/complex.worklet.js +++ b/rspack/worklet/src/worklet/complex.worklet.js @@ -1,4 +1,4 @@ -import { answer } from './answer'; +import { answer } from './answer.ts'; class PortProcessor extends AudioWorkletProcessor { constructor() { super(); diff --git a/rstest/rspack-adapter/rstest.config.mts b/rstest/rspack-adapter/rstest.config.ts similarity index 100% rename from rstest/rspack-adapter/rstest.config.mts rename to rstest/rspack-adapter/rstest.config.ts From cfde6141fa604437a2b9ac7c134162bcd2ebe9cc Mon Sep 17 00:00:00 2001 From: neverland Date: Sun, 19 Jul 2026 20:55:04 +0800 Subject: [PATCH 2/3] chore: disable fully specified resolution in Rspack examples --- rspack/basic/rspack.config.js | 10 ++++++++++ rspack/basic/src/index.js | 2 +- rspack/builtin-swc-loader/rspack.config.js | 6 ++++++ rspack/builtin-swc-loader/src/index.jsx | 2 +- rspack/bundle-splitting/index.js | 6 +++--- rspack/bundle-splitting/rspack.config.js | 8 ++++++++ .../rspack.config.js | 10 ++++++++++ .../case-sensitive-paths-webpack-plugin/src/index.js | 2 +- rspack/code-splitting/index.js | 4 ++-- rspack/code-splitting/rspack.config.js | 10 ++++++++++ rspack/common-libs/lib1/src/index.ts | 4 ++-- rspack/common-libs/lib1/tsconfig.json | 4 +++- rspack/common-libs/lib2/src/index.ts | 4 ++-- rspack/common-libs/lib2/tsconfig.json | 4 +++- rspack/cra/rspack.config.js | 6 ++++++ rspack/cra/src/App.test.js | 2 +- rspack/cra/src/index.jsx | 4 ++-- rspack/css-chunking-plugin/rspack.config.js | 6 ++++++ rspack/css-chunking-plugin/src/index.js | 2 +- rspack/dll-reference/index.js | 4 ++-- rspack/dll-reference/rspack.config.js | 10 ++++++++++ rspack/eslint/rspack.config.js | 10 ++++++++++ rspack/eslint/src/index.js | 2 +- rspack/hooks-after-resolve/rspack.config.js | 10 ++++++++++ rspack/hooks-after-resolve/src/index.js | 2 +- rspack/lazy-compilation-server/dev.js | 10 ++++++++++ rspack/lazy-compilation-server/src/index.js | 4 ++-- rspack/library-cjs/rspack.config.js | 10 ++++++++++ rspack/library-cjs/src/index.js | 4 ++-- rspack/library-esm/rspack.config.js | 8 ++++++++ rspack/library-esm/src/index.js | 4 ++-- rspack/library-umd/rspack.config.js | 10 ++++++++++ rspack/library-umd/src/index.js | 4 ++-- rspack/lightingcss-loader/rspack.config.js | 6 ++++++ rspack/lightingcss-loader/src/index.js | 2 +- rspack/module-federation-v1.5/app/rspack.config.js | 6 ++++++ rspack/module-federation-v1.5/app/src/bootstrap.js | 2 +- rspack/module-federation-v1.5/app/src/index.js | 2 +- rspack/module-federation-v1.5/lib1/rspack.config.js | 6 ++++++ rspack/module-federation-v1.5/lib1/src/bootstrap.js | 2 +- rspack/module-federation-v1.5/lib1/src/index.js | 2 +- rspack/module-federation-v1/app/rspack.config.js | 6 ++++++ rspack/module-federation-v1/app/src/bootstrap.js | 2 +- rspack/module-federation-v1/app/src/index.js | 2 +- rspack/module-federation-v1/lib1/rspack.config.js | 6 ++++++ rspack/module-federation-v1/lib1/src/bootstrap.js | 2 +- rspack/module-federation-v1/lib1/src/index.js | 2 +- rspack/monaco-editor-webpack-plugin/index.js | 2 +- rspack/monaco-editor-webpack-plugin/rspack.config.js | 6 ++++++ rspack/multi-entry/index.js | 4 ++-- rspack/multi-entry/rspack.config.js | 10 ++++++++++ rspack/nest-alias/rspack.config.js | 10 ++++++++++ rspack/node-globals-shim/rspack.config.js | 10 ++++++++++ rspack/node-globals-shim/src/index.js | 4 ++-- rspack/node-polyfill/rspack.config.js | 10 ++++++++++ rspack/node-polyfill/src/index.js | 2 +- rspack/perfsee/rspack.config.js | 10 ++++++++++ rspack/perfsee/src/index.js | 2 +- rspack/polyfill/rspack.config.js | 6 ++++++ rspack/polyfill/src/index.js | 2 +- rspack/preact-refresh/rspack.config.js | 6 ++++++ rspack/preact-refresh/src/index.jsx | 2 +- rspack/preact/rspack.config.js | 6 ++++++ rspack/preact/src/index.jsx | 2 +- rspack/react-compiler-babel/rspack.config.js | 6 ++++++ rspack/react-compiler-babel/src/index.jsx | 2 +- rspack/react-with-extract-css/rspack.config.js | 6 ++++++ rspack/react-with-extract-css/src/index.jsx | 2 +- rspack/react-with-less/rspack.config.js | 6 ++++++ rspack/react-with-less/src/index.jsx | 2 +- rspack/react-with-sass/rspack.config.js | 6 ++++++ rspack/react-with-sass/src/index.jsx | 2 +- rspack/react/rspack.config.js | 6 ++++++ rspack/react/src/index.jsx | 2 +- rspack/sentry/rspack.config.js | 10 ++++++++++ rspack/sentry/src/index.js | 2 +- rspack/solid/rspack.config.js | 6 ++++++ rspack/solid/src/App.jsx | 2 +- rspack/solid/src/index.jsx | 2 +- rspack/stats/rspack.config.js | 10 ++++++++++ rspack/stats/src/index.js | 2 +- rspack/treeshaking-transform-imports/rspack.config.js | 6 ++++++ rspack/treeshaking-transform-imports/src/a.js | 2 +- rspack/treeshaking-transform-imports/src/index.js | 2 +- rspack/treeshaking-transform-imports/src/sdk.js | 6 +++--- rspack/vue-jsx/rspack.config.js | 6 ++++++ rspack/vue-jsx/src/main.jsx | 2 +- rspack/wasm-simple/example.js | 2 +- rspack/wasm-simple/rspack.config.js | 10 ++++++++++ rspack/worker/chat-worker.js | 2 +- rspack/worker/example.js | 2 +- rspack/worker/fib-worker.js | 2 +- rspack/worker/rspack.config.js | 10 ++++++++++ rspack/worklet/rspack.config.js | 6 ++++++ rspack/worklet/src/index.js | 4 ++-- rspack/worklet/src/worklet/complex.worklet.js | 2 +- 96 files changed, 397 insertions(+), 71 deletions(-) diff --git a/rspack/basic/rspack.config.js b/rspack/basic/rspack.config.js index 91b5bf2bb..342e3f93b 100644 --- a/rspack/basic/rspack.config.js +++ b/rspack/basic/rspack.config.js @@ -3,6 +3,16 @@ import { rspack } from '@rspack/core'; import { defineConfig } from '@rspack/cli'; export default defineConfig({ + module: { + rules: [ + { + test: /\.[cm]?[jt]sx?$/, + resolve: { + fullySpecified: false, + }, + }, + ], + }, entry: './src/index.js', plugins: [ new rspack.HtmlRspackPlugin({ diff --git a/rspack/basic/src/index.js b/rspack/basic/src/index.js index 6cde9f2b5..cfbdbfb89 100644 --- a/rspack/basic/src/index.js +++ b/rspack/basic/src/index.js @@ -1,4 +1,4 @@ -import { answer } from './answer.js'; +import { answer } from './answer'; function render() { document.getElementById('root').innerHTML = `the answer to the universe is ${answer}`; } diff --git a/rspack/builtin-swc-loader/rspack.config.js b/rspack/builtin-swc-loader/rspack.config.js index 1334c9891..714097005 100644 --- a/rspack/builtin-swc-loader/rspack.config.js +++ b/rspack/builtin-swc-loader/rspack.config.js @@ -18,6 +18,12 @@ export default defineConfig({ }, module: { rules: [ + { + test: /\.[cm]?[jt]sx?$/, + resolve: { + fullySpecified: false, + }, + }, { test: /\.css$/, type: 'css', diff --git a/rspack/builtin-swc-loader/src/index.jsx b/rspack/builtin-swc-loader/src/index.jsx index d9a4c3cc1..d1fdc49b6 100644 --- a/rspack/builtin-swc-loader/src/index.jsx +++ b/rspack/builtin-swc-loader/src/index.jsx @@ -1,7 +1,7 @@ import React from 'react'; import ReactDOM from 'react-dom/client'; import './index.css'; -import App from './App.jsx'; +import App from './App'; import { answer } from 'lib3'; graphql` fragment Foo on Bar { diff --git a/rspack/bundle-splitting/index.js b/rspack/bundle-splitting/index.js index 55ade7fc8..d71b971cb 100644 --- a/rspack/bundle-splitting/index.js +++ b/rspack/bundle-splitting/index.js @@ -1,4 +1,4 @@ -import { common } from './common.js'; -import { inline } from './inline.js'; -import { manual } from './manual.js'; +import { common } from './common'; +import { inline } from './inline'; +import { manual } from './manual'; console.log('all:', manual, inline, common); diff --git a/rspack/bundle-splitting/rspack.config.js b/rspack/bundle-splitting/rspack.config.js index 4bb56e5d5..bd8962603 100644 --- a/rspack/bundle-splitting/rspack.config.js +++ b/rspack/bundle-splitting/rspack.config.js @@ -7,6 +7,14 @@ export default defineConfig({ main: './index.js', }, module: { + rules: [ + { + test: /\.[cm]?[jt]sx?$/, + resolve: { + fullySpecified: false, + }, + }, + ], parser: { asset: { dataUrlCondition: { diff --git a/rspack/case-sensitive-paths-webpack-plugin/rspack.config.js b/rspack/case-sensitive-paths-webpack-plugin/rspack.config.js index 654836090..c77b5ee5f 100644 --- a/rspack/case-sensitive-paths-webpack-plugin/rspack.config.js +++ b/rspack/case-sensitive-paths-webpack-plugin/rspack.config.js @@ -3,5 +3,15 @@ import { defineConfig } from '@rspack/cli'; import CaseSensitivePlugin from 'case-sensitive-paths-webpack-plugin'; export default defineConfig({ + module: { + rules: [ + { + test: /\.[cm]?[jt]sx?$/, + resolve: { + fullySpecified: false, + }, + }, + ], + }, plugins: [new CaseSensitivePlugin()], }); diff --git a/rspack/case-sensitive-paths-webpack-plugin/src/index.js b/rspack/case-sensitive-paths-webpack-plugin/src/index.js index 619ba471b..056f1781f 100644 --- a/rspack/case-sensitive-paths-webpack-plugin/src/index.js +++ b/rspack/case-sensitive-paths-webpack-plugin/src/index.js @@ -1,2 +1,2 @@ -import { answer } from './Answer.js'; +import { answer } from './Answer'; console.log('answer', answer); diff --git a/rspack/code-splitting/index.js b/rspack/code-splitting/index.js index d5df5b0c1..b3366333c 100644 --- a/rspack/code-splitting/index.js +++ b/rspack/code-splitting/index.js @@ -1,7 +1,7 @@ -import { something } from './static.js'; +import { something } from './static'; const a = 10; async function render() { - const { answer } = await import('./answer.js'); + const { answer } = await import('./answer'); console.log('a:', a); console.log('answer:', answer); console.log('static:', something); diff --git a/rspack/code-splitting/rspack.config.js b/rspack/code-splitting/rspack.config.js index 56d9d6c31..94cdc6d98 100644 --- a/rspack/code-splitting/rspack.config.js +++ b/rspack/code-splitting/rspack.config.js @@ -3,6 +3,16 @@ import { rspack } from '@rspack/core'; import { defineConfig } from '@rspack/cli'; export default defineConfig({ + module: { + rules: [ + { + test: /\.[cm]?[jt]sx?$/, + resolve: { + fullySpecified: false, + }, + }, + ], + }, entry: { main: './index.js', }, diff --git a/rspack/common-libs/lib1/src/index.ts b/rspack/common-libs/lib1/src/index.ts index ebc02e4e3..6d24bce71 100644 --- a/rspack/common-libs/lib1/src/index.ts +++ b/rspack/common-libs/lib1/src/index.ts @@ -1,5 +1,5 @@ -import { tab } from '@components/tab.js'; +import { tab } from '@components/tab'; console.log('button', tab); -export * from '@components/tab.js'; +export * from '@components/tab'; diff --git a/rspack/common-libs/lib1/tsconfig.json b/rspack/common-libs/lib1/tsconfig.json index 51e5e88a2..4f9035f12 100644 --- a/rspack/common-libs/lib1/tsconfig.json +++ b/rspack/common-libs/lib1/tsconfig.json @@ -1,10 +1,12 @@ { "extends": "../../../tsconfig.base.json", "compilerOptions": { + "module": "ESNext", + "moduleResolution": "Bundler", "outDir": "dist", "rootDir": "src", "paths": { - "@components/*.js": ["./src/components/*.ts"] + "@components/*": ["./src/components/*"] } }, "include": ["src"] diff --git a/rspack/common-libs/lib2/src/index.ts b/rspack/common-libs/lib2/src/index.ts index fe5039a55..10820dd55 100644 --- a/rspack/common-libs/lib2/src/index.ts +++ b/rspack/common-libs/lib2/src/index.ts @@ -1,5 +1,5 @@ -import { button } from '@components/button.js'; +import { button } from '@components/button'; console.log('button', button); -export * from '@components/button.js'; +export * from '@components/button'; diff --git a/rspack/common-libs/lib2/tsconfig.json b/rspack/common-libs/lib2/tsconfig.json index 51e5e88a2..4f9035f12 100644 --- a/rspack/common-libs/lib2/tsconfig.json +++ b/rspack/common-libs/lib2/tsconfig.json @@ -1,10 +1,12 @@ { "extends": "../../../tsconfig.base.json", "compilerOptions": { + "module": "ESNext", + "moduleResolution": "Bundler", "outDir": "dist", "rootDir": "src", "paths": { - "@components/*.js": ["./src/components/*.ts"] + "@components/*": ["./src/components/*"] } }, "include": ["src"] diff --git a/rspack/cra/rspack.config.js b/rspack/cra/rspack.config.js index 8eb679f6d..f74bd9252 100644 --- a/rspack/cra/rspack.config.js +++ b/rspack/cra/rspack.config.js @@ -12,6 +12,12 @@ export default defineConfig({ }, module: { rules: [ + { + test: /\.[cm]?[jt]sx?$/, + resolve: { + fullySpecified: false, + }, + }, { test: /\.css$/, type: 'css', diff --git a/rspack/cra/src/App.test.js b/rspack/cra/src/App.test.js index a466f5293..1f03afeec 100644 --- a/rspack/cra/src/App.test.js +++ b/rspack/cra/src/App.test.js @@ -1,5 +1,5 @@ import { render, screen } from '@testing-library/react'; -import App from './App.jsx'; +import App from './App'; test('renders learn react link', () => { render(); diff --git a/rspack/cra/src/index.jsx b/rspack/cra/src/index.jsx index de476c1cf..9168dc413 100644 --- a/rspack/cra/src/index.jsx +++ b/rspack/cra/src/index.jsx @@ -1,8 +1,8 @@ import React from 'react'; import ReactDOM from 'react-dom/client'; import './index.css'; -import App from './App.jsx'; -import reportWebVitals from './reportWebVitals.js'; +import App from './App'; +import reportWebVitals from './reportWebVitals'; const root = ReactDOM.createRoot(document.getElementById('root')); root.render( diff --git a/rspack/css-chunking-plugin/rspack.config.js b/rspack/css-chunking-plugin/rspack.config.js index 64301b4bc..43380128f 100644 --- a/rspack/css-chunking-plugin/rspack.config.js +++ b/rspack/css-chunking-plugin/rspack.config.js @@ -6,6 +6,12 @@ export default defineConfig({ entry: './src/index.js', module: { rules: [ + { + test: /\.[cm]?[jt]sx?$/, + resolve: { + fullySpecified: false, + }, + }, { test: /\.css$/, type: 'css', diff --git a/rspack/css-chunking-plugin/src/index.js b/rspack/css-chunking-plugin/src/index.js index 1b1b9da11..9ed7facad 100644 --- a/rspack/css-chunking-plugin/src/index.js +++ b/rspack/css-chunking-plugin/src/index.js @@ -1 +1 @@ -import('./page.js'); +import('./page'); diff --git a/rspack/dll-reference/index.js b/rspack/dll-reference/index.js index bd0600e75..7b4f638e8 100644 --- a/rspack/dll-reference/index.js +++ b/rspack/dll-reference/index.js @@ -1,5 +1,5 @@ -import a from '../dll/a.ts'; -import alpha from '../dll/alpha.ts'; +import a from '../dll/a'; +import alpha from '../dll/alpha'; import beta from 'beta/beta'; import b from 'beta/b'; import c from 'beta/c'; diff --git a/rspack/dll-reference/rspack.config.js b/rspack/dll-reference/rspack.config.js index f2b8868b3..f9711270d 100644 --- a/rspack/dll-reference/rspack.config.js +++ b/rspack/dll-reference/rspack.config.js @@ -4,6 +4,16 @@ import { defineConfig } from '@rspack/cli'; import { rspack } from '@rspack/core'; export default defineConfig({ + module: { + rules: [ + { + test: /\.[cm]?[jt]sx?$/, + resolve: { + fullySpecified: false, + }, + }, + ], + }, entry: './index', output: { path: path.resolve(import.meta.dirname, 'dist'), diff --git a/rspack/eslint/rspack.config.js b/rspack/eslint/rspack.config.js index fca9bd90c..a222561f3 100644 --- a/rspack/eslint/rspack.config.js +++ b/rspack/eslint/rspack.config.js @@ -3,6 +3,16 @@ import { defineConfig } from '@rspack/cli'; import EslintPlugin from 'eslint-rspack-plugin'; export default defineConfig({ + module: { + rules: [ + { + test: /\.[cm]?[jt]sx?$/, + resolve: { + fullySpecified: false, + }, + }, + ], + }, context: import.meta.dirname, entry: { main: './src/index.js', diff --git a/rspack/eslint/src/index.js b/rspack/eslint/src/index.js index 6cde9f2b5..cfbdbfb89 100644 --- a/rspack/eslint/src/index.js +++ b/rspack/eslint/src/index.js @@ -1,4 +1,4 @@ -import { answer } from './answer.js'; +import { answer } from './answer'; function render() { document.getElementById('root').innerHTML = `the answer to the universe is ${answer}`; } diff --git a/rspack/hooks-after-resolve/rspack.config.js b/rspack/hooks-after-resolve/rspack.config.js index 9646110ac..48c9196e8 100644 --- a/rspack/hooks-after-resolve/rspack.config.js +++ b/rspack/hooks-after-resolve/rspack.config.js @@ -3,6 +3,16 @@ import { defineConfig } from '@rspack/cli'; import { rspack } from '@rspack/core'; export default defineConfig({ + module: { + rules: [ + { + test: /\.[cm]?[jt]sx?$/, + resolve: { + fullySpecified: false, + }, + }, + ], + }, entry: './src/index.js', plugins: [ new rspack.HtmlRspackPlugin({ diff --git a/rspack/hooks-after-resolve/src/index.js b/rspack/hooks-after-resolve/src/index.js index 5e53837b9..cc88a2bed 100644 --- a/rspack/hooks-after-resolve/src/index.js +++ b/rspack/hooks-after-resolve/src/index.js @@ -1,4 +1,4 @@ -import { answer } from './answer.js'; +import { answer } from './answer'; function render() { document.getElementById('root').innerHTML = `the answer to the universe is ${answer}`; diff --git a/rspack/lazy-compilation-server/dev.js b/rspack/lazy-compilation-server/dev.js index cacf770cc..ec356217d 100644 --- a/rspack/lazy-compilation-server/dev.js +++ b/rspack/lazy-compilation-server/dev.js @@ -2,6 +2,16 @@ import { rspack } from '@rspack/core'; import { RspackDevServer } from '@rspack/dev-server'; const compiler = rspack({ + module: { + rules: [ + { + test: /\.[cm]?[jt]sx?$/, + resolve: { + fullySpecified: false, + }, + }, + ], + }, entry: './src/index.js', context: import.meta.dirname, plugins: [new rspack.HtmlRspackPlugin()], diff --git a/rspack/lazy-compilation-server/src/index.js b/rspack/lazy-compilation-server/src/index.js index c8ceeb29d..54eb92adc 100644 --- a/rspack/lazy-compilation-server/src/index.js +++ b/rspack/lazy-compilation-server/src/index.js @@ -1,4 +1,4 @@ -import info from './info.js'; +import info from './info'; const text = document.createElement('text'); @@ -7,7 +7,7 @@ text.textContent = info; document.body.appendChild(text); document.addEventListener('click', () => { - import('./show-msg.js'); + import('./show-msg'); }); module.hot.accept('./info', () => { diff --git a/rspack/library-cjs/rspack.config.js b/rspack/library-cjs/rspack.config.js index 97d5a1411..f6d19d580 100644 --- a/rspack/library-cjs/rspack.config.js +++ b/rspack/library-cjs/rspack.config.js @@ -2,6 +2,16 @@ import { defineConfig } from '@rspack/cli'; export default defineConfig({ + module: { + rules: [ + { + test: /\.[cm]?[jt]sx?$/, + resolve: { + fullySpecified: false, + }, + }, + ], + }, mode: 'production', entry: { index: './src/index.js', diff --git a/rspack/library-cjs/src/index.js b/rspack/library-cjs/src/index.js index 4cb0a5f97..3bbd841e7 100644 --- a/rspack/library-cjs/src/index.js +++ b/rspack/library-cjs/src/index.js @@ -1,2 +1,2 @@ -export * from './answer.js'; -export * from './secret.js'; +export * from './answer'; +export * from './secret'; diff --git a/rspack/library-esm/rspack.config.js b/rspack/library-esm/rspack.config.js index bf529946e..19ad0a6ec 100644 --- a/rspack/library-esm/rspack.config.js +++ b/rspack/library-esm/rspack.config.js @@ -17,6 +17,14 @@ export default defineConfig({ workerChunkLoading: 'import', }, module: { + rules: [ + { + test: /\.[cm]?[jt]sx?$/, + resolve: { + fullySpecified: false, + }, + }, + ], parser: { javascript: { importMeta: false, // keep import.meta for runtime diff --git a/rspack/library-esm/src/index.js b/rspack/library-esm/src/index.js index 4cb0a5f97..3bbd841e7 100644 --- a/rspack/library-esm/src/index.js +++ b/rspack/library-esm/src/index.js @@ -1,2 +1,2 @@ -export * from './answer.js'; -export * from './secret.js'; +export * from './answer'; +export * from './secret'; diff --git a/rspack/library-umd/rspack.config.js b/rspack/library-umd/rspack.config.js index 3cd3a9bbc..bd09d20e9 100644 --- a/rspack/library-umd/rspack.config.js +++ b/rspack/library-umd/rspack.config.js @@ -2,6 +2,16 @@ import { defineConfig } from '@rspack/cli'; export default defineConfig({ + module: { + rules: [ + { + test: /\.[cm]?[jt]sx?$/, + resolve: { + fullySpecified: false, + }, + }, + ], + }, mode: 'production', entry: { index: './src/index.js', diff --git a/rspack/library-umd/src/index.js b/rspack/library-umd/src/index.js index 4cb0a5f97..3bbd841e7 100644 --- a/rspack/library-umd/src/index.js +++ b/rspack/library-umd/src/index.js @@ -1,2 +1,2 @@ -export * from './answer.js'; -export * from './secret.js'; +export * from './answer'; +export * from './secret'; diff --git a/rspack/lightingcss-loader/rspack.config.js b/rspack/lightingcss-loader/rspack.config.js index 6eee2e53c..71fbcccee 100644 --- a/rspack/lightingcss-loader/rspack.config.js +++ b/rspack/lightingcss-loader/rspack.config.js @@ -6,6 +6,12 @@ export default defineConfig({ entry: './src/index.js', module: { rules: [ + { + test: /\.[cm]?[jt]sx?$/, + resolve: { + fullySpecified: false, + }, + }, { test: /\.css$/, use: [ diff --git a/rspack/lightingcss-loader/src/index.js b/rspack/lightingcss-loader/src/index.js index 71f6dfda3..5b5512bd3 100644 --- a/rspack/lightingcss-loader/src/index.js +++ b/rspack/lightingcss-loader/src/index.js @@ -1,5 +1,5 @@ import './index.css'; -import { answer } from './answer.js'; +import { answer } from './answer'; function render() { document.getElementById('root').innerHTML = `
the answer to the universe is ${answer}
`; diff --git a/rspack/module-federation-v1.5/app/rspack.config.js b/rspack/module-federation-v1.5/app/rspack.config.js index 3db2be38b..644b0f0e7 100644 --- a/rspack/module-federation-v1.5/app/rspack.config.js +++ b/rspack/module-federation-v1.5/app/rspack.config.js @@ -18,6 +18,12 @@ export default defineConfig({ }, module: { rules: [ + { + test: /\.[cm]?[jt]sx?$/, + resolve: { + fullySpecified: false, + }, + }, { test: /\.(?:js|mjs|cjs|jsx)$/, include: path.resolve(import.meta.dirname, 'src'), diff --git a/rspack/module-federation-v1.5/app/src/bootstrap.js b/rspack/module-federation-v1.5/app/src/bootstrap.js index bff1d1140..8b61f13f5 100644 --- a/rspack/module-federation-v1.5/app/src/bootstrap.js +++ b/rspack/module-federation-v1.5/app/src/bootstrap.js @@ -1,5 +1,5 @@ import { createRoot } from 'react-dom/client'; // <- this is a shared module, but used as usual -import App from './App.js'; +import App from './App'; // load app const el = document.createElement('main'); diff --git a/rspack/module-federation-v1.5/app/src/index.js b/rspack/module-federation-v1.5/app/src/index.js index 285e25976..9da4575b7 100644 --- a/rspack/module-federation-v1.5/app/src/index.js +++ b/rspack/module-federation-v1.5/app/src/index.js @@ -7,7 +7,7 @@ // This also requires an async boundary (import()) // At this point shared modules initialized and remote modules are loaded -import('./bootstrap.js'); +import('./bootstrap'); // It's possible to place more code here to do stuff on page init // but it can't use any of the shared modules or remote modules. diff --git a/rspack/module-federation-v1.5/lib1/rspack.config.js b/rspack/module-federation-v1.5/lib1/rspack.config.js index 5716abb38..c20ca24f8 100644 --- a/rspack/module-federation-v1.5/lib1/rspack.config.js +++ b/rspack/module-federation-v1.5/lib1/rspack.config.js @@ -18,6 +18,12 @@ export default defineConfig({ }, module: { rules: [ + { + test: /\.[cm]?[jt]sx?$/, + resolve: { + fullySpecified: false, + }, + }, { test: /\.(?:js|mjs|cjs|jsx)$/, include: path.resolve(import.meta.dirname, 'src'), diff --git a/rspack/module-federation-v1.5/lib1/src/bootstrap.js b/rspack/module-federation-v1.5/lib1/src/bootstrap.js index e52fe9901..126347f47 100644 --- a/rspack/module-federation-v1.5/lib1/src/bootstrap.js +++ b/rspack/module-federation-v1.5/lib1/src/bootstrap.js @@ -1,5 +1,5 @@ import { createRoot } from 'react-dom/client'; -import Component from './Component.js'; +import Component from './Component'; import { de } from 'date-fns/locale'; const el = document.createElement('main'); diff --git a/rspack/module-federation-v1.5/lib1/src/index.js b/rspack/module-federation-v1.5/lib1/src/index.js index d390836af..b93c7a026 100644 --- a/rspack/module-federation-v1.5/lib1/src/index.js +++ b/rspack/module-federation-v1.5/lib1/src/index.js @@ -1 +1 @@ -import('./bootstrap.js'); +import('./bootstrap'); diff --git a/rspack/module-federation-v1/app/rspack.config.js b/rspack/module-federation-v1/app/rspack.config.js index e3f990601..3197515c3 100644 --- a/rspack/module-federation-v1/app/rspack.config.js +++ b/rspack/module-federation-v1/app/rspack.config.js @@ -18,6 +18,12 @@ export default defineConfig({ }, module: { rules: [ + { + test: /\.[cm]?[jt]sx?$/, + resolve: { + fullySpecified: false, + }, + }, { test: /\.(?:js|mjs|cjs|jsx)$/, include: path.resolve(import.meta.dirname, 'src'), diff --git a/rspack/module-federation-v1/app/src/bootstrap.js b/rspack/module-federation-v1/app/src/bootstrap.js index bff1d1140..8b61f13f5 100644 --- a/rspack/module-federation-v1/app/src/bootstrap.js +++ b/rspack/module-federation-v1/app/src/bootstrap.js @@ -1,5 +1,5 @@ import { createRoot } from 'react-dom/client'; // <- this is a shared module, but used as usual -import App from './App.js'; +import App from './App'; // load app const el = document.createElement('main'); diff --git a/rspack/module-federation-v1/app/src/index.js b/rspack/module-federation-v1/app/src/index.js index 285e25976..9da4575b7 100644 --- a/rspack/module-federation-v1/app/src/index.js +++ b/rspack/module-federation-v1/app/src/index.js @@ -7,7 +7,7 @@ // This also requires an async boundary (import()) // At this point shared modules initialized and remote modules are loaded -import('./bootstrap.js'); +import('./bootstrap'); // It's possible to place more code here to do stuff on page init // but it can't use any of the shared modules or remote modules. diff --git a/rspack/module-federation-v1/lib1/rspack.config.js b/rspack/module-federation-v1/lib1/rspack.config.js index f8868bc7c..aebb73e6a 100644 --- a/rspack/module-federation-v1/lib1/rspack.config.js +++ b/rspack/module-federation-v1/lib1/rspack.config.js @@ -18,6 +18,12 @@ export default defineConfig({ }, module: { rules: [ + { + test: /\.[cm]?[jt]sx?$/, + resolve: { + fullySpecified: false, + }, + }, { test: /\.(?:js|mjs|cjs|jsx)$/, include: path.resolve(import.meta.dirname, 'src'), diff --git a/rspack/module-federation-v1/lib1/src/bootstrap.js b/rspack/module-federation-v1/lib1/src/bootstrap.js index e52fe9901..126347f47 100644 --- a/rspack/module-federation-v1/lib1/src/bootstrap.js +++ b/rspack/module-federation-v1/lib1/src/bootstrap.js @@ -1,5 +1,5 @@ import { createRoot } from 'react-dom/client'; -import Component from './Component.js'; +import Component from './Component'; import { de } from 'date-fns/locale'; const el = document.createElement('main'); diff --git a/rspack/module-federation-v1/lib1/src/index.js b/rspack/module-federation-v1/lib1/src/index.js index d390836af..b93c7a026 100644 --- a/rspack/module-federation-v1/lib1/src/index.js +++ b/rspack/module-federation-v1/lib1/src/index.js @@ -1 +1 @@ -import('./bootstrap.js'); +import('./bootstrap'); diff --git a/rspack/monaco-editor-webpack-plugin/index.js b/rspack/monaco-editor-webpack-plugin/index.js index 1a22f3280..04bddc899 100644 --- a/rspack/monaco-editor-webpack-plugin/index.js +++ b/rspack/monaco-editor-webpack-plugin/index.js @@ -1,4 +1,4 @@ -import * as monaco from 'monaco-editor/esm/vs/editor/editor.api.js'; +import * as monaco from 'monaco-editor/esm/vs/editor/editor.api'; (function () { // create div to avoid needing a HtmlWebpackPlugin template diff --git a/rspack/monaco-editor-webpack-plugin/rspack.config.js b/rspack/monaco-editor-webpack-plugin/rspack.config.js index 130d9739e..4fa149164 100644 --- a/rspack/monaco-editor-webpack-plugin/rspack.config.js +++ b/rspack/monaco-editor-webpack-plugin/rspack.config.js @@ -15,6 +15,12 @@ export default defineConfig({ }, module: { rules: [ + { + test: /\.[cm]?[jt]sx?$/, + resolve: { + fullySpecified: false, + }, + }, { test: /\.css$/, type: 'css', diff --git a/rspack/multi-entry/index.js b/rspack/multi-entry/index.js index c877a74c1..b767c3291 100644 --- a/rspack/multi-entry/index.js +++ b/rspack/multi-entry/index.js @@ -1,7 +1,7 @@ -import { something } from './static.js'; +import { something } from './static'; const a = 10; async function render() { - import('./answer.js').then((x) => { + import('./answer').then((x) => { console.log('x:', x); }); console.log('a:', a); diff --git a/rspack/multi-entry/rspack.config.js b/rspack/multi-entry/rspack.config.js index 015ea478b..ae07dbe84 100644 --- a/rspack/multi-entry/rspack.config.js +++ b/rspack/multi-entry/rspack.config.js @@ -3,6 +3,16 @@ import { defineConfig } from '@rspack/cli'; import { rspack } from '@rspack/core'; export default defineConfig({ + module: { + rules: [ + { + test: /\.[cm]?[jt]sx?$/, + resolve: { + fullySpecified: false, + }, + }, + ], + }, entry: { index: './index.js', second: './second.js', diff --git a/rspack/nest-alias/rspack.config.js b/rspack/nest-alias/rspack.config.js index 834e2f67b..970cb8fec 100644 --- a/rspack/nest-alias/rspack.config.js +++ b/rspack/nest-alias/rspack.config.js @@ -3,6 +3,16 @@ import path from 'node:path'; import { defineConfig } from '@rspack/cli'; export default defineConfig({ + module: { + rules: [ + { + test: /\.[cm]?[jt]sx?$/, + resolve: { + fullySpecified: false, + }, + }, + ], + }, entry: { main: './src/index.ts', }, diff --git a/rspack/node-globals-shim/rspack.config.js b/rspack/node-globals-shim/rspack.config.js index 7980b8b88..986506315 100644 --- a/rspack/node-globals-shim/rspack.config.js +++ b/rspack/node-globals-shim/rspack.config.js @@ -4,6 +4,16 @@ import { defineConfig } from '@rspack/cli'; import { rspack } from '@rspack/core'; export default defineConfig({ + module: { + rules: [ + { + test: /\.[cm]?[jt]sx?$/, + resolve: { + fullySpecified: false, + }, + }, + ], + }, context: import.meta.dirname, entry: { main: './src/index.js', diff --git a/rspack/node-globals-shim/src/index.js b/rspack/node-globals-shim/src/index.js index cffe9f468..ef5ad7dee 100644 --- a/rspack/node-globals-shim/src/index.js +++ b/rspack/node-globals-shim/src/index.js @@ -1,5 +1,5 @@ -import './util.js'; -import { answer } from './answer.js'; +import './util'; +import { answer } from './answer'; function render() { document.getElementById('root').innerHTML = `the answer to the universe is ${answer}`; } diff --git a/rspack/node-polyfill/rspack.config.js b/rspack/node-polyfill/rspack.config.js index 6ced09b0f..2dd1bcd16 100644 --- a/rspack/node-polyfill/rspack.config.js +++ b/rspack/node-polyfill/rspack.config.js @@ -4,6 +4,16 @@ import { rspack } from '@rspack/core'; import NodePolyfillPlugin from 'node-polyfill-webpack-plugin'; export default defineConfig({ + module: { + rules: [ + { + test: /\.[cm]?[jt]sx?$/, + resolve: { + fullySpecified: false, + }, + }, + ], + }, context: import.meta.dirname, entry: { main: './src/index.js', diff --git a/rspack/node-polyfill/src/index.js b/rspack/node-polyfill/src/index.js index 551743d75..5fcefee91 100644 --- a/rspack/node-polyfill/src/index.js +++ b/rspack/node-polyfill/src/index.js @@ -1,5 +1,5 @@ import util from 'util'; -import logger from './logger.js'; +import logger from './logger'; console.log('procss:', process.version); console.log('buffer', Buffer.from('abcd')); diff --git a/rspack/perfsee/rspack.config.js b/rspack/perfsee/rspack.config.js index c58512701..bf99de267 100644 --- a/rspack/perfsee/rspack.config.js +++ b/rspack/perfsee/rspack.config.js @@ -4,6 +4,16 @@ import { defineConfig } from '@rspack/cli'; import { rspack } from '@rspack/core'; export default defineConfig({ + module: { + rules: [ + { + test: /\.[cm]?[jt]sx?$/, + resolve: { + fullySpecified: false, + }, + }, + ], + }, context: import.meta.dirname, entry: { main: './src/index.js', diff --git a/rspack/perfsee/src/index.js b/rspack/perfsee/src/index.js index 6cde9f2b5..cfbdbfb89 100644 --- a/rspack/perfsee/src/index.js +++ b/rspack/perfsee/src/index.js @@ -1,4 +1,4 @@ -import { answer } from './answer.js'; +import { answer } from './answer'; function render() { document.getElementById('root').innerHTML = `the answer to the universe is ${answer}`; } diff --git a/rspack/polyfill/rspack.config.js b/rspack/polyfill/rspack.config.js index 5ed566e17..245259f2b 100644 --- a/rspack/polyfill/rspack.config.js +++ b/rspack/polyfill/rspack.config.js @@ -16,6 +16,12 @@ export default defineConfig({ }, module: { rules: [ + { + test: /\.[cm]?[jt]sx?$/, + resolve: { + fullySpecified: false, + }, + }, { test: /\.(?:js|mjs|cjs)$/, exclude: /node_modules/, diff --git a/rspack/polyfill/src/index.js b/rspack/polyfill/src/index.js index 6cde9f2b5..cfbdbfb89 100644 --- a/rspack/polyfill/src/index.js +++ b/rspack/polyfill/src/index.js @@ -1,4 +1,4 @@ -import { answer } from './answer.js'; +import { answer } from './answer'; function render() { document.getElementById('root').innerHTML = `the answer to the universe is ${answer}`; } diff --git a/rspack/preact-refresh/rspack.config.js b/rspack/preact-refresh/rspack.config.js index 71fb9eae6..913a09adf 100644 --- a/rspack/preact-refresh/rspack.config.js +++ b/rspack/preact-refresh/rspack.config.js @@ -20,6 +20,12 @@ export default defineConfig({ }, module: { rules: [ + { + test: /\.[cm]?[jt]sx?$/, + resolve: { + fullySpecified: false, + }, + }, { test: /\.css$/, type: 'css', diff --git a/rspack/preact-refresh/src/index.jsx b/rspack/preact-refresh/src/index.jsx index f6395651d..4f7c4b906 100644 --- a/rspack/preact-refresh/src/index.jsx +++ b/rspack/preact-refresh/src/index.jsx @@ -1,7 +1,7 @@ import React from 'react'; import ReactDOM from 'react-dom/client'; import './index.css'; -import App from './App.jsx'; +import App from './App'; const root = ReactDOM.createRoot(document.getElementById('root')); root.render(); diff --git a/rspack/preact/rspack.config.js b/rspack/preact/rspack.config.js index a7aaa02a4..4a22c4afc 100644 --- a/rspack/preact/rspack.config.js +++ b/rspack/preact/rspack.config.js @@ -19,6 +19,12 @@ export default defineConfig({ }, module: { rules: [ + { + test: /\.[cm]?[jt]sx?$/, + resolve: { + fullySpecified: false, + }, + }, { test: /\.css$/, type: 'css', diff --git a/rspack/preact/src/index.jsx b/rspack/preact/src/index.jsx index 5917c5feb..793e2b837 100644 --- a/rspack/preact/src/index.jsx +++ b/rspack/preact/src/index.jsx @@ -1,7 +1,7 @@ import React from 'react'; import ReactDOM from 'react-dom/client'; import './index.css'; -import App from './App.jsx'; +import App from './App'; const root = ReactDOM.createRoot(document.getElementById('root')); root.render(); diff --git a/rspack/react-compiler-babel/rspack.config.js b/rspack/react-compiler-babel/rspack.config.js index 70c3ad50d..68bff5ff2 100644 --- a/rspack/react-compiler-babel/rspack.config.js +++ b/rspack/react-compiler-babel/rspack.config.js @@ -11,6 +11,12 @@ export default defineConfig({ }, module: { rules: [ + { + test: /\.[cm]?[jt]sx?$/, + resolve: { + fullySpecified: false, + }, + }, { test: /\.css$/, type: 'css', diff --git a/rspack/react-compiler-babel/src/index.jsx b/rspack/react-compiler-babel/src/index.jsx index 87da8bf7f..dac4ede38 100644 --- a/rspack/react-compiler-babel/src/index.jsx +++ b/rspack/react-compiler-babel/src/index.jsx @@ -1,7 +1,7 @@ import React from 'react'; import ReactDOM from 'react-dom/client'; import './index.css'; -import App from './App.jsx'; +import App from './App'; const root = ReactDOM.createRoot(document.getElementById('root')); root.render( diff --git a/rspack/react-with-extract-css/rspack.config.js b/rspack/react-with-extract-css/rspack.config.js index a2f615132..d9db0d33d 100644 --- a/rspack/react-with-extract-css/rspack.config.js +++ b/rspack/react-with-extract-css/rspack.config.js @@ -13,6 +13,12 @@ export default defineConfig({ }, module: { rules: [ + { + test: /\.[cm]?[jt]sx?$/, + resolve: { + fullySpecified: false, + }, + }, { test: /\.(?:js|mjs|cjs|jsx)$/, exclude: /node_modules/, diff --git a/rspack/react-with-extract-css/src/index.jsx b/rspack/react-with-extract-css/src/index.jsx index df3dfb4db..b22747728 100644 --- a/rspack/react-with-extract-css/src/index.jsx +++ b/rspack/react-with-extract-css/src/index.jsx @@ -1,7 +1,7 @@ import React from 'react'; import ReactDOM from 'react-dom'; import './styles.less'; -import HelloWorld from './components/hello-world.jsx'; +import HelloWorld from './components/hello-world'; function App() { return ( diff --git a/rspack/react-with-less/rspack.config.js b/rspack/react-with-less/rspack.config.js index 24333867d..371a53961 100644 --- a/rspack/react-with-less/rspack.config.js +++ b/rspack/react-with-less/rspack.config.js @@ -13,6 +13,12 @@ export default defineConfig({ }, module: { rules: [ + { + test: /\.[cm]?[jt]sx?$/, + resolve: { + fullySpecified: false, + }, + }, { test: /\.(?:js|mjs|cjs|jsx)$/, exclude: /node_modules/, diff --git a/rspack/react-with-less/src/index.jsx b/rspack/react-with-less/src/index.jsx index df3dfb4db..b22747728 100644 --- a/rspack/react-with-less/src/index.jsx +++ b/rspack/react-with-less/src/index.jsx @@ -1,7 +1,7 @@ import React from 'react'; import ReactDOM from 'react-dom'; import './styles.less'; -import HelloWorld from './components/hello-world.jsx'; +import HelloWorld from './components/hello-world'; function App() { return ( diff --git a/rspack/react-with-sass/rspack.config.js b/rspack/react-with-sass/rspack.config.js index 4d9572dd6..2ab6b5ec1 100644 --- a/rspack/react-with-sass/rspack.config.js +++ b/rspack/react-with-sass/rspack.config.js @@ -11,6 +11,12 @@ export default defineConfig({ }, module: { rules: [ + { + test: /\.[cm]?[jt]sx?$/, + resolve: { + fullySpecified: false, + }, + }, { test: /\.(?:js|mjs|cjs|jsx)$/, exclude: /node_modules/, diff --git a/rspack/react-with-sass/src/index.jsx b/rspack/react-with-sass/src/index.jsx index 4e92ed510..ce9f0b007 100644 --- a/rspack/react-with-sass/src/index.jsx +++ b/rspack/react-with-sass/src/index.jsx @@ -1,6 +1,6 @@ import ReactDOM from 'react-dom'; import './styles.scss'; -import HelloWorld from './components/hello-world.jsx'; +import HelloWorld from './components/hello-world'; function App() { return ( diff --git a/rspack/react/rspack.config.js b/rspack/react/rspack.config.js index 0aab4fb65..c9dcbfd88 100644 --- a/rspack/react/rspack.config.js +++ b/rspack/react/rspack.config.js @@ -11,6 +11,12 @@ export default defineConfig({ }, module: { rules: [ + { + test: /\.[cm]?[jt]sx?$/, + resolve: { + fullySpecified: false, + }, + }, { test: /\.css$/, type: 'css', diff --git a/rspack/react/src/index.jsx b/rspack/react/src/index.jsx index 87da8bf7f..dac4ede38 100644 --- a/rspack/react/src/index.jsx +++ b/rspack/react/src/index.jsx @@ -1,7 +1,7 @@ import React from 'react'; import ReactDOM from 'react-dom/client'; import './index.css'; -import App from './App.jsx'; +import App from './App'; const root = ReactDOM.createRoot(document.getElementById('root')); root.render( diff --git a/rspack/sentry/rspack.config.js b/rspack/sentry/rspack.config.js index cfefdb1d9..b4e1e1816 100644 --- a/rspack/sentry/rspack.config.js +++ b/rspack/sentry/rspack.config.js @@ -4,6 +4,16 @@ import { rspack } from '@rspack/core'; import { sentryWebpackPlugin } from '@sentry/webpack-plugin'; export default defineConfig({ + module: { + rules: [ + { + test: /\.[cm]?[jt]sx?$/, + resolve: { + fullySpecified: false, + }, + }, + ], + }, entry: './src/index.js', plugins: [ new rspack.HtmlRspackPlugin({ diff --git a/rspack/sentry/src/index.js b/rspack/sentry/src/index.js index 6cde9f2b5..cfbdbfb89 100644 --- a/rspack/sentry/src/index.js +++ b/rspack/sentry/src/index.js @@ -1,4 +1,4 @@ -import { answer } from './answer.js'; +import { answer } from './answer'; function render() { document.getElementById('root').innerHTML = `the answer to the universe is ${answer}`; } diff --git a/rspack/solid/rspack.config.js b/rspack/solid/rspack.config.js index c1ecea448..9d15526e6 100644 --- a/rspack/solid/rspack.config.js +++ b/rspack/solid/rspack.config.js @@ -12,6 +12,12 @@ export default defineConfig({ }, module: { rules: [ + { + test: /\.[cm]?[jt]sx?$/, + resolve: { + fullySpecified: false, + }, + }, { test: /\.css$/, type: 'css', diff --git a/rspack/solid/src/App.jsx b/rspack/solid/src/App.jsx index 9fbc3b84e..f79c152f5 100644 --- a/rspack/solid/src/App.jsx +++ b/rspack/solid/src/App.jsx @@ -1,7 +1,7 @@ import logo from './logo.svg'; import styles from './App.module.css'; import { createSignal } from 'solid-js'; -import Message from './Message.jsx'; +import Message from './Message'; function App() { const [count, setCount] = createSignal(1); const increment = () => setCount(count() + 1); diff --git a/rspack/solid/src/index.jsx b/rspack/solid/src/index.jsx index 053dbf022..27c0e53ad 100644 --- a/rspack/solid/src/index.jsx +++ b/rspack/solid/src/index.jsx @@ -2,6 +2,6 @@ import { render } from 'solid-js/web'; import './index.css'; -import App from './App.jsx'; +import App from './App'; render(() => , document.getElementById('root')); diff --git a/rspack/stats/rspack.config.js b/rspack/stats/rspack.config.js index c5a87a4ac..59cc5b80d 100644 --- a/rspack/stats/rspack.config.js +++ b/rspack/stats/rspack.config.js @@ -33,6 +33,16 @@ class StatsPrinterTestPlugin { } export default defineConfig({ + module: { + rules: [ + { + test: /\.[cm]?[jt]sx?$/, + resolve: { + fullySpecified: false, + }, + }, + ], + }, context: import.meta.dirname, entry: { main: './src/index.js', diff --git a/rspack/stats/src/index.js b/rspack/stats/src/index.js index 6cde9f2b5..cfbdbfb89 100644 --- a/rspack/stats/src/index.js +++ b/rspack/stats/src/index.js @@ -1,4 +1,4 @@ -import { answer } from './answer.js'; +import { answer } from './answer'; function render() { document.getElementById('root').innerHTML = `the answer to the universe is ${answer}`; } diff --git a/rspack/treeshaking-transform-imports/rspack.config.js b/rspack/treeshaking-transform-imports/rspack.config.js index f3e44c00b..d3c7079b0 100644 --- a/rspack/treeshaking-transform-imports/rspack.config.js +++ b/rspack/treeshaking-transform-imports/rspack.config.js @@ -10,6 +10,12 @@ export default defineConfig({ }, module: { rules: [ + { + test: /\.[cm]?[jt]sx?$/, + resolve: { + fullySpecified: false, + }, + }, { test: /\.css$/, type: 'css', diff --git a/rspack/treeshaking-transform-imports/src/a.js b/rspack/treeshaking-transform-imports/src/a.js index 358dbaeac..115ff9df1 100644 --- a/rspack/treeshaking-transform-imports/src/a.js +++ b/rspack/treeshaking-transform-imports/src/a.js @@ -1,2 +1,2 @@ -import { b } from './sdk.js'; +import { b } from './sdk'; export const a = b; diff --git a/rspack/treeshaking-transform-imports/src/index.js b/rspack/treeshaking-transform-imports/src/index.js index 999287a1f..2cfcb9234 100644 --- a/rspack/treeshaking-transform-imports/src/index.js +++ b/rspack/treeshaking-transform-imports/src/index.js @@ -1,2 +1,2 @@ -import { a } from './sdk.js'; +import { a } from './sdk'; console.log(a); diff --git a/rspack/treeshaking-transform-imports/src/sdk.js b/rspack/treeshaking-transform-imports/src/sdk.js index f8a71bd15..c2357812d 100644 --- a/rspack/treeshaking-transform-imports/src/sdk.js +++ b/rspack/treeshaking-transform-imports/src/sdk.js @@ -1,3 +1,3 @@ -export { a } from './a.js'; -export { b } from './b.js'; -export { c } from './c.js'; +export { a } from './a'; +export { b } from './b'; +export { c } from './c'; diff --git a/rspack/vue-jsx/rspack.config.js b/rspack/vue-jsx/rspack.config.js index 70f49968e..3891fad68 100644 --- a/rspack/vue-jsx/rspack.config.js +++ b/rspack/vue-jsx/rspack.config.js @@ -12,6 +12,12 @@ export default defineConfig({ }, module: { rules: [ + { + test: /\.[cm]?[jt]sx?$/, + resolve: { + fullySpecified: false, + }, + }, { test: /\.css$/, type: 'css', diff --git a/rspack/vue-jsx/src/main.jsx b/rspack/vue-jsx/src/main.jsx index 49078b8e5..5ae2eef9f 100644 --- a/rspack/vue-jsx/src/main.jsx +++ b/rspack/vue-jsx/src/main.jsx @@ -1,5 +1,5 @@ import { createApp } from 'vue'; -import App from './App.jsx'; +import App from './App'; import './index.css'; createApp(App).mount('#app'); diff --git a/rspack/wasm-simple/example.js b/rspack/wasm-simple/example.js index 7ffd41d20..59bb5d4fa 100644 --- a/rspack/wasm-simple/example.js +++ b/rspack/wasm-simple/example.js @@ -5,7 +5,7 @@ import { factorialJavascript, fibonacci, fibonacciJavascript, -} from './math.js'; +} from './math'; console.log(add(22, 2200)); console.log(mathAdd(10, 101)); diff --git a/rspack/wasm-simple/rspack.config.js b/rspack/wasm-simple/rspack.config.js index 293f0b825..43de59acf 100644 --- a/rspack/wasm-simple/rspack.config.js +++ b/rspack/wasm-simple/rspack.config.js @@ -3,6 +3,16 @@ import { defineConfig } from '@rspack/cli'; import { rspack } from '@rspack/core'; export default defineConfig({ + module: { + rules: [ + { + test: /\.[cm]?[jt]sx?$/, + resolve: { + fullySpecified: false, + }, + }, + ], + }, entry: { main: './example.js', }, diff --git a/rspack/worker/chat-worker.js b/rspack/worker/chat-worker.js index 0388e1a94..305437a65 100644 --- a/rspack/worker/chat-worker.js +++ b/rspack/worker/chat-worker.js @@ -1,4 +1,4 @@ -import { history, add } from './chat-module.js'; +import { history, add } from './chat-module'; onconnect = function (e) { console.log(e); diff --git a/rspack/worker/example.js b/rspack/worker/example.js index 3fe97a12d..a826dcfe1 100644 --- a/rspack/worker/example.js +++ b/rspack/worker/example.js @@ -71,7 +71,7 @@ chatWorker.port.onmessage = (event) => { fib1.addEventListener('change', async () => { try { const value = parseInt(fib1.value, 10); - const { fibonacci } = await import('./fibonacci.js'); + const { fibonacci } = await import('./fibonacci'); const result = fibonacci(value); output1.innerText = `fib(${value}) = ${result}`; } catch (e) { diff --git a/rspack/worker/fib-worker.js b/rspack/worker/fib-worker.js index 18b51659e..cb5e94615 100644 --- a/rspack/worker/fib-worker.js +++ b/rspack/worker/fib-worker.js @@ -1,5 +1,5 @@ onmessage = async (event) => { - const { fibonacci } = await import('./fibonacci.js'); + const { fibonacci } = await import('./fibonacci'); const value = JSON.parse(event.data); postMessage(`fib(${value}) = ${fibonacci(value)}`); }; diff --git a/rspack/worker/rspack.config.js b/rspack/worker/rspack.config.js index d6064267e..fe96f007c 100644 --- a/rspack/worker/rspack.config.js +++ b/rspack/worker/rspack.config.js @@ -4,6 +4,16 @@ import { defineConfig } from '@rspack/cli'; import { rspack } from '@rspack/core'; export default defineConfig({ + module: { + rules: [ + { + test: /\.[cm]?[jt]sx?$/, + resolve: { + fullySpecified: false, + }, + }, + ], + }, entry: './example.js', context: import.meta.dirname, output: { diff --git a/rspack/worklet/rspack.config.js b/rspack/worklet/rspack.config.js index 9b625eb4f..36f17b47d 100644 --- a/rspack/worklet/rspack.config.js +++ b/rspack/worklet/rspack.config.js @@ -14,6 +14,12 @@ export default defineConfig({ }, module: { rules: [ + { + test: /\.[cm]?[jt]sx?$/, + resolve: { + fullySpecified: false, + }, + }, { resourceQuery: /url/, type: 'asset', diff --git a/rspack/worklet/src/index.js b/rspack/worklet/src/index.js index 783a5b4b4..c46deeee4 100644 --- a/rspack/worklet/src/index.js +++ b/rspack/worklet/src/index.js @@ -1,5 +1,5 @@ -import simpleWorklet from './worklet/simple.worklet.js?url'; -import complexWorklet from './worklet/complex.worklet.js'; +import simpleWorklet from './worklet/simple.worklet?url'; +import complexWorklet from './worklet/complex.worklet'; let context = new AudioContext(); context.audioWorklet.addModule(simpleWorklet).then(() => { diff --git a/rspack/worklet/src/worklet/complex.worklet.js b/rspack/worklet/src/worklet/complex.worklet.js index b7089bdf3..b450ed174 100644 --- a/rspack/worklet/src/worklet/complex.worklet.js +++ b/rspack/worklet/src/worklet/complex.worklet.js @@ -1,4 +1,4 @@ -import { answer } from './answer.ts'; +import { answer } from './answer'; class PortProcessor extends AudioWorkletProcessor { constructor() { super(); From 3538f621210324ca092499d1c26269e0ead8af18 Mon Sep 17 00:00:00 2001 From: neverland Date: Sun, 19 Jul 2026 21:17:32 +0800 Subject: [PATCH 3/3] fix: preserve CommonJS loading for UMD example --- rspack/library-umd/rspack.config.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/rspack/library-umd/rspack.config.js b/rspack/library-umd/rspack.config.js index bd09d20e9..41b24ecac 100644 --- a/rspack/library-umd/rspack.config.js +++ b/rspack/library-umd/rspack.config.js @@ -17,6 +17,8 @@ export default defineConfig({ index: './src/index.js', }, output: { + filename: '[name].cjs', + globalObject: 'globalThis', library: { type: 'umd', name: 'rspack_library',