Skip to content

Commit ae705c0

Browse files
authored
Merge pull request #6369 from alibaba/release/next
Release 3.2.7
2 parents 170fe47 + 76ef029 commit ae705c0

25 files changed

+441
-56
lines changed

packages/ice/CHANGELOG.md

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

3+
## 3.2.7
4+
5+
### Patch Changes
6+
7+
- 429a2a83: fix: relative id in pipe transform
8+
- c7aad4eb: chore: add user config comments
9+
- d8f4520f: fix: alias for type declaration
10+
- 110b282b: feat: support user config htmlGenerating to control the generation of html
11+
- Updated dependencies [29ad1b52]
12+
- @ice/runtime@1.2.5
13+
314
## 3.2.6
415

516
### Patch Changes

packages/ice/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@ice/app",
3-
"version": "3.2.6",
3+
"version": "3.2.7",
44
"description": "provide scripts and configuration used by web framework ice",
55
"type": "module",
66
"main": "./esm/index.js",
@@ -38,7 +38,7 @@
3838
"dependencies": {
3939
"@ice/bundles": "0.1.12",
4040
"@ice/route-manifest": "1.2.0",
41-
"@ice/runtime": "^1.2.4",
41+
"@ice/runtime": "^1.2.5",
4242
"@ice/webpack-config": "1.0.18",
4343
"@swc/helpers": "0.5.1",
4444
"@types/express": "^4.17.14",

packages/ice/src/commands/build.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -142,13 +142,17 @@ const build = async (
142142
distType,
143143
prependCode,
144144
},
145+
htmlGenerating,
145146
} = userConfig;
146147
let renderMode: RenderMode;
147148
if (ssg) {
148149
renderMode = 'SSG';
150+
if (!htmlGenerating) {
151+
logger.warn('SSG depends on htmlGenerating, SSG will not work when htmlGenerating is set to false.');
152+
}
149153
}
150154
const { serverEntry } = await serverCompileTask.get() || {};
151-
if (serverEntry) {
155+
if (serverEntry && htmlGenerating) {
152156
serverEntryRef.current = serverEntry;
153157
const routeType = appConfig?.router?.type;
154158
const {

packages/ice/src/config.ts

+5
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,11 @@ const userConfig = [
389389
validation: 'object',
390390
defaultValue: {},
391391
},
392+
{
393+
name: 'htmlGenerating',
394+
validation: 'boolean',
395+
defaultValue: true,
396+
},
392397
];
393398

394399
const cliOption = [

packages/ice/src/esbuild/transformPipe.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,8 @@ const transformPipe = (options: PluginOptions = {}): Plugin => {
100100
const resolveDir = path.dirname(args.path);
101101
const loader = guessLoader(id);
102102

103-
// If file extension is not recognized, return it to esbuild.
104-
if (!loader) {
103+
// If file extension is not recognized and load path is relative, return it to esbuild.
104+
if (!loader || !path.isAbsolute(id)) {
105105
return;
106106
}
107107

packages/ice/src/service/runtimeGenerator.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,11 @@ export function generateDeclaration(exportList: Array<TargetDeclarationData | De
8686
const symbol = type ? ';' : ',';
8787

8888
if (specifier) {
89-
importDeclarations.push(`import ${type ? 'type ' : ''}${isDefaultImport ? specifier : `{ ${specifiers.map(specifierStr => (specifierStr)).join(', ')} }`} from '${source}';`);
89+
importDeclarations.push(`import ${type ? 'type ' : ''}${isDefaultImport ? specifier : `{ ${specifiers.map(specifierStr => ((alias && alias[specifierStr]) ? `${specifierStr} as ${alias[specifierStr]}` : specifierStr)).join(', ')} }`} from '${source}';`);
9090

9191
specifiers.forEach((specifierStr) => {
9292
if (alias && alias[specifierStr]) {
93-
exportDeclarations.push(`${specifierStr} as ${alias[specifierStr]}${symbol}`);
93+
exportDeclarations.push(`${alias[specifierStr]}${symbol}`);
9494
exportNames.push(alias[specifierStr]);
9595
} else {
9696
exportDeclarations.push(`${specifierStr}${symbol}`);

packages/ice/src/types/userConfig.ts

+169-2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ interface SyntaxFeatures {
1212
}
1313

1414
interface Optimization {
15+
/**
16+
* Optimize code by remove react-router dependencies when set to true.
17+
*/
1518
router?: boolean;
1619
}
1720

@@ -33,60 +36,224 @@ interface Fetcher {
3336
}
3437

3538
export interface UserConfig {
39+
/**
40+
* Feature polyfill for legacy browsers, which can not polyfilled by core-js.
41+
* @see https://v3.ice.work/docs/guide/basic/config#featurepolyfill
42+
*/
3643
featurePolyfill?: {
3744
abortcontroller?: boolean | string;
3845
};
3946
output?: {
4047
distType: Array<DistType> | DistType;
4148
prependCode?: string;
4249
};
50+
/**
51+
* Alias for import certain modules more easily.
52+
* @see https://v3.ice.work/docs/guide/basic/config#alias
53+
*/
4354
alias?: Record<string, string | false>;
55+
/**
56+
* Define global constants which can be configured at compile time.
57+
* @see https://v3.ice.work/docs/guide/basic/config#define
58+
*/
4459
define?: Record<string, string | boolean>;
60+
/**
61+
* Configure the publicPath, it only works in dev mode.
62+
* @see https://v3.ice.work/docs/guide/basic/config#devpublicpath
63+
*/
4564
devPublicPath?: string;
65+
/**
66+
* Configure the publicPath, it only works in prod mode.
67+
* @see https://v3.ice.work/docs/guide/basic/config#publicpath
68+
*/
4669
publicPath?: string;
70+
/**
71+
* Configure hash based file name.
72+
* @see https://v3.ice.work/docs/guide/basic/config#hash
73+
*/
4774
hash?: boolean | string;
75+
/**
76+
* Configure externals to prevent bundling certain imported packages and
77+
* instead retrieve these external dependencies at runtime.
78+
* @see https://v3.ice.work/docs/guide/basic/config#externals
79+
*/
4880
externals?: Config['externals'];
81+
/**
82+
* The output directory for build command.
83+
* @see https://v3.ice.work/docs/guide/basic/config#outputdir
84+
*/
4985
outputDir?: string;
86+
/**
87+
* Proxy configuration for dev server, as same as webpack devServer.proxy.
88+
* @see https://v3.ice.work/docs/guide/basic/config#proxy
89+
*/
5090
proxy?: Config['proxy'];
91+
/**
92+
* Polyfill mode for legacy browsers, works with .browserslistrc, support entry and usage.
93+
* @see https://v3.ice.work/docs/guide/basic/config#polyfill
94+
*/
5195
polyfill?: Config['polyfill'];
96+
/**
97+
* Configure the output file name of build bundle.
98+
*/
5299
filename?: string;
100+
/**
101+
* Modify the webpack configuration, it is not recommended.
102+
* @see https://v3.ice.work/docs/guide/basic/config#webpack
103+
*/
53104
webpack?: ModifyWebpackConfig;
54-
postcss?: ProcessOptions & { plugins?: (string | [string, Record<string, any>?])[] };
105+
/**
106+
* Allows to set PostCSS options and plugins.
107+
* @see https://v3.ice.work/docs/guide/basic/config#postcss
108+
*/
109+
postcss?: ProcessOptions & {
110+
plugins?: (string | [string, Record<string, any>?])[];
111+
};
112+
/**
113+
* Custom file-system based route rules.
114+
* @see https://v3.ice.work/docs/guide/basic/config#routes
115+
*/
55116
routes?: {
117+
/**
118+
* Ignore files when generate routes when match rule.
119+
*/
56120
ignoreFiles?: string[];
121+
/**
122+
* Define route rules by API.
123+
*/
57124
defineRoutes?: (defineRoute: DefineRouteFunction) => void;
125+
/**
126+
* Define route rules by route config.
127+
*/
58128
config?: RouteItem[];
129+
/**
130+
* inject initial route path for each route html.
131+
*/
59132
injectInitialEntry?: boolean;
60133
};
134+
/**
135+
* Add ice.js plugin to customize framework config.
136+
* @see https://v3.ice.work/docs/guide/basic/config#plugins
137+
*/
61138
plugins?: PluginList<Config, OverwritePluginAPI>;
139+
/**
140+
* `console.*` will be dropped when build.
141+
* @see https://v3.ice.work/docs/guide/basic/config#droploglevel
142+
*/
62143
dropLogLevel?: 'trace' | 'debug' | 'log' | 'info' | 'warn' | 'error';
144+
/**
145+
* Minify build output, it only works in prod mode by default.
146+
* @see https://v3.ice.work/docs/guide/basic/config#minify
147+
*/
63148
minify?: boolean | 'swc' | MinifyOptions;
149+
/**
150+
* Compile dependencies, ice.js will compile all dependencies by default when build for compatibility.
151+
* @see https://v3.ice.work/docs/guide/basic/config#compiledependencies
152+
*/
64153
compileDependencies?: boolean | string[] | RegExp[];
154+
/**
155+
* HTML will not be generated when build, If it is false.
156+
* @see https://v3.ice.work/docs/guide/basic/config#htmlgenerating
157+
*/
158+
htmlGenerating?: boolean;
159+
/**
160+
* Choose a style of souce mapping to enhance the debugging process.
161+
* @see https://v3.ice.work/docs/guide/basic/config#sourcemap
162+
*/
65163
sourceMap?: string | boolean;
164+
/**
165+
* Check typescript when compile source code.
166+
* @see https://v3.ice.work/docs/guide/basic/config#tschecker
167+
*/
66168
tsChecker?: boolean;
169+
/**
170+
* Check source code by eslint if eslint options is configured.
171+
* @see https://v3.ice.work/docs/guide/basic/config#eslint
172+
*/
67173
eslint?: Config['eslintOptions'] | boolean;
174+
/**
175+
* A switch for SSR (Server Side Rendering)
176+
* @see https://v3.ice.work/docs/guide/basic/config#ssr
177+
*/
68178
ssr?: boolean;
179+
/**
180+
* A switch for SSG (Static Site Generation), it is true by default.
181+
* @see https://v3.ice.work/docs/guide/basic/config#ssg
182+
*/
69183
ssg?: boolean;
184+
/**
185+
* config for server bundle
186+
* @see https://v3.ice.work/docs/guide/basic/config#server
187+
*/
70188
server?: {
189+
/**
190+
* onDemand compilation for server when dev
191+
*/
71192
onDemand?: boolean;
193+
/**
194+
* bundle format for server bundle, support esm and cjs
195+
*/
72196
format?: 'esm' | 'cjs';
197+
/**
198+
* bundle server code as a single file
199+
*/
73200
bundle?: boolean;
201+
/**
202+
* ignore file when bundle server code, module return empty when match
203+
*/
74204
ignores?: IgnorePattern[];
205+
/**
206+
* externals config for server bundle
207+
*/
75208
externals?: string[];
76209
};
210+
/**
211+
* Optimization options for build.
212+
* @sse https://v3.ice.work/docs/guide/basic/config#optimization
213+
*/
77214
optimization?: Optimization;
78-
mock?: { exclude?: string[] };
215+
/**
216+
* Configure mock rules for development.
217+
* @see https://v3.ice.work/docs/guide/basic/config#mock
218+
*/
219+
mock?: {
220+
exclude?: string[];
221+
};
222+
/**
223+
* Config for experimental features.
224+
* @see https://v3.ice.work/docs/guide/basic/config#experimental
225+
*/
79226
experimental?: Config['experimental'];
227+
/**
228+
* Custom transform rules for source code.
229+
* @see https://v3.ice.work/docs/guide/basic/config#transform
230+
*/
80231
transform?: UnpluginOptions['transform'];
232+
/**
233+
* Specify the syntax features you want to use.
234+
* @see https://v3.ice.work/docs/guide/basic/config#syntaxfeatures
235+
*/
81236
syntaxFeatures?: SyntaxFeatures;
82237
/**
83238
* @deprecated
84239
* Please use `codeSplitting` instead
85240
*/
86241
splitChunks?: boolean;
242+
/**
243+
* Code splitting strategy, support page and vendors, default value is true (built-in strategy).
244+
* @see https://v3.ice.work/docs/guide/basic/config#codesplitting
245+
*/
87246
codeSplitting?: 'page' | 'vendors' | boolean;
247+
/**
248+
* generate additional assets for request data, default is true
249+
* @see https://v3.ice.work/docs/guide/basic/config#dataloader
250+
*/
88251
dataLoader?: {
89252
fetcher?: Fetcher;
90253
} | Boolean;
254+
/**
255+
* Enable cross-origin loading of chunks.
256+
* @see https://v3.ice.work/docs/guide/basic/config#crossoriginloading
257+
*/
91258
crossOriginLoading?: Config['output']['crossOriginLoading'];
92259
}

packages/ice/templates/core/types.ts.ejs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
<%- routeConfigTypes.imports -%>
21
import type { AppConfig, RouteConfig as DefaultRouteConfig } from '@ice/runtime';
2+
<%- routeConfigTypes.imports -%>
33

44
<% if (routeConfigTypes.imports) {-%>
55
type ExtendsRouteConfig = <% if (routeConfigTypes.imports) { %><%- routeConfigTypes.exportNames.join(' & ') %><% } %>;

packages/ice/tests/generator.test.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,14 @@ describe('generateDeclaration', () => {
3939
it('aliased exports', () => {
4040
const { importStr, exportStr } = generateDeclaration([{
4141
source: 'react-helmet',
42-
specifier: 'Helmet',
42+
specifier: ['Helmet'],
4343
alias: {
4444
Helmet: 'Head',
4545
},
4646
declarationType: DeclarationType.NORMAL,
4747
}]);
48-
expect(importStr).toBe('import Helmet from \'react-helmet\';');
49-
expect(exportStr).toBe('Helmet as Head,');
48+
expect(importStr).toBe('import { Helmet as Head } from \'react-helmet\';');
49+
expect(exportStr).toBe('Head,');
5050
});
5151
});
5252

packages/plugin-i18n/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@
5555
"webpack-dev-server": "^4.13.2"
5656
},
5757
"peerDependencies": {
58-
"@ice/app": "^3.2.6",
59-
"@ice/runtime": "^1.2.4"
58+
"@ice/app": "^3.2.7",
59+
"@ice/runtime": "^1.2.5"
6060
},
6161
"publishConfig": {
6262
"access": "public"

packages/plugin-pha/CHANGELOG.md

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

3+
## 3.0.1
4+
5+
### Patch Changes
6+
7+
- 110b282b: fix: do not render document when template is set to false
8+
39
## 3.0.0
410

511
### Major Changes

packages/plugin-pha/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@ice/plugin-pha",
3-
"version": "3.0.0",
3+
"version": "3.0.1",
44
"description": "ice.js plugin for PHA.",
55
"license": "MIT",
66
"type": "module",
@@ -25,7 +25,7 @@
2525
"htmlparser2": "^8.0.1"
2626
},
2727
"devDependencies": {
28-
"@ice/app": "^3.2.6",
28+
"@ice/app": "^3.2.7",
2929
"build-scripts": "^2.1.1-0",
3030
"esbuild": "^0.17.16",
3131
"webpack": "^5.86.0",

0 commit comments

Comments
 (0)