diff --git a/package.json b/package.json index cb57d6a74c..c57f2d6064 100644 --- a/package.json +++ b/package.json @@ -71,7 +71,8 @@ "packageManager": "pnpm@8.9.2", "pnpm": { "patchedDependencies": { - "@rspack/core@0.5.4": "patches/@rspack__core@0.5.4.patch" + "@rspack/core@0.5.4": "patches/@rspack__core@0.5.4.patch", + "unplugin@1.6.0": "patches/unplugin@1.6.0.patch" } } } diff --git a/packages/bundles/CHANGELOG.md b/packages/bundles/CHANGELOG.md index 6015175edc..3eaf98b64f 100644 --- a/packages/bundles/CHANGELOG.md +++ b/packages/bundles/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## 0.2.5 + +### Patch Changes + +- c404b151: fix: align the transform order and content with webpack mode + ## 0.2.4 ### Patch Changes diff --git a/packages/bundles/package.json b/packages/bundles/package.json index 1adf28689c..2c7c2fc9dc 100644 --- a/packages/bundles/package.json +++ b/packages/bundles/package.json @@ -1,6 +1,6 @@ { "name": "@ice/bundles", - "version": "0.2.4", + "version": "0.2.5", "license": "MIT", "author": "ICE", "description": "Basic dependencies for ice.", diff --git a/packages/ice/CHANGELOG.md b/packages/ice/CHANGELOG.md index 3ac38ddc46..3f0685cd30 100644 --- a/packages/ice/CHANGELOG.md +++ b/packages/ice/CHANGELOG.md @@ -1,5 +1,17 @@ # Changelog +## 3.4.5 + +### Patch Changes + +- b279c880: fix: app config compile error of env exports +- Updated dependencies [c404b151] +- Updated dependencies [21257778] + - @ice/shared-config@1.2.5 + - @ice/bundles@0.2.5 + - @ice/webpack-config@1.1.12 + - @ice/rspack-config@1.1.5 + ## 3.4.4 ### Patch Changes diff --git a/packages/ice/package.json b/packages/ice/package.json index deb13eb416..946e1e7981 100644 --- a/packages/ice/package.json +++ b/packages/ice/package.json @@ -1,6 +1,6 @@ { "name": "@ice/app", - "version": "3.4.4", + "version": "3.4.5", "description": "provide scripts and configuration used by web framework ice", "type": "module", "main": "./esm/index.js", @@ -47,12 +47,12 @@ "bugs": "https://github.com/alibaba/ice/issues", "homepage": "https://v3.ice.work", "dependencies": { - "@ice/bundles": "0.2.4", + "@ice/bundles": "0.2.5", "@ice/route-manifest": "1.2.2", "@ice/runtime": "^1.4.2", - "@ice/shared-config": "1.2.4", - "@ice/webpack-config": "1.1.11", - "@ice/rspack-config": "1.1.4", + "@ice/shared-config": "1.2.5", + "@ice/webpack-config": "1.1.12", + "@ice/rspack-config": "1.1.5", "@swc/helpers": "0.5.1", "@types/express": "^4.17.14", "address": "^1.1.2", diff --git a/packages/ice/src/service/config.ts b/packages/ice/src/service/config.ts index 95e4feda77..822ad4584c 100644 --- a/packages/ice/src/service/config.ts +++ b/packages/ice/src/service/config.ts @@ -136,8 +136,11 @@ export const getAppExportConfig = (rootDir: string) => { const config = new Config({ entry: appEntry, rootDir, - // Only remove top level code for src/app. - transformInclude: (id) => id.includes('src/app') || id.includes('.ice'), + transformInclude: (id) => { + // Only remove top level code for src/app and runtime code in .ice, + // env.ts should not be include otherwise it will cause compile error of env variable export. + return id.includes('src/app') || (id.includes('.ice') && !id.includes('env.ts')); + }, getOutfile, needRecompile: async (entry, keepExports) => { const cachedKey = `app_${keepExports.join('_')}_${process.env.__ICE_VERSION__}`; diff --git a/packages/plugin-fusion/CHANGELOG.md b/packages/plugin-fusion/CHANGELOG.md index e4771752b5..9952f11313 100644 --- a/packages/plugin-fusion/CHANGELOG.md +++ b/packages/plugin-fusion/CHANGELOG.md @@ -1,5 +1,16 @@ # Changelog +## 1.1.0 + +### Minor Changes + +- 79c32a77: feat: optimize function theme injection + +### Patch Changes + +- Updated dependencies [79c32a77] + - @ice/style-import@1.1.0 + ## 1.0.5 ### Patch Changes diff --git a/packages/plugin-fusion/package.json b/packages/plugin-fusion/package.json index d290dec8c8..27a4905680 100644 --- a/packages/plugin-fusion/package.json +++ b/packages/plugin-fusion/package.json @@ -1,6 +1,6 @@ { "name": "@ice/plugin-fusion", - "version": "1.0.5", + "version": "1.1.0", "description": "plugin for ICE while use fusion component", "license": "MIT", "type": "module", @@ -11,10 +11,10 @@ "!esm/**/*.map" ], "dependencies": { - "@ice/style-import": "^1.0.1" + "@ice/style-import": "^1.1.0" }, "devDependencies": { - "@ice/app": "^3.3.4" + "@ice/app": "^3.4.5" }, "repository": { "type": "http", diff --git a/packages/plugin-fusion/src/index.ts b/packages/plugin-fusion/src/index.ts index 1f72d7fddc..7fa04b7d8b 100644 --- a/packages/plugin-fusion/src/index.ts +++ b/packages/plugin-fusion/src/index.ts @@ -32,37 +32,9 @@ function getVariablesPath({ return formatPath(filePath); } -function importIcon(iconPath: string, cssPrefix: string) { - let entryFile = ''; - return { - name: 'transform-import-icon', - enforce: 'pre', - transformInclude(id: string) { - // Only transform source code and icon file. - return (id.match(/\.(js|jsx|ts|tsx)$/) && !id.match(/node_modules/)) || iconPath === formatPath(id); - }, - async transform(code: string, id: string, options: { isServer: boolean }) { - const { isServer } = options; - // Only import icon scss in client - if (!isServer) { - // Icon just import once. - if (!entryFile) { - entryFile = id; - } - if (id === entryFile) { - return `import '${iconPath}';\n${code}`; - } else if (formatPath(id) === iconPath) { - // Default cssPrefix for icon.scss. - return `$css-prefix: '${cssPrefix}';\n${code}`; - } - } - }, - }; -} - const plugin: Plugin = (options = {}) => ({ name: '@ice/plugin-fusion', - setup: ({ onGetConfig, createLogger }) => { + setup: ({ onGetConfig, createLogger, generator }) => { const { theme, themePackage, importStyle } = options; if (importStyle) { onGetConfig((config) => { @@ -73,16 +45,18 @@ const plugin: Plugin = (options = {}) => ({ }); } if (theme || themePackage) { - onGetConfig((config) => { - // Try to get icon.scss if exists. - const iconFile = getVariablesPath({ - packageName: themePackage, - filename: 'icons.scss', - silent: true, + // Try to get icon.scss if exists. + const iconFile = getVariablesPath({ + packageName: themePackage, + filename: 'icons.scss', + silent: true, + }); + if (iconFile) { + generator.addEntryImportAhead({ + source: iconFile, }); - if (iconFile) { - config.transformPlugins = [...(config.transformPlugins || []), importIcon(iconFile, theme?.['css-prefix'] || 'next-')]; - } + } + onGetConfig((config) => { // Modify webpack config of scss rule for fusion theme. config.configureWebpack ??= []; config.configureWebpack.push((webpackConfig) => { @@ -90,8 +64,8 @@ const plugin: Plugin = (options = {}) => ({ let sassLoader = null; rules.some((rule) => { if (typeof rule === 'object' && - rule.test instanceof RegExp && - rule?.test?.source?.match(/scss/)) { + rule.test instanceof RegExp && + rule?.test?.source?.match(/scss/)) { sassLoader = Array.isArray(rule?.use) && rule.use.find((use) => typeof use === 'object' && use.loader.includes('sass-loader')); return true; @@ -99,7 +73,9 @@ const plugin: Plugin = (options = {}) => ({ return false; }); if (sassLoader) { - const additionalContent = []; + const additionalContent = [ + `$css-prefix: '${theme?.['css-prefix'] || 'next-'}' !default;`, + ]; if (themePackage) { const themeFile = getVariablesPath({ packageName: themePackage, diff --git a/packages/plugin-i18n/package.json b/packages/plugin-i18n/package.json index 5b0d908bbe..722e1f7c76 100644 --- a/packages/plugin-i18n/package.json +++ b/packages/plugin-i18n/package.json @@ -56,7 +56,7 @@ "webpack-dev-server": "4.15.0" }, "peerDependencies": { - "@ice/app": "^3.4.4", + "@ice/app": "^3.4.5", "@ice/runtime": "^1.4.2" }, "publishConfig": { diff --git a/packages/rspack-config/CHANGELOG.md b/packages/rspack-config/CHANGELOG.md index 94c51246f4..174c2e90b1 100644 --- a/packages/rspack-config/CHANGELOG.md +++ b/packages/rspack-config/CHANGELOG.md @@ -1,5 +1,15 @@ # @ice/rspack-config +## 1.1.5 + +### Patch Changes + +- 21257778: fix: imporve dev sourcemap +- Updated dependencies [c404b151] +- Updated dependencies [21257778] + - @ice/shared-config@1.2.5 + - @ice/bundles@0.2.5 + ## 1.1.4 ### Patch Changes diff --git a/packages/rspack-config/package.json b/packages/rspack-config/package.json index a6937aa0d8..991ecfa968 100644 --- a/packages/rspack-config/package.json +++ b/packages/rspack-config/package.json @@ -1,6 +1,6 @@ { "name": "@ice/rspack-config", - "version": "1.1.4", + "version": "1.1.5", "repository": "alibaba/ice", "bugs": "https://github.com/alibaba/ice/issues", "homepage": "https://v3.ice.work", @@ -15,8 +15,8 @@ "*.d.ts" ], "dependencies": { - "@ice/bundles": "0.2.4", - "@ice/shared-config": "1.2.4" + "@ice/bundles": "0.2.5", + "@ice/shared-config": "1.2.5" }, "devDependencies": { "@rspack/core": "0.5.4" diff --git a/packages/rspack-config/src/index.ts b/packages/rspack-config/src/index.ts index 7a8e47bb72..58c819674e 100644 --- a/packages/rspack-config/src/index.ts +++ b/packages/rspack-config/src/index.ts @@ -1,6 +1,6 @@ import * as path from 'path'; import { createRequire } from 'module'; -import { getDefineVars, getCompilerPlugins, getJsxTransformOptions, getAliasWithRoot, skipCompilePackages } from '@ice/shared-config'; +import { getDefineVars, getCompilerPlugins, getJsxTransformOptions, getAliasWithRoot, skipCompilePackages, getDevtoolValue } from '@ice/shared-config'; import type { Config, ModifyWebpackConfig } from '@ice/shared-config/types'; import type { Configuration, rspack as Rspack } from '@rspack/core'; import lodash from '@ice/bundles/compiled/lodash/index.js'; @@ -71,6 +71,7 @@ const getConfig: GetConfig = async (options) => { configureWebpack = [], minimizerOptions = {}, optimizePackageImports = [], + sourceMap, } = taskConfig || {}; const isDev = mode === 'development'; const absoluteOutputDir = path.isAbsolute(outputDir) ? outputDir : path.join(rootDir, outputDir); @@ -151,8 +152,6 @@ const getConfig: GetConfig = async (options) => { rules: [ { test: /\.(jsx?|tsx?|mjs)$/, - // Set enforce: 'post' to make sure the compilation-loader is executed after other transformers. - enforce: 'post', ...(excludeRule ? { exclude: new RegExp(excludeRule) } : {}), use: { loader: 'builtin:compilation-loader', @@ -232,6 +231,7 @@ const getConfig: GetConfig = async (options) => { infrastructureLogging: { level: 'warn', }, + devtool: getDevtoolValue(sourceMap), devServer: { allowedHosts: 'all', headers: { diff --git a/packages/shared-config/CHANGELOG.md b/packages/shared-config/CHANGELOG.md index 698953b242..d134ee6c69 100644 --- a/packages/shared-config/CHANGELOG.md +++ b/packages/shared-config/CHANGELOG.md @@ -1,5 +1,14 @@ # @ice/shared-config +## 1.2.5 + +### Patch Changes + +- c404b151: fix: align the transform order and content with webpack mode +- 21257778: fix: imporve dev sourcemap +- Updated dependencies [c404b151] + - @ice/bundles@0.2.5 + ## 1.2.4 ### Patch Changes diff --git a/packages/shared-config/package.json b/packages/shared-config/package.json index 185677ddbd..c4174969aa 100644 --- a/packages/shared-config/package.json +++ b/packages/shared-config/package.json @@ -1,6 +1,6 @@ { "name": "@ice/shared-config", - "version": "1.2.4", + "version": "1.2.5", "repository": "alibaba/ice", "bugs": "https://github.com/alibaba/ice/issues", "homepage": "https://v3.ice.work", @@ -17,7 +17,7 @@ "*.d.ts" ], "dependencies": { - "@ice/bundles": "0.2.4", + "@ice/bundles": "0.2.5", "@rollup/pluginutils": "^4.2.0", "browserslist": "^4.22.1", "consola": "^2.15.3", diff --git a/packages/shared-config/src/getCompilerPlugins.ts b/packages/shared-config/src/getCompilerPlugins.ts index 3e4706321b..680832bb3a 100644 --- a/packages/shared-config/src/getCompilerPlugins.ts +++ b/packages/shared-config/src/getCompilerPlugins.ts @@ -89,8 +89,10 @@ function getCompilerPlugins(rootDir: string, config: Config, compiler: Compiler, })); } if (clientBundlers.includes(compiler)) { - return compilerPlugins + const transformPlugins = compilerPlugins .map((plugin) => createUnplugin(() => getPluginTransform(plugin, transformOptions))[compiler]()) as Config['plugins']; + // Reverse the transformPlugins for rspack, because the unplugin order has been change in rspack mode. + return compiler === 'rspack' ? transformPlugins.reverse() : transformPlugins; } else { return compilerPlugins.map(plugin => getPluginTransform(plugin, transformOptions)); } diff --git a/packages/shared-config/src/index.ts b/packages/shared-config/src/index.ts index a0789a3022..ed9d952343 100644 --- a/packages/shared-config/src/index.ts +++ b/packages/shared-config/src/index.ts @@ -5,6 +5,7 @@ import getDefineVars from './getDefineVars.js'; import getPostcssOpts from './getPostcssOpts.js'; import getCSSModuleLocalIdent from './getCSSModuleLocalIdent.js'; import getAliasWithRoot from './getAlias.js'; +import getDevtoolValue from './utils/getDevtool.js'; export { getCSSModuleLocalIdent, @@ -17,4 +18,5 @@ export { getDefineVars, getPostcssOpts, getAliasWithRoot, + getDevtoolValue, }; diff --git a/packages/shared-config/src/utils/getDevtool.ts b/packages/shared-config/src/utils/getDevtool.ts new file mode 100644 index 0000000000..623345a655 --- /dev/null +++ b/packages/shared-config/src/utils/getDevtool.ts @@ -0,0 +1,16 @@ +import type { Config } from '../types'; + +interface GetDevtoolOptions { + (sourceMap: Config['sourceMap']): T; +} + +const getDevtoolValue: GetDevtoolOptions = (sourceMap) => { + if (typeof sourceMap === 'string') { + return sourceMap; + } else if (sourceMap === false) { + return false; + } + return 'source-map'; +}; + +export default getDevtoolValue; diff --git a/packages/style-import/CHANGELOG.md b/packages/style-import/CHANGELOG.md index f954379113..a227ca339d 100644 --- a/packages/style-import/CHANGELOG.md +++ b/packages/style-import/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## 1.1.0 + +### Minor Changes + +- 79c32a77: feat: optimize function theme injection + ## 1.0.1 ### Patch Changes diff --git a/packages/style-import/package.json b/packages/style-import/package.json index b4abd3dced..acb1760a46 100644 --- a/packages/style-import/package.json +++ b/packages/style-import/package.json @@ -1,6 +1,6 @@ { "name": "@ice/style-import", - "version": "1.0.1", + "version": "1.1.0", "description": "automatic import style by transform code", "type": "module", "scripts": { @@ -16,7 +16,7 @@ "url": "https://github.com/alibaba/ice/tree/master/packages/transform-import" }, "dependencies": { - "es-module-lexer": "^1.0.2", + "rs-module-lexer": "^2.3.0", "magic-string": "^0.27.0" }, "publishConfig": { diff --git a/packages/style-import/src/index.ts b/packages/style-import/src/index.ts index b7946c422d..868ae47a9b 100644 --- a/packages/style-import/src/index.ts +++ b/packages/style-import/src/index.ts @@ -1,6 +1,8 @@ -import { init, parse } from 'es-module-lexer'; +import pkg from 'rs-module-lexer'; import MagicString from 'magic-string'; -import type { ImportSpecifier, ExportSpecifier } from 'es-module-lexer'; +import type { ImportSpecifier, ExportSpecifier } from 'rs-module-lexer'; + +const { parseAsync, parse } = pkg; interface TransformOptions { libraryName: string; @@ -9,7 +11,7 @@ interface TransformOptions { kebabCase?: Boolean; } -export async function importStyle(code: string, options: TransformOptions): Promise; }> { @@ -17,18 +19,23 @@ export async function importStyle(code: string, options: TransformOptions): Prom if (!style) { return null; } - await init; let imports: readonly ImportSpecifier[] = []; try { - imports = parse(code)[0]; + const { output } = await parseAsync({ + input: [{ + code, + filename: id, + }], + }); + imports = output[0].imports; } catch (e) { console.log(e); return null; } - if (!imports.length) { return null; } + let s: MagicString | undefined; const str = () => s || (s = new MagicString(code)); imports.forEach(({ n, se, ss }) => { @@ -38,9 +45,20 @@ export async function importStyle(code: string, options: TransformOptions): Prom // Get specifiers by export statement (es-module-lexer can analyze name exported). if (importStr) { const exportSource = importStr.replace('import ', 'export ').replace(/\s+as\s+\w+,?/g, ','); + // Namespace export is not supported. + if (exportSource.includes('*')) { + return; + } let exports: ExportSpecifier[] = []; try { - exports = parse(exportSource)[1]; + const { output } = parse({ + input: [{ + // Use static filename to mark the source is written by js. + filename: 'export.js', + code: exportSource, + }], + }); + exports = output[0].exports; } catch (e) { console.log(`error occur when analyze code: ${importStr}`); console.log(e); @@ -89,7 +107,7 @@ export default function importStylePlugin(options: TransformOptions) { if (transformOption.isServer || !code) { return null; } - return await importStyle(code, options); + return await importStyle(code, id, options); }, }; } diff --git a/packages/style-import/tests/importStyle.test.ts b/packages/style-import/tests/importStyle.test.ts index ae7dec83ac..927b44292c 100644 --- a/packages/style-import/tests/importStyle.test.ts +++ b/packages/style-import/tests/importStyle.test.ts @@ -4,58 +4,59 @@ import { importStyle } from '../src/index'; describe('import style', () => { it('simple import', async () => { const sourceCode = 'import { Button } from \'antd\';'; - const result = await importStyle(sourceCode, { libraryName: 'antd', style: true }); + const result = await importStyle(sourceCode, 'index.js', { libraryName: 'antd', style: true }); expect(result?.code).toBe(`${sourceCode}\nimport 'antd/es/button/style';`); }); it('custom style', async () => { const sourceCode = 'import { Button } from \'antd\';'; - const result = await importStyle(sourceCode, { libraryName: 'antd', style: (name) => `antd/es/${name.toLocaleLowerCase()}/style` }); + const result = await importStyle(sourceCode, 'index.ts', { libraryName: 'antd', style: (name) => `antd/es/${name.toLocaleLowerCase()}/style` }); expect(result?.code).toBe(`${sourceCode}\nimport 'antd/es/button/style';`); }); it('mismatch import', async () => { const sourceCode = 'import { Button } from \'antd-mobile\';'; - const result = await importStyle(sourceCode, { libraryName: 'antd', style: true }); + const result = await importStyle(sourceCode, 'index.js', { libraryName: 'antd', style: true }); expect(result?.code).toBe(`${sourceCode}`); }); it('multiple import', async () => { const sourceCode = 'import { Button, Table } from \'antd\';'; - const result = await importStyle(sourceCode, { libraryName: 'antd', style: true }); + const result = await importStyle(sourceCode, 'index.js', { libraryName: 'antd', style: true }); expect(result?.code).toBe(`${sourceCode}\nimport 'antd/es/button/style';\nimport 'antd/es/table/style';`); }); it('named import', async () => { const sourceCode = 'import { Button as Btn } from \'antd\';'; - const result = await importStyle(sourceCode, { libraryName: 'antd', style: true }); + const result = await importStyle(sourceCode, 'index.js', { libraryName: 'antd', style: true }); expect(result?.code).toBe(`${sourceCode}\nimport 'antd/es/button/style';`); }); it('default import', async () => { const sourceCode = 'import * as antd from \'antd\';'; - const result = await importStyle(sourceCode, { libraryName: 'antd', style: true }); + const result = await importStyle(sourceCode, 'index.js', { libraryName: 'antd', style: true }); expect(result?.code).toBe(`${sourceCode}`); }); it('sourcemap', async () => { const sourceCode = 'import * as antd from \'antd\';'; - const result = await importStyle(sourceCode, { libraryName: 'antd', style: true, sourceMap: true }); + const result = await importStyle(sourceCode, 'index.js', { libraryName: 'antd', style: true, sourceMap: true }); expect(!!result?.map).toBe(true); }); it('none import', async () => { const sourceCode = 'export const a = \'antd\';'; - const result = await importStyle(sourceCode, { libraryName: 'antd', style: true }); + const result = await importStyle(sourceCode, 'index.js', { libraryName: 'antd', style: true }); expect(result).toBe(null); }); - it('parse error', async () => { + it('parse export', async () => { const sourceCode = 'export antd, { Button } from \'antd\';'; - const result = await importStyle(sourceCode, { libraryName: 'antd', style: true }); - expect(result).toBe(null); + const result = await importStyle(sourceCode, 'index.js', { libraryName: 'antd', style: true }); + expect(result?.code).toBe(`${sourceCode}\nimport 'antd/es/button/style';`); }); - it('import error', async () => { + + it('mixed import', async () => { const sourceCode = 'import antd, { Button } from \'antd\';'; - const result = await importStyle(sourceCode, { libraryName: 'antd', style: true }); - expect(result?.code).toBe(sourceCode); + const result = await importStyle(sourceCode, 'index.js', { libraryName: 'antd', style: true }); + expect(result?.code).toBe(`${sourceCode}\nimport 'antd/es/button/style';`); }); it('style false', async () => { const sourceCode = 'import { Button } from \'antd\';'; - const result = await importStyle(sourceCode, { libraryName: 'antd', style: false }); + const result = await importStyle(sourceCode, 'index.js', { libraryName: 'antd', style: false }); expect(result).toBe(null); }); }); diff --git a/packages/webpack-config/CHANGELOG.md b/packages/webpack-config/CHANGELOG.md index 80ed27a7fd..2e555083c6 100644 --- a/packages/webpack-config/CHANGELOG.md +++ b/packages/webpack-config/CHANGELOG.md @@ -1,5 +1,15 @@ # Changelog +## 1.1.12 + +### Patch Changes + +- 21257778: fix: imporve dev sourcemap +- Updated dependencies [c404b151] +- Updated dependencies [21257778] + - @ice/shared-config@1.2.5 + - @ice/bundles@0.2.5 + ## 1.1.11 ### Patch Changes diff --git a/packages/webpack-config/package.json b/packages/webpack-config/package.json index 885f554ce3..47c171fb76 100644 --- a/packages/webpack-config/package.json +++ b/packages/webpack-config/package.json @@ -1,6 +1,6 @@ { "name": "@ice/webpack-config", - "version": "1.1.11", + "version": "1.1.12", "repository": "alibaba/ice", "bugs": "https://github.com/alibaba/ice/issues", "homepage": "https://v3.ice.work", @@ -15,8 +15,8 @@ "*.d.ts" ], "dependencies": { - "@ice/shared-config": "1.2.4", - "@ice/bundles": "0.2.4", + "@ice/shared-config": "1.2.5", + "@ice/bundles": "0.2.5", "fast-glob": "^3.2.11", "process": "^0.11.10" }, diff --git a/packages/webpack-config/src/index.ts b/packages/webpack-config/src/index.ts index b6ee1e705d..dd187bda1b 100644 --- a/packages/webpack-config/src/index.ts +++ b/packages/webpack-config/src/index.ts @@ -11,7 +11,7 @@ import ESlintPlugin from '@ice/bundles/compiled/eslint-webpack-plugin/index.js'; import CopyPlugin from '@ice/bundles/compiled/copy-webpack-plugin/index.js'; import type { NormalModule, Compiler, Configuration } from 'webpack'; import type webpack from 'webpack'; -import { compilationPlugin, compileExcludes, getCompilerPlugins, getDefineVars, getAliasWithRoot } from '@ice/shared-config'; +import { compilationPlugin, compileExcludes, getCompilerPlugins, getDefineVars, getAliasWithRoot, getDevtoolValue } from '@ice/shared-config'; import type { Config, ModifyWebpackConfig } from '@ice/shared-config/types.js'; import configAssets from './config/assets.js'; import configCss from './config/css.js'; @@ -427,12 +427,3 @@ export function getWebpackConfig(options: GetWebpackConfigOptions): Configuratio .reduce((result, next: ModifyWebpackConfig) => next(result, ctx), webpackConfig); } -function getDevtoolValue(sourceMap: Config['sourceMap']) { - if (typeof sourceMap === 'string') { - return sourceMap; - } else if (sourceMap === false) { - return false; - } - - return 'source-map'; -} diff --git a/patches/unplugin@1.6.0.patch b/patches/unplugin@1.6.0.patch new file mode 100644 index 0000000000..4562818e72 --- /dev/null +++ b/patches/unplugin@1.6.0.patch @@ -0,0 +1,44 @@ +diff --git a/dist/index.js b/dist/index.js +index 631e1459fbcb948d5089ae5432350c91d9853b5c..00cd831ddaf72e181f6260a99ce40e3ee5220f59 100644 +--- a/dist/index.js ++++ b/dist/index.js +@@ -1535,7 +1535,7 @@ function getRspackPlugin(factory) { + }); + const externalModules = /* @__PURE__ */ new Set(); + if (plugin.load) { +- compiler.options.module.rules.unshift({ ++ compiler.options.module.rules.push({ + enforce: plugin.enforce, + include(id) { + return shouldLoad(id, plugin, externalModules); +@@ -1549,7 +1549,7 @@ function getRspackPlugin(factory) { + }); + } + if (plugin.transform) { +- compiler.options.module.rules.unshift({ ++ compiler.options.module.rules.push({ + enforce: plugin.enforce, + use(data) { + return transformUse(data, plugin, TRANSFORM_LOADER); +diff --git a/dist/index.mjs b/dist/index.mjs +index bca4a4f9ccf06032f8e8af17ec12307c9176b440..5be1848ae866cb181c486b59ecdbf26921b5e5c8 100644 +--- a/dist/index.mjs ++++ b/dist/index.mjs +@@ -1501,7 +1501,7 @@ function getRspackPlugin(factory) { + }); + const externalModules = /* @__PURE__ */ new Set(); + if (plugin.load) { +- compiler.options.module.rules.unshift({ ++ compiler.options.module.rules.push({ + enforce: plugin.enforce, + include(id) { + return shouldLoad(id, plugin, externalModules); +@@ -1515,7 +1515,7 @@ function getRspackPlugin(factory) { + }); + } + if (plugin.transform) { +- compiler.options.module.rules.unshift({ ++ compiler.options.module.rules.push({ + enforce: plugin.enforce, + use(data) { + return transformUse(data, plugin, TRANSFORM_LOADER); diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 071cd407e1..991e6096a0 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -8,6 +8,9 @@ patchedDependencies: '@rspack/core@0.5.4': hash: cx7wc7uikmrb5dsrfcy5wrjzui path: patches/@rspack__core@0.5.4.patch + unplugin@1.6.0: + hash: z2z7uvjbiarznogeja262ejlha + path: patches/unplugin@1.6.0.patch importers: @@ -1561,7 +1564,7 @@ importers: version: 4.9.5 unplugin: specifier: 1.6.0 - version: 1.6.0 + version: 1.6.0(patch_hash=z2z7uvjbiarznogeja262ejlha) webpack: specifier: 5.88.2 version: 5.88.2(@swc/core@1.3.80)(esbuild@0.17.16) @@ -1619,22 +1622,22 @@ importers: packages/ice: dependencies: '@ice/bundles': - specifier: 0.2.4 + specifier: 0.2.5 version: link:../bundles '@ice/route-manifest': specifier: 1.2.2 version: link:../route-manifest '@ice/rspack-config': - specifier: 1.1.4 + specifier: 1.1.5 version: link:../rspack-config '@ice/runtime': specifier: ^1.4.2 version: link:../runtime '@ice/shared-config': - specifier: 1.2.4 + specifier: 1.2.5 version: link:../shared-config '@ice/webpack-config': - specifier: 1.1.11 + specifier: 1.1.12 version: link:../webpack-config '@swc/helpers': specifier: 0.5.1 @@ -1768,7 +1771,7 @@ importers: version: 1.50.0 unplugin: specifier: ^1.6.0 - version: 1.6.0 + version: 1.6.0(patch_hash=z2z7uvjbiarznogeja262ejlha) webpack: specifier: ^5.88.0 version: 5.88.2(esbuild@0.17.16) @@ -1924,11 +1927,11 @@ importers: packages/plugin-fusion: dependencies: '@ice/style-import': - specifier: ^1.0.1 + specifier: ^1.1.0 version: link:../style-import devDependencies: '@ice/app': - specifier: ^3.3.4 + specifier: ^3.4.5 version: link:../ice packages/plugin-i18n: @@ -2304,10 +2307,10 @@ importers: packages/rspack-config: dependencies: '@ice/bundles': - specifier: 0.2.4 + specifier: 0.2.5 version: link:../bundles '@ice/shared-config': - specifier: 1.2.4 + specifier: 1.2.5 version: link:../shared-config devDependencies: '@rspack/core': @@ -2378,7 +2381,7 @@ importers: packages/shared-config: dependencies: '@ice/bundles': - specifier: 0.2.4 + specifier: 0.2.5 version: link:../bundles '@rollup/pluginutils': specifier: ^4.2.0 @@ -2411,20 +2414,20 @@ importers: packages/style-import: dependencies: - es-module-lexer: - specifier: ^1.0.2 - version: 1.2.0 magic-string: specifier: ^0.27.0 version: 0.27.0 + rs-module-lexer: + specifier: ^2.3.0 + version: 2.3.0 packages/webpack-config: dependencies: '@ice/bundles': - specifier: 0.2.4 + specifier: 0.2.5 version: link:../bundles '@ice/shared-config': - specifier: 1.2.4 + specifier: 1.2.5 version: link:../shared-config fast-glob: specifier: ^3.2.11 @@ -9435,6 +9438,87 @@ packages: '@webassemblyjs/ast': 1.11.5 '@xtuc/long': 4.2.2 + /@xn-sakina/rml-darwin-arm64@2.3.0: + resolution: {integrity: sha512-3CxaA3NRBo6pd9i6Ih5FL+3qmCrYt4nlc1dAw+VhvyUImkSt1tt9WVvm955i2YJVEjQydgsE+U1xhxKJnFa8Hg==} + engines: {node: '>=14'} + cpu: [arm64] + os: [darwin] + requiresBuild: true + dev: false + optional: true + + /@xn-sakina/rml-darwin-x64@2.3.0: + resolution: {integrity: sha512-law6NEW5kaBnn9Ic2/SzLMlHRQcwYrVhKRKU0H/nC/60DFURe6ZKnhNgJAuS1SyU26oEHH6VR7NOvlSEcVWrEg==} + engines: {node: '>=14'} + cpu: [x64] + os: [darwin] + requiresBuild: true + dev: false + optional: true + + /@xn-sakina/rml-linux-arm-gnueabihf@2.3.0: + resolution: {integrity: sha512-/fshahvO2ma/NXbOZQXgJDd6nq7IcvvCP6twTtIr4l7KffJ1DeNdvarrD0Hrco5SAZX2qrq/0Z3RzJtsQ/8INQ==} + engines: {node: '>=14'} + cpu: [arm] + os: [linux] + requiresBuild: true + dev: false + optional: true + + /@xn-sakina/rml-linux-arm64-gnu@2.3.0: + resolution: {integrity: sha512-0/XEPfqvSvFImL+yvTcpNJz12vH5Dit19TSC0scGHL5CrwEOCDwrYrBLMLuPJVqroW7AFM+PRTg6p4GCUdY1Cw==} + engines: {node: '>=14'} + cpu: [arm64] + os: [linux] + requiresBuild: true + dev: false + optional: true + + /@xn-sakina/rml-linux-arm64-musl@2.3.0: + resolution: {integrity: sha512-kN9LyssC5HhM36bCWoASB7ECupA3Vpow6kFW6jURyT9p+UXcQzTtkKLQ/2OpRdom/eUNSabYuRmdyxGTJ2XIcw==} + engines: {node: '>=14'} + cpu: [arm64] + os: [linux] + requiresBuild: true + dev: false + optional: true + + /@xn-sakina/rml-linux-x64-gnu@2.3.0: + resolution: {integrity: sha512-XFPAqrIHseL8xA4eCNYcTCp6iSst3SnxcPHiKSezHquJdCSm8m0SRzUqJxMPQUULmM2EL5zHtswbbAb7t+AS3g==} + engines: {node: '>=14'} + cpu: [x64] + os: [linux] + requiresBuild: true + dev: false + optional: true + + /@xn-sakina/rml-linux-x64-musl@2.3.0: + resolution: {integrity: sha512-xLbOW1iDTz6fAN5rnGMclRNH1aBagDjrkApWhZ/5wQUaoi5r4ovAJWWAGqxDZlYi2lzpPSzlgKaD4ZlokC7r+A==} + engines: {node: '>=14'} + cpu: [x64] + os: [linux] + requiresBuild: true + dev: false + optional: true + + /@xn-sakina/rml-win32-arm64-msvc@2.3.0: + resolution: {integrity: sha512-gwUV/Kr/Kkg060OBzzhP8ji7kJq1EG3OKhNXqfOlpIQHU4aHq/xKtVEEFu8KlarhgK9oTyjzM+80yMc0XSwtUg==} + engines: {node: '>=14'} + cpu: [arm64] + os: [win32] + requiresBuild: true + dev: false + optional: true + + /@xn-sakina/rml-win32-x64-msvc@2.3.0: + resolution: {integrity: sha512-iJZOAKiMQIVPZ+0QN4sZgo0RewmJu01sSLsHUajc3bTB1EMspZODIRgOli0PjLjWh5WvJ3T230xD9VOaXZ0I8g==} + engines: {node: '>=14'} + cpu: [x64] + os: [win32] + requiresBuild: true + dev: false + optional: true + /@xtuc/ieee754@1.2.0: resolution: {integrity: sha512-DX8nKgqcGwsc0eJSqYt5lwP4DH5FlHnmuWWBRy7X0NcaGR0ZtuyeESgMwTYVEtxmsNGY+qit4QYT/MIYTOTPeA==} @@ -12468,10 +12552,6 @@ packages: resolution: {integrity: sha512-+7IwY/kiGAacQfY+YBhKMvEmyAJnw5grTUgjG85Pe7vcUI/6b7pZjZG8nQ7+48YhzEAEqrEgD2dCz/JIK+AYvw==} dev: true - /es-module-lexer@1.2.0: - resolution: {integrity: sha512-2BMfqBDeVCcOlLaL1ZAfp+D868SczNpKArrTM3dhpd7dK/OVlogzY15qpUngt+LMTq5UC/csb9vVQAgupucSbA==} - dev: false - /es-module-lexer@1.2.1: resolution: {integrity: sha512-9978wrXM50Y4rTMmW5kXIC09ZdXQZqkE4mxhwkd8VbzsGkXGPgV4zWuqQJgCEzYngdo2dYDa0l8xhX4fkSwJSg==} @@ -20574,6 +20654,22 @@ packages: fsevents: 2.3.2 dev: true + /rs-module-lexer@2.3.0: + resolution: {integrity: sha512-Ap6ez0EupuGKoohMq1yClBcGRjivQnemFeR0aIYWjyYT1n8HOywYYi0WUz3bzLVSwAKE4OhFHPDr6LiqHGwwvQ==} + engines: {node: '>=14'} + requiresBuild: true + optionalDependencies: + '@xn-sakina/rml-darwin-arm64': 2.3.0 + '@xn-sakina/rml-darwin-x64': 2.3.0 + '@xn-sakina/rml-linux-arm-gnueabihf': 2.3.0 + '@xn-sakina/rml-linux-arm64-gnu': 2.3.0 + '@xn-sakina/rml-linux-arm64-musl': 2.3.0 + '@xn-sakina/rml-linux-x64-gnu': 2.3.0 + '@xn-sakina/rml-linux-x64-musl': 2.3.0 + '@xn-sakina/rml-win32-arm64-msvc': 2.3.0 + '@xn-sakina/rml-win32-x64-msvc': 2.3.0 + dev: false + /rtl-detect@1.0.4: resolution: {integrity: sha512-EBR4I2VDSSYr7PkBmFy04uhycIpDKp+21p/jARYXlCSjQksTBQcJ0HFUPOO79EPPH5JS6VAhiIQbycf0O3JAxQ==} @@ -22550,7 +22646,7 @@ packages: resolution: {integrity: sha512-pjy2bYhSsufwWlKwPc+l3cN7+wuJlK6uz0YdJEOlQDbl6jo/YlPi4mb8agUkVC8BF7V8NuzeyPNqRksA3hztKQ==} engines: {node: '>= 0.8'} - /unplugin@1.6.0: + /unplugin@1.6.0(patch_hash=z2z7uvjbiarznogeja262ejlha): resolution: {integrity: sha512-BfJEpWBu3aE/AyHx8VaNE/WgouoQxgH9baAiH82JjX8cqVyi3uJQstqwD5J+SZxIK326SZIhsSZlALXVBCknTQ==} dependencies: acorn: 8.11.2 @@ -22558,6 +22654,7 @@ packages: webpack-sources: 3.2.3 webpack-virtual-modules: 0.6.1 dev: true + patched: true /unquote@1.1.1: resolution: {integrity: sha512-vRCqFv6UhXpWxZPyGDh/F3ZpNv8/qo7w6iufLpQg9aKnQ71qM4B5KiI7Mia9COcjEhrO9LueHpMYjYzsWH3OIg==}