Skip to content

Commit adf1fa4

Browse files
authored
Merge pull request #6541 from alibaba/release/next
Release 3.3.3
2 parents 6926c47 + 40f1071 commit adf1fa4

33 files changed

+254
-46
lines changed

examples/basic-project/ice.config.mts

+3
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,7 @@ export default defineConfig(() => ({
4141
customPlugin(),
4242
],
4343
eslint: true,
44+
cssModules: {
45+
localIdentName: '[hash:8]',
46+
},
4447
}));

packages/ice/CHANGELOG.md

+12
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
11
# Changelog
22

3+
## 3.3.3
4+
5+
### Patch Changes
6+
7+
- c3a9c20a: chore: modify output
8+
- 82702258: feat: compat no document
9+
- 78f850fa: feat: support hash only class name for css modules
10+
- Updated dependencies [78f850fa]
11+
- @ice/webpack-config@1.1.3
12+
- @ice/shared-config@1.0.4
13+
- @ice/rspack-config@1.0.4
14+
315
## 3.3.2
416

517
### Patch Changes

packages/ice/package.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@ice/app",
3-
"version": "3.3.2",
3+
"version": "3.3.3",
44
"description": "provide scripts and configuration used by web framework ice",
55
"type": "module",
66
"main": "./esm/index.js",
@@ -40,9 +40,9 @@
4040
"@ice/bundles": "0.1.16",
4141
"@ice/route-manifest": "1.2.2",
4242
"@ice/runtime": "^1.2.9",
43-
"@ice/shared-config": "1.0.3",
44-
"@ice/webpack-config": "1.1.2",
45-
"@ice/rspack-config": "1.0.3",
43+
"@ice/shared-config": "1.0.4",
44+
"@ice/webpack-config": "1.1.3",
45+
"@ice/rspack-config": "1.0.4",
4646
"@swc/helpers": "0.5.1",
4747
"@types/express": "^4.17.14",
4848
"address": "^1.1.2",

packages/ice/src/bundler/config/output.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export async function getOutputPaths(options: {
2121
}
2222
}
2323
if (serverEntry && userConfig.htmlGenerating) {
24-
outputPaths = await buildCustomOuputs(rootDir, outputDir, serverEntry, bundleOptions);
24+
outputPaths = await buildCustomOutputs(rootDir, outputDir, serverEntry, bundleOptions);
2525
}
2626
return outputPaths;
2727
}
@@ -32,7 +32,7 @@ export async function removeServerOutput(outputDir: string, ssr: boolean) {
3232
}
3333
}
3434
// Build custom outputs such html and js file for weex.
35-
async function buildCustomOuputs(
35+
async function buildCustomOutputs(
3636
rootDir: string,
3737
outputDir: string,
3838
serverEntry: string,

packages/ice/src/config.ts

+8
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,14 @@ const userConfig = [
154154
return mergeDefaultValue(config, 'postcss', postcss);
155155
},
156156
},
157+
{
158+
name: 'cssModules',
159+
validation: 'object',
160+
defaultValue: {},
161+
setConfig(config: Config, postcss: UserConfig['cssModules']) {
162+
return mergeDefaultValue(config, 'cssModules', postcss);
163+
},
164+
},
157165
{
158166
name: 'webpack',
159167
validation: 'function',

packages/ice/src/createService.ts

+2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { Context } from 'build-scripts';
55
import type { CommandArgs, CommandName } from 'build-scripts';
66
import type { Config } from '@ice/shared-config/types';
77
import type { AppConfig } from '@ice/runtime/types';
8+
import fse from 'fs-extra';
89
import webpack from '@ice/bundles/compiled/webpack/index.js';
910
import type {
1011
DeclarationData,
@@ -274,6 +275,7 @@ async function createService({ rootDir, command, commandArgs }: CreateServiceOpt
274275
enableRoutes: true,
275276
entryCode,
276277
jsOutput: distType.includes('javascript'),
278+
hasDocument: fse.existsSync(path.join(rootDir, 'src/document.tsx')),
277279
dataLoader: userConfig.dataLoader,
278280
routeImports,
279281
routeDefinition,

packages/ice/src/service/ServerRunner.ts

+6-3
Original file line numberDiff line numberDiff line change
@@ -112,14 +112,16 @@ class ServerRunner extends Runner {
112112
},
113113
},
114114
}, 'esbuild', { isServer: true });
115-
const { alias, ignores } = filterAlias(task.config.alias || {});
116-
const define = getRuntimeDefination(task.config.define || {});
115+
const taskConfig = task.config;
116+
const { alias, ignores } = filterAlias(taskConfig.alias || {});
117+
const define = getRuntimeDefination(taskConfig.define || {});
117118
const runtimeMeta = new RuntimeMeta({
118119
rootDir,
119120
alias,
120121
ignores,
121122
external: server.externals || [],
122123
define,
124+
taskConfig,
123125
speedup,
124126
});
125127

@@ -140,8 +142,9 @@ class ServerRunner extends Runner {
140142
// ServerRunner only works in development mode.
141143
mode: 'development',
142144
fileName,
143-
localIdentName: name,
145+
localName: name,
144146
rule: speedup ? 'native' : 'loader',
147+
localIdentName: taskConfig.cssModules?.localIdentName,
145148
});
146149
},
147150
}),

packages/ice/src/service/onDemandPreBundle.ts

+7-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { createRequire } from 'module';
33
import fse from 'fs-extra';
44
import findUp from 'find-up';
55
import type { Plugin } from 'esbuild';
6+
import type { Config } from '@ice/shared-config/types';
67
import { logger } from '../utils/logger.js';
78
import { CACHE_DIR } from '../constant.js';
89
import { bundleDeps, resolvePackageESEntry, getDepsCacheDir } from './preBundleDeps.js';
@@ -24,6 +25,7 @@ interface PreBundleOptions {
2425
plugins?: Plugin[];
2526
external?: string[];
2627
define?: Record<string, string>;
28+
taskConfig?: Config;
2729
speedup?: boolean;
2830
}
2931

@@ -36,6 +38,7 @@ export class RuntimeMeta {
3638
private cachePath: string;
3739
private external: string[];
3840
private define: Record<string, string>;
41+
private taskConfig: Config;
3942
private speedup: boolean;
4043

4144
constructor(options: Omit<PreBundleOptions, 'pkgName' | 'resolveId'>) {
@@ -47,6 +50,7 @@ export class RuntimeMeta {
4750
this.define = options.define;
4851
this.speedup = options.speedup;
4952
this.cachePath = path.join(getDepsCacheDir(path.join(this.rootDir, CACHE_DIR)), 'metadata.json');
53+
this.taskConfig = options.taskConfig;
5054
}
5155

5256
async getDepsCache() {
@@ -100,6 +104,7 @@ export class RuntimeMeta {
100104
define: this.define,
101105
pkgName: pkgName,
102106
resolveId,
107+
taskConfig: this.taskConfig,
103108
speedup: this.speedup,
104109
});
105110
await this.setDepsCache(pkgName, resolveId, bundlePath);
@@ -111,7 +116,7 @@ export class RuntimeMeta {
111116
}
112117

113118
export default async function preBundleDeps(options: PreBundleOptions): Promise<PreBundleResult> {
114-
const { rootDir, pkgName, alias, ignores, plugins, resolveId, external, define, speedup } = options;
119+
const { rootDir, pkgName, alias, ignores, plugins, resolveId, external, define, speedup, taskConfig } = options;
115120
const depsCacheDir = getDepsCacheDir(path.join(rootDir, CACHE_DIR));
116121
try {
117122
await bundleDeps({
@@ -122,6 +127,7 @@ export default async function preBundleDeps(options: PreBundleOptions): Promise<
122127
plugins: plugins || [],
123128
external,
124129
define,
130+
taskConfig,
125131
speedup,
126132
rootDir,
127133
});

packages/ice/src/service/preBundleDeps.ts

+5-2
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ export default async function preBundleDeps(
104104
alias,
105105
external,
106106
define,
107+
taskConfig,
107108
speedup,
108109
});
109110

@@ -129,9 +130,10 @@ export async function bundleDeps(options:
129130
plugins: Plugin[];
130131
external: string[];
131132
define: BuildOptions['define'];
133+
taskConfig: Config;
132134
speedup?: boolean;
133135
}) {
134-
const { entryPoints, outdir, alias, ignores, plugins, external, define, speedup, rootDir } = options;
136+
const { entryPoints, outdir, alias, ignores, plugins, external, define, speedup, rootDir, taskConfig } = options;
135137
return await esbuild.build({
136138
absWorkingDir: process.cwd(),
137139
entryPoints,
@@ -162,8 +164,9 @@ export async function bundleDeps(options:
162164
// Prebundle only works in development mode.
163165
mode: 'development',
164166
fileName,
165-
localIdentName: name,
167+
localName: name,
166168
rule: speedup ? 'native' : 'loader',
169+
localIdentName: taskConfig.cssModules?.localIdentName,
167170
});
168171
},
169172
}),

packages/ice/src/service/serverCompiler.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -205,8 +205,9 @@ export function createServerCompiler(options: Options) {
205205
rootDir,
206206
mode: dev ? 'development' : 'production',
207207
fileName,
208-
localIdentName: name,
208+
localName: name,
209209
rule: speedup ? 'native' : 'loader',
210+
localIdentName: task.config.cssModules?.localIdentName,
210211
});
211212
},
212213
}),

packages/ice/src/types/userConfig.ts

+1
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ export interface UserConfig {
117117
postcss?: ProcessOptions & {
118118
plugins?: (string | [string, Record<string, any>?])[];
119119
};
120+
cssModules?: Config['cssModules'];
120121
/**
121122
* Custom file-system based route rules.
122123
* @see https://v3.ice.work/docs/guide/basic/config#routes

packages/ice/src/utils/getCSSModuleIdent.ts

+5-3
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,19 @@ interface Options {
99
rule?: string;
1010
mode?: 'development' | 'production';
1111
fileName: string;
12+
localName: string;
1213
localIdentName: string;
1314
}
1415

16+
// TODO: move this logic to getCSSModuleLocalIdent.
1517
const getCSSModuleIdent = (options: Options) => {
16-
const { rootDir, fileName, localIdentName, rule, mode } = options;
18+
const { rootDir, fileName, localName, localIdentName, rule, mode } = options;
1719
if (rule === 'native') {
1820
const template = mode === 'development' ? CSS_MODULES_LOCAL_IDENT_NAME_DEV : CSS_MODULES_LOCAL_IDENT_NAME;
1921
const relativePath = path.isAbsolute(fileName) ? path.relative(rootDir, fileName) : fileName;
20-
return getIdentByRust(relativePath, localIdentName, template);
22+
return getIdentByRust(relativePath, localName, localIdentName || template);
2123
} else {
22-
return escapeLocalIdent(getCSSModuleLocalIdent(fileName, localIdentName));
24+
return escapeLocalIdent(getCSSModuleLocalIdent(fileName, localName, localIdentName));
2325
}
2426
};
2527

packages/ice/templates/core/entry.client.tsx.ejs

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import * as app from '@/app';
88
import createRoutes from './routes';
99
<% } -%>
1010
<%- runtimeOptions.imports %>
11-
<% if(dataLoaderImport.imports) {-%><%-dataLoaderImport.imports%><% } -%>
11+
<% if (dataLoaderImport.imports) {-%><%-dataLoaderImport.imports%><% } -%>
1212
import type { RunClientAppOptions } from '@ice/runtime';
1313

1414
const getRouterBasename = () => {
@@ -19,7 +19,7 @@ const getRouterBasename = () => {
1919
// Otherwise chunk of route component will pack @ice/jsx-runtime and depend on framework bundle.
2020
const App = <></>;
2121

22-
<% if(!dataLoaderImport.imports) {-%>
22+
<% if (!dataLoaderImport.imports) {-%>
2323
let dataLoaderFetcher = (options) => {
2424
return window.fetch(options.url, options);
2525
}

packages/ice/templates/core/entry.server.ts.ejs

+10-6
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,25 @@
11
import './env.server';
22
import * as runtime from '@ice/runtime/server';
3-
<% if(hydrate) {-%>
3+
<% if (hydrate) {-%>
44
import { commons, statics } from './runtime-modules';
55
<% }-%>
66
import * as app from '@/app';
7+
<% if (hasDocument) {-%>
78
import * as Document from '@/document';
9+
<% }-%>
810
import type { RenderMode, DistType } from '@ice/runtime';
911
import type { RenderToPipeableStreamOptions } from 'react-dom/server';
1012
// @ts-ignore
1113
import assetsManifest from 'virtual:assets-manifest.json';
12-
<% if(hydrate) {-%>
14+
<% if (hydrate) {-%>
1315
import createRoutes from './routes';
1416
<% } else { -%>
1517
import routesManifest from './route-manifest.json';
1618
<% } -%>
1719
import routesConfig from './routes-config.bundle.mjs';
18-
<% if(dataLoaderImport.imports) {-%><%-dataLoaderImport.imports%><% } -%>
19-
<% if(hydrate) {-%><%- runtimeOptions.imports %><% } -%>
20-
<% if(!hydrate) {-%>
20+
<% if (dataLoaderImport.imports) {-%><%-dataLoaderImport.imports%><% } -%>
21+
<% if (hydrate) {-%><%- runtimeOptions.imports %><% } -%>
22+
<% if (!hydrate) {-%>
2123
// Do not inject runtime modules when render mode is document only.
2224
const commons = [];
2325
const statics = [];
@@ -90,12 +92,14 @@ function mergeOptions(options) {
9092
assetsManifest,
9193
createRoutes,
9294
runtimeModules,
95+
<% if (hasDocument) {-%>
9396
documentDataLoader: Document.dataLoader,
9497
Document: Document.default,
98+
<% }-%>
9599
basename: basename || getRouterBasename(),
96100
renderMode,
97101
routesConfig,
98-
<% if(hydrate) {-%>
102+
<% if (hydrate) {-%>
99103
runtimeOptions: {
100104
<% if (runtimeOptions.exports) { -%>
101105
<%- runtimeOptions.exports %>

packages/ice/templates/exports/data-loader.ts.ejs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { dataLoader } from '@ice/runtime';
22
import * as app from '@/app';
33
import dataloaderConfig from './dataloader-config'
4-
<% if(dataLoaderImport.imports) {-%><%-dataLoaderImport.imports%><% } -%>
4+
<% if (dataLoaderImport.imports) {-%><%-dataLoaderImport.imports%><% } -%>
55
<% const staticModuleNames = []; -%>
66
<% if (runtimeModules.length) { -%>
77
<% runtimeModules.forEach((runtimeModule, index) => { -%>
@@ -14,10 +14,10 @@ import dataloaderConfig from './dataloader-config'
1414

1515
const loaders = {
1616
...dataloaderConfig,
17-
<% if(hasExportAppData) {-%>__app: app.dataLoader,<% } -%>
17+
<% if (hasExportAppData) {-%>__app: app.dataLoader,<% } -%>
1818
}
1919

20-
<% if(!dataLoaderImport.imports) {-%>
20+
<% if (!dataLoaderImport.imports) {-%>
2121
let dataLoaderFetcher = (options) => {
2222
return window.fetch(options.url, options);
2323
}

packages/plugin-i18n/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
"webpack-dev-server": "^4.13.2"
5757
},
5858
"peerDependencies": {
59-
"@ice/app": "^3.3.2",
59+
"@ice/app": "^3.3.3",
6060
"@ice/runtime": "^1.2.9"
6161
},
6262
"publishConfig": {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# @ice/plugin-stream-error
2+
3+
## 1.0.0
4+
5+
### Major Changes
6+
7+
- f2c7df96: feat: plugin deal with stream error
+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# @ice/plugin-stream-error
2+
3+
A plugin for re-render app when stream error.
4+
5+
## Usage
6+
7+
```ts
8+
import { defineConfig } from '@ice/app';
9+
import streamError from '@ice/plugin-stream-error';
10+
11+
export default defineConfig(() => ({
12+
plugins: [
13+
streamError(),
14+
],
15+
}));
16+
```
17+
18+
> Causion: This plugin only works when stream content ends with javascripts which triggered an custom event of `stream_end`

0 commit comments

Comments
 (0)