Skip to content

Commit

Permalink
Merge pull request #6824 from alibaba/release/next
Browse files Browse the repository at this point in the history
Release 3.4.5
  • Loading branch information
ClarkXia authored Mar 7, 2024
2 parents e2cc5d8 + 7ae6af3 commit 1989fc1
Show file tree
Hide file tree
Showing 27 changed files with 337 additions and 122 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@
"packageManager": "[email protected]",
"pnpm": {
"patchedDependencies": {
"@rspack/[email protected]": "patches/@[email protected]"
"@rspack/[email protected]": "patches/@[email protected]",
"[email protected]": "patches/[email protected]"
}
}
}
6 changes: 6 additions & 0 deletions packages/bundles/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion packages/bundles/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ice/bundles",
"version": "0.2.4",
"version": "0.2.5",
"license": "MIT",
"author": "ICE",
"description": "Basic dependencies for ice.",
Expand Down
12 changes: 12 additions & 0 deletions packages/ice/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
10 changes: 5 additions & 5 deletions packages/ice/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down Expand Up @@ -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",
Expand Down
7 changes: 5 additions & 2 deletions packages/ice/src/service/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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__}`;
Expand Down
11 changes: 11 additions & 0 deletions packages/plugin-fusion/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
6 changes: 3 additions & 3 deletions packages/plugin-fusion/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand All @@ -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",
Expand Down
58 changes: 17 additions & 41 deletions packages/plugin-fusion/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<PluginOptions> = (options = {}) => ({
name: '@ice/plugin-fusion',
setup: ({ onGetConfig, createLogger }) => {
setup: ({ onGetConfig, createLogger, generator }) => {
const { theme, themePackage, importStyle } = options;
if (importStyle) {
onGetConfig((config) => {
Expand All @@ -73,33 +45,37 @@ const plugin: Plugin<PluginOptions> = (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) => {
const { rules } = webpackConfig.module;
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;
}
return false;
});
if (sassLoader) {
const additionalContent = [];
const additionalContent = [
`$css-prefix: '${theme?.['css-prefix'] || 'next-'}' !default;`,
];
if (themePackage) {
const themeFile = getVariablesPath({
packageName: themePackage,
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 @@ -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": {
Expand Down
10 changes: 10 additions & 0 deletions packages/rspack-config/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
6 changes: 3 additions & 3 deletions packages/rspack-config/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand All @@ -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"
Expand Down
6 changes: 3 additions & 3 deletions packages/rspack-config/src/index.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -232,6 +231,7 @@ const getConfig: GetConfig = async (options) => {
infrastructureLogging: {
level: 'warn',
},
devtool: getDevtoolValue(sourceMap),
devServer: {
allowedHosts: 'all',
headers: {
Expand Down
9 changes: 9 additions & 0 deletions packages/shared-config/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 2 additions & 2 deletions packages/shared-config/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand All @@ -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",
Expand Down
4 changes: 3 additions & 1 deletion packages/shared-config/src/getCompilerPlugins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand Down
2 changes: 2 additions & 0 deletions packages/shared-config/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -17,4 +18,5 @@ export {
getDefineVars,
getPostcssOpts,
getAliasWithRoot,
getDevtoolValue,
};
16 changes: 16 additions & 0 deletions packages/shared-config/src/utils/getDevtool.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import type { Config } from '../types';

interface GetDevtoolOptions<T = any> {
(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;
6 changes: 6 additions & 0 deletions packages/style-import/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## 1.1.0

### Minor Changes

- 79c32a77: feat: optimize function theme injection

## 1.0.1

### Patch Changes
Expand Down
4 changes: 2 additions & 2 deletions packages/style-import/package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand All @@ -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": {
Expand Down
Loading

0 comments on commit 1989fc1

Please sign in to comment.