Skip to content

Commit

Permalink
Merge branch 'release/next' into feat/rspack
Browse files Browse the repository at this point in the history
  • Loading branch information
ClarkXia committed Aug 21, 2023
2 parents 99d670c + 1dbcfa5 commit e0100a2
Show file tree
Hide file tree
Showing 40 changed files with 524 additions and 570 deletions.
5 changes: 5 additions & 0 deletions .changeset/late-trains-relate.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@ice/bundles': patch
---

fix: bump @swc/core, webpack, swc plugins, core-js version
2 changes: 1 addition & 1 deletion examples/app-config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@
"@types/react": "^18.0.0",
"@types/react-dom": "^18.0.2",
"speed-measure-webpack-plugin": "^1.5.0",
"webpack": "^5.86.0"
"webpack": "^5.88.0"
}
}
2 changes: 1 addition & 1 deletion examples/basic-project/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@
"@types/react": "^18.0.0",
"@types/react-dom": "^18.0.2",
"speed-measure-webpack-plugin": "^1.5.0",
"webpack": "^5.86.0"
"webpack": "^5.88.0"
}
}
2 changes: 1 addition & 1 deletion examples/cavans-project/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@
"devDependencies": {
"@types/react": "^18.0.0",
"@types/react-dom": "^18.0.0",
"webpack": "^5.86.0"
"webpack": "^5.88.0"
}
}
2 changes: 1 addition & 1 deletion examples/csr-project/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@
"@types/react": "^18.0.0",
"@types/react-dom": "^18.0.0",
"speed-measure-webpack-plugin": "^1.5.0",
"webpack": "^5.86.0"
"webpack": "^5.88.0"
}
}
2 changes: 1 addition & 1 deletion examples/disable-data-loader/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@
"@types/react": "^18.0.0",
"@types/react-dom": "^18.0.2",
"speed-measure-webpack-plugin": "^1.5.0",
"webpack": "^5.86.0"
"webpack": "^5.88.0"
}
}
2 changes: 1 addition & 1 deletion examples/miniapp-project/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@
"@types/react-dom": "^18.0.2",
"browserslist": "^4.19.3",
"speed-measure-webpack-plugin": "^1.5.0",
"webpack": "^5.86.0"
"webpack": "^5.88.0"
}
}
2 changes: 1 addition & 1 deletion examples/rax-inline-style/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@
"devDependencies": {
"@types/react": "^18.0.0",
"@types/react-dom": "^18.0.2",
"webpack": "^5.86.0"
"webpack": "^5.88.0"
}
}
2 changes: 1 addition & 1 deletion examples/rax-project/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@
"devDependencies": {
"@types/react": "^18.0.0",
"@types/react-dom": "^18.0.2",
"webpack": "^5.86.0"
"webpack": "^5.88.0"
}
}
2 changes: 1 addition & 1 deletion examples/with-entry-type/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@
"fs-extra": "^10.0.0",
"@types/react": "^18.0.0",
"@types/react-dom": "^18.0.2",
"webpack": "^5.86.0"
"webpack": "^5.88.0"
}
}
2 changes: 1 addition & 1 deletion examples/with-nested-routes/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@
"@types/react": "^18.0.0",
"@types/react-dom": "^18.0.0",
"speed-measure-webpack-plugin": "^1.5.0",
"webpack": "^5.86.0"
"webpack": "^5.88.0"
}
}
2 changes: 1 addition & 1 deletion examples/with-pha/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@
"devDependencies": {
"@types/react": "^18.0.0",
"@types/react-dom": "^18.0.2",
"webpack": "^5.86.0"
"webpack": "^5.88.0"
}
}
12 changes: 6 additions & 6 deletions packages/bundles/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@
"main": "./esm/index.js",
"type": "module",
"dependencies": {
"@swc/core": "1.3.19",
"@ice/swc-plugin-remove-export": "0.1.2",
"@ice/swc-plugin-keep-export": "0.1.4-2",
"@ice/swc-plugin-node-transform": "0.1.0-8",
"@swc/core": "1.3.77",
"@ice/swc-plugin-remove-export": "0.2.0",
"@ice/swc-plugin-keep-export": "0.2.0",
"@ice/swc-plugin-node-transform": "0.2.0",
"ansi-html-community": "^0.0.8",
"html-entities": "^2.3.2",
"core-js": "3.29.1",
"core-js": "3.32.0",
"caniuse-lite": "^1.0.30001431",
"chokidar": "3.5.3",
"esbuild": "^0.17.16",
Expand Down Expand Up @@ -68,7 +68,7 @@
"terser-webpack-plugin": "5.3.5",
"typescript": "^4.6.4",
"trusted-cert": "1.1.3",
"webpack": "5.86.0",
"webpack": "5.88.2",
"webpack-bundle-analyzer": "4.5.0",
"webpack-dev-server": "4.15.0",
"unplugin": "0.9.5",
Expand Down
2 changes: 1 addition & 1 deletion packages/ice/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
"react-router": "6.14.2",
"sass": "^1.50.0",
"unplugin": "^0.9.0",
"webpack": "^5.86.0",
"webpack": "^5.88.0",
"webpack-dev-server": "^4.7.4",
"@rspack/core": "0.2.12",
"@rspack/dev-server": "0.2.12"
Expand Down
2 changes: 0 additions & 2 deletions packages/ice/src/bundler/webpack/start.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ export async function startDevServer(
a.split('/').filter(Boolean).length - b.split('/').filter(Boolean).length);
const webTaskConfig = taskConfigs.find(({ name }) => name === WEB);
const customMiddlewares = webpackConfigs[0].devServer?.setupMiddlewares;
// @ts-expect-error
const defaultDevServerConfig = await getDefaultServerConfig(webpackConfigs[0].devServer, commandArgs);
let devServerConfig: DevServerConfiguration = {
...defaultDevServerConfig,
Expand All @@ -47,7 +46,6 @@ export async function startDevServer(
mock: commandArgs.mock,
rootDir,
});
// @ts-expect-error
return customMiddlewares ? customMiddlewares(builtInMiddlewares, devServer) : builtInMiddlewares;
},
};
Expand Down
1 change: 1 addition & 0 deletions packages/ice/src/webpack/ServerCompilerPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ export default class ServerCompilerPlugin {
compiler.hooks.watchRun.tap(pluginName, () => {
this.isCompiling = true;
});
// @ts-expect-error webpack hooks type not match.
compiler.hooks.emit.tapPromise(pluginName, async (compilation: Compilation) => {
this.isCompiling = false;
await this.compileTask(compilation);
Expand Down
4 changes: 0 additions & 4 deletions packages/jsx-runtime/build.config.mts
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
import { defineConfig } from '@ice/pkg';

export default defineConfig({
bundle: {
filename: 'jsx-runtime',
formats: ['umd'],
},
transform: {
formats: ['esm'],
},
Expand Down
2 changes: 1 addition & 1 deletion packages/jsx-runtime/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"style-unit": "^3.0.4"
},
"devDependencies": {
"@ice/pkg": "1.1.2-0",
"@ice/pkg": "^1.5.0",
"@types/react": "^18.0.0",
"@types/react-dom": "^18.0.0",
"react": "^18.0.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/miniapp-loader/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"@ice/bundles": "^0.1.10"
},
"devDependencies": {
"webpack": "^5.86.0"
"webpack": "^5.88.0"
},
"publishConfig": {
"access": "public"
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-cavans/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
},
"devDependencies": {
"@ice/app": "^3.2.10",
"webpack": "^5.86.0",
"webpack": "^5.88.0",
"@ice/runtime": "^1.2.5"
},
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-i18n/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"url-join": "^5.0.0"
},
"devDependencies": {
"@ice/pkg": "^1.0.0",
"@ice/pkg": "^1.5.0",
"@ice/app": "workspace:^",
"@ice/runtime": "workspace:^",
"@remix-run/router": "^1.6.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-miniapp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
"devDependencies": {
"@ice/app": "^3.2.6",
"@ice/runtime": "^1.2.4",
"webpack": "^5.86.0"
"webpack": "^5.88.0"
},
"repository": {
"type": "http",
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-miniapp/src/miniapp/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ const getMiniappTask = ({
// FIXME: enable cache will cause error, disable it temporarily
enableCache: false,
plugins,
loaders: module.rules,
loaders: module?.rules,
optimization: {
sideEffects: true,
usedExports: true,
Expand Down
5 changes: 4 additions & 1 deletion packages/plugin-miniapp/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,7 @@ export interface MiniappWebpackOptions {
nativeConfig: Record<string, any>;
}

export type MiniappWebpackConfig = Pick<webpack.Configuration, 'plugins' | 'module'>;
export interface MiniappWebpackConfig {
plugins: Config['plugins'];
module: webpack.Configuration['module'];
}
2 changes: 1 addition & 1 deletion packages/plugin-pha/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"@ice/app": "^3.2.9",
"build-scripts": "^2.1.2-0",
"esbuild": "^0.17.16",
"webpack": "^5.86.0",
"webpack": "^5.88.0",
"webpack-dev-server": "^4.9.2"
},
"repository": {
Expand Down
4 changes: 2 additions & 2 deletions packages/plugin-rax-compat/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"devDependencies": {
"@ice/app": "^3.2.8",
"@types/lodash-es": "^4.17.7",
"webpack": "^5.86.0"
"webpack": "^5.88.0"
},
"repository": {
"type": "http",
Expand All @@ -45,4 +45,4 @@
"publishConfig": {
"access": "public"
}
}
}
2 changes: 1 addition & 1 deletion packages/rax-compat/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
"@ice/appear": "^0.2.0"
},
"devDependencies": {
"@ice/pkg": "1.1.2-0",
"@ice/pkg": "^1.5.0",
"@types/rax": "^1.0.8",
"@types/react": "^18.0.0",
"@types/react-dom": "^18.0.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/rspack-config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
],
"dependencies": {
"@ice/shared-config": "1.0.0",
"@ice/bundles": "0.1.12"
"@ice/bundles": "0.1.13"
},
"devDependencies": {
"@rspack/core": "^0.2.12"
Expand Down
2 changes: 1 addition & 1 deletion packages/shared-config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"*.d.ts"
],
"dependencies": {
"@ice/bundles": "0.1.12",
"@ice/bundles": "0.1.13",
"@rollup/pluginutils": "^4.2.0",
"browserslist": "^4.19.3",
"consola": "^2.15.3",
Expand Down
5 changes: 2 additions & 3 deletions packages/shared-config/src/getCompilerPlugins.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import unplugin from '@ice/bundles/compiled/unplugin/index.js';
import type { BuildOptions } from 'esbuild';
import type { UnpluginOptions } from '@ice/bundles/compiled/unplugin/index.js';
import type { Configuration } from 'webpack';
import type { Config } from './types.js';
import compilationPlugin from './unPlugins/compilation.js';
import redirectImportPlugin from './unPlugins/redirectImport.js';
Expand Down Expand Up @@ -32,7 +31,7 @@ function transformInclude(id: string) {
return !!id.match(/\.(js|jsx|ts|tsx|mjs|mts|css|less|scss)$/);
}

function getCompilerPlugins(rootDir: string, config: Config, compiler: 'webpack', transformOptions: TransformOptions): Configuration['plugins'];
function getCompilerPlugins(rootDir: string, config: Config, compiler: 'webpack', transformOptions: TransformOptions): Config['plugins'];
function getCompilerPlugins(rootDir: string, config: Config, compiler: 'esbuild', transformOptions: TransformOptions): BuildOptions['plugins'];
function getCompilerPlugins(rootDir: string, config: Config, compiler: Compiler, transformOptions: TransformOptions) {
const {
Expand Down Expand Up @@ -91,7 +90,7 @@ function getCompilerPlugins(rootDir: string, config: Config, compiler: Compiler,
// Plugins will be transformed as webpack loader, the execute order of webpack loader is reversed.
? compilerPlugins
.reverse()
.map((plugin) => createUnplugin(() => getPluginTransform(plugin, transformOptions)).webpack())
.map((plugin) => createUnplugin(() => getPluginTransform(plugin, transformOptions)).webpack()) as Config['plugins']
: compilerPlugins.map(plugin => getPluginTransform(plugin, transformOptions));
}

Expand Down
2 changes: 1 addition & 1 deletion packages/shared-config/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ export interface Config {

publicPath?: string;

loaders?: (RuleSetRule | '...')[];
loaders?: (undefined | null | false | '' | 0 | RuleSetRule | '...')[];

plugins?: (
| ((this: Compiler, compiler: Compiler) => void)
Expand Down
2 changes: 1 addition & 1 deletion packages/shared-config/src/unPlugins/compilation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ function getJsxTransformOptions({
loose: false,
...(polyfill ? {
mode: polyfill,
coreJs: '3.29',
coreJs: '3.32',
} : {}),
};
const supportBrowsers = getSupportedBrowsers(rootDir, mode === 'development');
Expand Down
5 changes: 3 additions & 2 deletions packages/shared-config/src/utils/transformImport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,11 @@ const transformImport = async (source: string, coreJsPath: string) => {
if (!isESM) {
// Replace @swc/helpers with cjs path.
const importStr = source.substring(targetImport.ss, targetImport.se);
const matchImport = importStr.match(/import\s+([\w*\s{},]*)\s+from\s+['"](.*)['"]/);
// Import rule: import { _ as _type_of } from "@swc/helpers/_/_type_of";
const matchImport = importStr.match(/import\s+{\s+([\w*\s{},]*)\s+}\s+from\s+['"](.*)['"]/);
if (matchImport) {
const [,identifier] = matchImport;
const replaceModule = `var ${identifier} = require('${targetImport.n.replace(/@swc\/helpers\/src\/(.*).mjs$/,
const replaceModule = `var ${identifier.split('as')[1].trim()} = require('${targetImport.n.replace(/@swc\/helpers\/_\/(.*)$/,
(_, matched) => `@swc/helpers/cjs/${matched}.cjs`)}')._`;
str().overwrite(targetImport.ss, targetImport.se, replaceModule);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
import _object_spread from '@swc/helpers/src/_object_spread.mjs';import 'react';
import { _ as _object_spread } from '@swc/helpers/_/_object_spread';import 'react';
Original file line number Diff line number Diff line change
@@ -1 +1 @@
import _object_spread from '@swc/helpers/src/_object_spread.mjs';module.exports = {};
import { _ as _object_spread } from '@swc/helpers/_/_object_spread';module.exports = {};
2 changes: 1 addition & 1 deletion packages/shared-config/tests/transformImport.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ describe('transform core js path', () => {
it('@swc/helpers esm', async () => {
const orignalCode = fs.readFileSync(path.join(__dirname, './fixtures/transformImport/swc-esm.js'), 'utf-8');
expect(await transformImport(orignalCode, coreJsPath))
.toBe('import _object_spread from \'@swc/helpers/src/_object_spread.mjs\';import \'react\';');
.toBe('import { _ as _object_spread } from \'@swc/helpers/_/_object_spread\';import \'react\';');
});
it('@swc/helpers cjs', async () => {
const orignalCode = fs.readFileSync(path.join(__dirname, './fixtures/transformImport/swc.js'), 'utf-8');
Expand Down
2 changes: 1 addition & 1 deletion packages/webpack-config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"process": "^0.11.10"
},
"devDependencies": {
"webpack": "^5.86.0"
"webpack": "^5.88.0"
},
"scripts": {
"watch": "tsc -w",
Expand Down
2 changes: 1 addition & 1 deletion packages/webpack-modify/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
},
"devDependencies": {
"@ice/webpack-config": "^1.0.0",
"webpack": "^5.86.0"
"webpack": "^5.88.0"
},
"scripts": {
"watch": "tsc -w",
Expand Down
Loading

0 comments on commit e0100a2

Please sign in to comment.