mirror of https://github.com/alibaba/ice.git
fix: several bug when bump pack dependencies (#6689)
* fix: serveral bug when bump dependencies * fix: compile error * chore: bump version
This commit is contained in:
parent
a68ff48d8e
commit
7d193fe96b
|
|
@ -0,0 +1,6 @@
|
||||||
|
---
|
||||||
|
'@ice/rspack-config': patch
|
||||||
|
'@ice/app': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
fix: css module hash and HMR
|
||||||
|
|
@ -0,0 +1,6 @@
|
||||||
|
---
|
||||||
|
'@ice/webpack-config': patch
|
||||||
|
'@ice/shared-config': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
fix: optimize utils
|
||||||
|
|
@ -45,7 +45,7 @@
|
||||||
"zod": "^3.21.4",
|
"zod": "^3.21.4",
|
||||||
"zod-validation-error": "1.2.0",
|
"zod-validation-error": "1.2.0",
|
||||||
"terminal-link": "^2.1.1",
|
"terminal-link": "^2.1.1",
|
||||||
"@ice/pack-binding": "0.0.2",
|
"@ice/pack-binding": "0.0.3",
|
||||||
"@rspack/plugin-react-refresh": "0.4.0"
|
"@rspack/plugin-react-refresh": "0.4.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
import RefreshPlugin from '@rspack/plugin-react-refresh';
|
||||||
|
|
||||||
|
export default RefreshPlugin;
|
||||||
|
|
@ -82,7 +82,7 @@ const getConfig: GetConfig = async (context, options, rspack) => {
|
||||||
},
|
},
|
||||||
getRoutesFile,
|
getRoutesFile,
|
||||||
getExpandedEnvs,
|
getExpandedEnvs,
|
||||||
localIdentName: config.mode === 'development' ? CSS_MODULES_LOCAL_IDENT_NAME_DEV : CSS_MODULES_LOCAL_IDENT_NAME,
|
localIdentName: config.cssModules?.localIdentName || (config.mode === 'development' ? CSS_MODULES_LOCAL_IDENT_NAME_DEV : CSS_MODULES_LOCAL_IDENT_NAME),
|
||||||
taskConfig: {
|
taskConfig: {
|
||||||
...config,
|
...config,
|
||||||
plugins: (config.plugins || []).concat(plugins),
|
plugins: (config.plugins || []).concat(plugins),
|
||||||
|
|
|
||||||
|
|
@ -72,14 +72,16 @@ const createAssetsPlugin = (compilationInfo: CompilationInfo | (() => Compilatio
|
||||||
let url = '';
|
let url = '';
|
||||||
// Suffix `?url` will generate content hash in assets manifest,
|
// Suffix `?url` will generate content hash in assets manifest,
|
||||||
// keep the same file rule with client side.
|
// keep the same file rule with client side.
|
||||||
const contentHash = manifest?.assetsManifest!.assets[`${relativePath}${args.suffix}`];
|
const contentHash = manifest?.assetsManifest?.assets?.[`${relativePath}${args.suffix}`];
|
||||||
if (contentHash) {
|
if (contentHash) {
|
||||||
const basename = path.basename(args.path);
|
const basename = path.basename(args.path);
|
||||||
const extname = path.extname(basename);
|
const extname = path.extname(basename);
|
||||||
const ext = extname.substring(1);
|
const ext = extname.substring(1);
|
||||||
const name = basename.slice(0, -extname.length);
|
const name = basename.slice(0, -extname.length);
|
||||||
|
// In case of rspack bundler it will return full hash even it is set to [hash:8].
|
||||||
|
const hash = contentHash.length > 8 ? contentHash.slice(0, 8) : contentHash;
|
||||||
// assets/[name].[hash:8][ext]
|
// assets/[name].[hash:8][ext]
|
||||||
url = `${manifest?.assetsManifest.publicPath}assets/${name}.${contentHash}.${ext}`;
|
url = `${manifest?.assetsManifest.publicPath}assets/${name}.${hash}.${ext}`;
|
||||||
} else {
|
} else {
|
||||||
url = `data:${mrmime.lookup(args.path)};base64,${content.toString('base64')}`;
|
url = `data:${mrmime.lookup(args.path)};base64,${content.toString('base64')}`;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,11 @@
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
import { createRequire } from 'module';
|
import { createRequire } from 'module';
|
||||||
import { compilationPlugin, compileExcludes, getDefineVars, getCompilerPlugins, getJsxTransformOptions } from '@ice/shared-config';
|
import { compilationPlugin, compileExcludes, getDefineVars, getCompilerPlugins, getJsxTransformOptions, getAliasWithRoot } from '@ice/shared-config';
|
||||||
import type { Config, ModifyWebpackConfig } from '@ice/shared-config/types';
|
import type { Config, ModifyWebpackConfig } from '@ice/shared-config/types';
|
||||||
import type { Configuration, rspack as Rspack } from '@rspack/core';
|
import type { Configuration, rspack as Rspack } from '@rspack/core';
|
||||||
import lodash from '@ice/bundles/compiled/lodash/index.js';
|
import lodash from '@ice/bundles/compiled/lodash/index.js';
|
||||||
|
import { coreJsPath } from '@ice/bundles';
|
||||||
|
import RefreshPlugin from '@ice/bundles/esm/plugin-refresh.js';
|
||||||
import getSplitChunks from './splitChunks.js';
|
import getSplitChunks from './splitChunks.js';
|
||||||
import getAssetsRule from './assetsRule.js';
|
import getAssetsRule from './assetsRule.js';
|
||||||
import getCssRules from './cssRules.js';
|
import getCssRules from './cssRules.js';
|
||||||
|
|
@ -26,6 +28,7 @@ type GetConfig = (
|
||||||
const require = createRequire(import.meta.url);
|
const require = createRequire(import.meta.url);
|
||||||
|
|
||||||
const { merge } = lodash;
|
const { merge } = lodash;
|
||||||
|
|
||||||
const getConfig: GetConfig = async (options) => {
|
const getConfig: GetConfig = async (options) => {
|
||||||
const {
|
const {
|
||||||
rootDir,
|
rootDir,
|
||||||
|
|
@ -62,6 +65,7 @@ const getConfig: GetConfig = async (options) => {
|
||||||
configureWebpack = [],
|
configureWebpack = [],
|
||||||
minimizerOptions = {},
|
minimizerOptions = {},
|
||||||
} = taskConfig || {};
|
} = taskConfig || {};
|
||||||
|
const isDev = mode === 'development';
|
||||||
const absoluteOutputDir = path.isAbsolute(outputDir) ? outputDir : path.join(rootDir, outputDir);
|
const absoluteOutputDir = path.isAbsolute(outputDir) ? outputDir : path.join(rootDir, outputDir);
|
||||||
const hashKey = hash === true ? 'hash:8' : (hash || '');
|
const hashKey = hash === true ? 'hash:8' : (hash || '');
|
||||||
const compilation = compilationPlugin({
|
const compilation = compilationPlugin({
|
||||||
|
|
@ -129,7 +133,7 @@ const getConfig: GetConfig = async (options) => {
|
||||||
use: {
|
use: {
|
||||||
loader: 'builtin:compilation-loader',
|
loader: 'builtin:compilation-loader',
|
||||||
options: {
|
options: {
|
||||||
swcOptions: getJsxTransformOptions({ suffix: 'jsx', rootDir, mode, fastRefresh: false, polyfill, enableEnv: true }),
|
swcOptions: getJsxTransformOptions({ suffix: 'jsx', rootDir, mode, fastRefresh: isDev, polyfill, enableEnv: true }),
|
||||||
transformFeatures: {
|
transformFeatures: {
|
||||||
removeExport: swcOptions.removeExportExprs,
|
removeExport: swcOptions.removeExportExprs,
|
||||||
keepExport: swcOptions.keepExports,
|
keepExport: swcOptions.keepExports,
|
||||||
|
|
@ -146,7 +150,11 @@ const getConfig: GetConfig = async (options) => {
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
resolve: {
|
resolve: {
|
||||||
alias,
|
alias: {
|
||||||
|
// Always lock the corejs version, it is decided by shared-config.
|
||||||
|
'core-js': coreJsPath,
|
||||||
|
...getAliasWithRoot(rootDir, alias),
|
||||||
|
},
|
||||||
},
|
},
|
||||||
watchOptions: {
|
watchOptions: {
|
||||||
ignored: /node_modules/,
|
ignored: /node_modules/,
|
||||||
|
|
@ -163,10 +171,10 @@ const getConfig: GetConfig = async (options) => {
|
||||||
...plugins,
|
...plugins,
|
||||||
// Unplugin should be compatible with rspack.
|
// Unplugin should be compatible with rspack.
|
||||||
...compilerWebpackPlugins,
|
...compilerWebpackPlugins,
|
||||||
|
isDev && new RefreshPlugin(),
|
||||||
new DefinePlugin(getDefineVars(define, runtimeDefineVars, getExpandedEnvs)),
|
new DefinePlugin(getDefineVars(define, runtimeDefineVars, getExpandedEnvs)),
|
||||||
new ProvidePlugin({
|
new ProvidePlugin({
|
||||||
process: [require.resolve('process/browser')],
|
process: [require.resolve('process/browser')],
|
||||||
$ReactRefreshRuntime$: [require.resolve('./client/reactRefresh.cjs')],
|
|
||||||
}),
|
}),
|
||||||
!!minify && new SwcJsMinimizerRspackPlugin(jsMinimizerPluginOptions),
|
!!minify && new SwcJsMinimizerRspackPlugin(jsMinimizerPluginOptions),
|
||||||
].filter(Boolean),
|
].filter(Boolean),
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,12 @@
|
||||||
|
import * as path from 'path';
|
||||||
|
|
||||||
|
function getAliasWithRoot(rootDir: string, alias?: Record<string, string | boolean>) {
|
||||||
|
const aliasWithRoot = {};
|
||||||
|
Object.keys(alias).forEach((key) => {
|
||||||
|
const aliasValue = alias[key];
|
||||||
|
aliasWithRoot[key] = (aliasValue && typeof aliasValue === 'string' && aliasValue.startsWith('.')) ? path.join(rootDir, aliasValue) : aliasValue;
|
||||||
|
});
|
||||||
|
return aliasWithRoot;
|
||||||
|
}
|
||||||
|
|
||||||
|
export default getAliasWithRoot;
|
||||||
|
|
@ -4,6 +4,7 @@ import getCompilerPlugins from './getCompilerPlugins.js';
|
||||||
import getDefineVars from './getDefineVars.js';
|
import getDefineVars from './getDefineVars.js';
|
||||||
import getPostcssOpts from './getPostcssOpts.js';
|
import getPostcssOpts from './getPostcssOpts.js';
|
||||||
import getCSSModuleLocalIdent from './getCSSModuleLocalIdent.js';
|
import getCSSModuleLocalIdent from './getCSSModuleLocalIdent.js';
|
||||||
|
import getAliasWithRoot from './getAlias.js';
|
||||||
|
|
||||||
export {
|
export {
|
||||||
getCSSModuleLocalIdent,
|
getCSSModuleLocalIdent,
|
||||||
|
|
@ -15,4 +16,5 @@ export {
|
||||||
getCompilerPlugins,
|
getCompilerPlugins,
|
||||||
getDefineVars,
|
getDefineVars,
|
||||||
getPostcssOpts,
|
getPostcssOpts,
|
||||||
|
getAliasWithRoot,
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -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 CopyPlugin from '@ice/bundles/compiled/copy-webpack-plugin/index.js';
|
||||||
import type { NormalModule, Compiler, Configuration } from 'webpack';
|
import type { NormalModule, Compiler, Configuration } from 'webpack';
|
||||||
import type webpack from 'webpack';
|
import type webpack from 'webpack';
|
||||||
import { compilationPlugin, compileExcludes, getCompilerPlugins, getDefineVars } from '@ice/shared-config';
|
import { compilationPlugin, compileExcludes, getCompilerPlugins, getDefineVars, getAliasWithRoot } from '@ice/shared-config';
|
||||||
import type { Config, ModifyWebpackConfig } from '@ice/shared-config/types.js';
|
import type { Config, ModifyWebpackConfig } from '@ice/shared-config/types.js';
|
||||||
import configAssets from './config/assets.js';
|
import configAssets from './config/assets.js';
|
||||||
import configCss from './config/css.js';
|
import configCss from './config/css.js';
|
||||||
|
|
@ -59,16 +59,6 @@ function getEntry(rootDir: string, runtimeTmpDir: string) {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
// format alias
|
|
||||||
export function getAliasWithRoot(rootDir: string, alias?: Record<string, string | boolean>) {
|
|
||||||
const aliasWithRoot = {};
|
|
||||||
Object.keys(alias).forEach((key) => {
|
|
||||||
const aliasValue = alias[key];
|
|
||||||
aliasWithRoot[key] = (aliasValue && typeof aliasValue === 'string' && aliasValue.startsWith('.')) ? path.join(rootDir, aliasValue) : aliasValue;
|
|
||||||
});
|
|
||||||
return aliasWithRoot;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function getWebpackConfig(options: GetWebpackConfigOptions): Configuration {
|
export function getWebpackConfig(options: GetWebpackConfigOptions): Configuration {
|
||||||
const {
|
const {
|
||||||
rootDir,
|
rootDir,
|
||||||
|
|
|
||||||
|
|
@ -1268,8 +1268,8 @@ importers:
|
||||||
specifier: 0.0.6
|
specifier: 0.0.6
|
||||||
version: 0.0.6
|
version: 0.0.6
|
||||||
'@ice/pack-binding':
|
'@ice/pack-binding':
|
||||||
specifier: 0.0.2
|
specifier: 0.0.3
|
||||||
version: 0.0.2
|
version: 0.0.3
|
||||||
'@ice/swc-plugin-keep-export':
|
'@ice/swc-plugin-keep-export':
|
||||||
specifier: 0.2.0
|
specifier: 0.2.0
|
||||||
version: 0.2.0
|
version: 0.2.0
|
||||||
|
|
@ -6647,8 +6647,8 @@ packages:
|
||||||
'@ice/css-modules-hash-win32-x64-msvc': 0.0.6
|
'@ice/css-modules-hash-win32-x64-msvc': 0.0.6
|
||||||
dev: false
|
dev: false
|
||||||
|
|
||||||
/@ice/pack-binding-darwin-arm64@0.0.2:
|
/@ice/pack-binding-darwin-arm64@0.0.3:
|
||||||
resolution: {integrity: sha512-OvwDHEqcYr5coVgQGLQxb90MTC6/ySnmQkq03dikAMf8w3o5ooMzqSfRGLL8uAqBBhNNNipYPI97C7b9Pz+eaw==}
|
resolution: {integrity: sha512-uYpNCOnhsfGouHEgctCiW9P8iAcEs633NBK6HqKENq4Mzjtu/gZIDH/kfBe7QtaIpSYttkfzWxkPg7oigcHvrA==}
|
||||||
engines: {node: '>= 10'}
|
engines: {node: '>= 10'}
|
||||||
cpu: [arm64]
|
cpu: [arm64]
|
||||||
os: [darwin]
|
os: [darwin]
|
||||||
|
|
@ -6656,16 +6656,16 @@ packages:
|
||||||
dev: false
|
dev: false
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
/@ice/pack-binding-darwin-universal@0.0.2:
|
/@ice/pack-binding-darwin-universal@0.0.3:
|
||||||
resolution: {integrity: sha512-TG0e5NT6r2+yzL3eBU20RegLfWHDXjSyPjfQc0HM9sWgAHABQ0q+gE47rTv0ThWL8vC1uh4jlhPamwUCpjvLoQ==}
|
resolution: {integrity: sha512-LjciyuX32M5WEuheUGE+juDJTGHcgsvs3fUpl6GAhM+DfgQAbROUVVsF1djmOxAAwJwYIR75SY3BlMIdlthkyQ==}
|
||||||
engines: {node: '>= 10'}
|
engines: {node: '>= 10'}
|
||||||
os: [darwin]
|
os: [darwin]
|
||||||
requiresBuild: true
|
requiresBuild: true
|
||||||
dev: false
|
dev: false
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
/@ice/pack-binding-darwin-x64@0.0.2:
|
/@ice/pack-binding-darwin-x64@0.0.3:
|
||||||
resolution: {integrity: sha512-WcNGfHUClA4x0KjZf9ju0hG0/xFHnMUR1neoEyMw0UW1m6jZF76aWKBfQABocZkFV+veIyTZFXs/2GAmGZOJYw==}
|
resolution: {integrity: sha512-qpvhz48oakCBYTIV1x/4mujVkbh0b3R1TthOB5MXQ4N3orXj6VqlP0WzzDOersRxmqrPlqDcVzuTThow5Go4xA==}
|
||||||
engines: {node: '>= 10'}
|
engines: {node: '>= 10'}
|
||||||
cpu: [x64]
|
cpu: [x64]
|
||||||
os: [darwin]
|
os: [darwin]
|
||||||
|
|
@ -6673,8 +6673,8 @@ packages:
|
||||||
dev: false
|
dev: false
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
/@ice/pack-binding-linux-x64-gnu@0.0.2:
|
/@ice/pack-binding-linux-x64-gnu@0.0.3:
|
||||||
resolution: {integrity: sha512-FQM056bjtP3gyp1ilS7PdrNMhpfwJS1PJvktw0LsrulCrsg+7vkUSvYHY5Jb2IcUAWX0JvTOhvyUeFQ4sN4S6A==}
|
resolution: {integrity: sha512-rFKwOpsHdDP3/d+j88N2LAve23HIzFjjfGweyoE6fjkZ3PPdx+8gkBzMR7jV1P4SXietsm/uoWfK71dhmlf76A==}
|
||||||
engines: {node: '>= 10'}
|
engines: {node: '>= 10'}
|
||||||
cpu: [x64]
|
cpu: [x64]
|
||||||
os: [linux]
|
os: [linux]
|
||||||
|
|
@ -6682,8 +6682,8 @@ packages:
|
||||||
dev: false
|
dev: false
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
/@ice/pack-binding-linux-x64-musl@0.0.2:
|
/@ice/pack-binding-linux-x64-musl@0.0.3:
|
||||||
resolution: {integrity: sha512-h2ELqYZbo/Ckpa0YS6U0z+/oFsJ7gVcta4Ib8IWjUdoXQpK4r37DxY7GdDe+VafGoYGwSJijdzbYQRYsobSVhQ==}
|
resolution: {integrity: sha512-qgdnZLQdARL3uMc+Ey/2arxCfOil4Km8xfI+rZhhNDPItsuk9kJenuSRO5FmXTtYqKWHsNT/Dj87d0KiuW/Ejw==}
|
||||||
engines: {node: '>= 10'}
|
engines: {node: '>= 10'}
|
||||||
cpu: [x64]
|
cpu: [x64]
|
||||||
os: [linux]
|
os: [linux]
|
||||||
|
|
@ -6691,8 +6691,8 @@ packages:
|
||||||
dev: false
|
dev: false
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
/@ice/pack-binding-win32-arm64-msvc@0.0.2:
|
/@ice/pack-binding-win32-arm64-msvc@0.0.3:
|
||||||
resolution: {integrity: sha512-hgxGL5c2gReksGcPeLkdgtmTBKC8baxb7ZAXN3HQoYyT8TJmTjeG6tJvDAfoJU7k6VrGWD2IQvdjWGSsdHUQzw==}
|
resolution: {integrity: sha512-I7fukJd68UVVZpv978+7VXmSP1LrkoSWydiKECbqOHdOm6o9/d7j6p6W1/QBWs5YUYtvGgRV1LzeT121nL3Bvw==}
|
||||||
engines: {node: '>= 10'}
|
engines: {node: '>= 10'}
|
||||||
cpu: [arm64]
|
cpu: [arm64]
|
||||||
os: [win32]
|
os: [win32]
|
||||||
|
|
@ -6700,8 +6700,8 @@ packages:
|
||||||
dev: false
|
dev: false
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
/@ice/pack-binding-win32-x64-msvc@0.0.2:
|
/@ice/pack-binding-win32-x64-msvc@0.0.3:
|
||||||
resolution: {integrity: sha512-TRacy9q8O2GLS1vA1Mh6ySPvpmzN459sTaOQ21WoGdbq+z6lrAgEKezbdB50hUoNZsw4DBDIPKwzZv2hhJGb6w==}
|
resolution: {integrity: sha512-GyXpRpWgFy5O24V/ZedFpfkABSdVvB6H5m7yd1Xq4heHy35/UQrbdhJstK/KfPskW/sSCWYH39cYdnODOXaHnw==}
|
||||||
engines: {node: '>= 10'}
|
engines: {node: '>= 10'}
|
||||||
cpu: [x64]
|
cpu: [x64]
|
||||||
os: [win32]
|
os: [win32]
|
||||||
|
|
@ -6709,17 +6709,17 @@ packages:
|
||||||
dev: false
|
dev: false
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
/@ice/pack-binding@0.0.2:
|
/@ice/pack-binding@0.0.3:
|
||||||
resolution: {integrity: sha512-UkWq7iZG0pH3u4yaU0lVRJjQT8CKfaRyPWSfiD6M8A8klRs3Ksd+yRWqsaIlQ6TxpQ9LvtAGKdAWBEYoJHqm/Q==}
|
resolution: {integrity: sha512-Y9GefjNG0RAJwyPNPOJohYCodZ0RTiMKn3ok0lJEYI53wsTc8ueBeoMQC96Fs03UvzOwNd252fD+0RMc4MWXeQ==}
|
||||||
engines: {node: '>= 10'}
|
engines: {node: '>= 10'}
|
||||||
optionalDependencies:
|
optionalDependencies:
|
||||||
'@ice/pack-binding-darwin-arm64': 0.0.2
|
'@ice/pack-binding-darwin-arm64': 0.0.3
|
||||||
'@ice/pack-binding-darwin-universal': 0.0.2
|
'@ice/pack-binding-darwin-universal': 0.0.3
|
||||||
'@ice/pack-binding-darwin-x64': 0.0.2
|
'@ice/pack-binding-darwin-x64': 0.0.3
|
||||||
'@ice/pack-binding-linux-x64-gnu': 0.0.2
|
'@ice/pack-binding-linux-x64-gnu': 0.0.3
|
||||||
'@ice/pack-binding-linux-x64-musl': 0.0.2
|
'@ice/pack-binding-linux-x64-musl': 0.0.3
|
||||||
'@ice/pack-binding-win32-arm64-msvc': 0.0.2
|
'@ice/pack-binding-win32-arm64-msvc': 0.0.3
|
||||||
'@ice/pack-binding-win32-x64-msvc': 0.0.2
|
'@ice/pack-binding-win32-x64-msvc': 0.0.3
|
||||||
dev: false
|
dev: false
|
||||||
|
|
||||||
/@ice/pkg@1.5.5:
|
/@ice/pkg@1.5.5:
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue