mirror of https://github.com/alibaba/ice.git
Compare commits
23 Commits
b367b81bc4
...
e50cf46419
| Author | SHA1 | Date |
|---|---|---|
|
|
e50cf46419 | |
|
|
763a1e6602 | |
|
|
3d762f58b9 | |
|
|
a257d585af | |
|
|
096fa4ee7c | |
|
|
29f0a171ca | |
|
|
d9a2e91f5c | |
|
|
f177d1b22e | |
|
|
49c7c19974 | |
|
|
e82fa0f7b9 | |
|
|
4569200caf | |
|
|
22b10c0d1c | |
|
|
cc0792b0fd | |
|
|
80250ffe6e | |
|
|
3a02e7be8e | |
|
|
ebf15cd8c5 | |
|
|
795c1986f3 | |
|
|
4334c40409 | |
|
|
fb013fd43f | |
|
|
451839c5c7 | |
|
|
76ed8ffbc5 | |
|
|
b719564cd9 | |
|
|
3a99b620cf |
|
|
@ -1,8 +0,0 @@
|
|||
---
|
||||
'@ice/jsx-runtime': patch
|
||||
'@ice/plugin-i18n': patch
|
||||
'rax-compat': patch
|
||||
'@ice/app': patch
|
||||
---
|
||||
|
||||
chore: update @swc/helpers to 0.5.17
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
---
|
||||
'@ice/rspack-config': patch
|
||||
---
|
||||
|
||||
feat: add support for custom loaders in rspack configuration
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
---
|
||||
'@ice/plugin-miniapp': patch
|
||||
---
|
||||
|
||||
fix: miniapp using absolute path to match route manifest
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
---
|
||||
'@ice/miniapp-runtime': patch
|
||||
---
|
||||
|
||||
fix: enter same page twice then exit should not throw error
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
---
|
||||
'@ice/app': patch
|
||||
---
|
||||
|
||||
fix: missing jsx-plus transform when server bundler is webpack
|
||||
|
|
@ -1,5 +1,11 @@
|
|||
# @ice/appear
|
||||
|
||||
## 0.2.2
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 451839c5: fix appear event handler callback refs in WeexAppear component
|
||||
|
||||
## 0.2.1
|
||||
|
||||
### Patch Changes
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@ice/appear",
|
||||
"version": "0.2.1",
|
||||
"version": "0.2.2",
|
||||
"description": "",
|
||||
"main": "./esm/index.js",
|
||||
"types": "./esm/index.d.ts",
|
||||
|
|
|
|||
|
|
@ -12,21 +12,28 @@ const WeexAppear = forwardRef<any, AppearProps>((props, ref) => {
|
|||
// Use copy of childrenRef to avoid ref value changed in cleanup phase.
|
||||
const nodeRef = typeof childrenRef === 'object' ? childrenRef.current : null;
|
||||
|
||||
const appearHandler = (e: CustomEvent) => {
|
||||
onAppear?.(e);
|
||||
};
|
||||
// Return early if onAppear callback not specified.
|
||||
onAppear && nodeRef?.addEventListener('appear', (e: CustomEvent) => onAppear(e));
|
||||
onAppear && nodeRef?.addEventListener('appear', appearHandler);
|
||||
|
||||
return () => {
|
||||
onAppear && nodeRef?.removeEventListener('appear', (e: CustomEvent) => onAppear(e));
|
||||
onAppear && nodeRef?.removeEventListener('appear', appearHandler);
|
||||
};
|
||||
}, [childrenRef, onAppear]);
|
||||
|
||||
useEffect(() => {
|
||||
const nodeRef = typeof childrenRef === 'object' ? childrenRef.current : null;
|
||||
|
||||
onDisappear && nodeRef?.addEventListener('disappear', (e: CustomEvent) => onDisappear(e));
|
||||
const disappearHandler = (e: CustomEvent) => {
|
||||
onDisappear?.(e);
|
||||
};
|
||||
|
||||
onDisappear && nodeRef?.addEventListener('disappear', disappearHandler);
|
||||
|
||||
return () => {
|
||||
onDisappear && nodeRef?.removeEventListener('disappear', (e: CustomEvent) => onDisappear(e));
|
||||
onDisappear && nodeRef?.removeEventListener('disappear', disappearHandler);
|
||||
};
|
||||
}, [childrenRef, onDisappear]);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,25 @@
|
|||
# Changelog
|
||||
|
||||
## 3.6.3
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- cc0792b0: fix: minify server bundle when build in prod
|
||||
- Updated dependencies [cc0792b0]
|
||||
- @ice/runtime@1.5.3
|
||||
|
||||
## 3.6.2
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 41951673: chore: update @swc/helpers to 0.5.17
|
||||
- 795c1986: fix: compat esbuild config
|
||||
- use AST to get file exports instead of using import()
|
||||
- respect compileDependencies in webpack mode
|
||||
- 59414ba4: fix: missing jsx-plus transform when server bundler is webpack
|
||||
- Updated dependencies [182929ca]
|
||||
- @ice/rspack-config@1.2.4
|
||||
|
||||
## 3.6.1
|
||||
|
||||
### Patch Changes
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@ice/app",
|
||||
"version": "3.6.1",
|
||||
"version": "3.6.3",
|
||||
"description": "provide scripts and configuration used by web framework ice",
|
||||
"type": "module",
|
||||
"main": "./esm/index.js",
|
||||
|
|
|
|||
|
|
@ -184,6 +184,7 @@ export function createServerCompiler(options: Options) {
|
|||
// while it is not recommended
|
||||
loader: { '.js': 'jsx' },
|
||||
jsx: 'automatic',
|
||||
minify: !dev,
|
||||
sourcemap: typeof sourceMap === 'boolean'
|
||||
// Transform sourceMap for esbuild.
|
||||
? sourceMap : (sourceMap.includes('inline') ? 'inline' : !!sourceMap),
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import type { UserConfig } from '../../types/userConfig.js';
|
|||
import { logger } from '../../utils/logger.js';
|
||||
import { getExpandedEnvs } from '../../utils/runtimeEnv.js';
|
||||
import { RUNTIME_TMP_DIR } from '../../constant.js';
|
||||
import { getExportsVariables } from '../../utils/getExportsVariables.js';
|
||||
|
||||
const _dirname = typeof __dirname !== 'undefined' ? __dirname : path.dirname(fileURLToPath(import.meta.url));
|
||||
|
||||
|
|
@ -17,11 +18,12 @@ export class WebpackServerCompiler {
|
|||
}
|
||||
|
||||
private async createWebpackConfig(options: {
|
||||
compileIncludes: Array<RegExp>;
|
||||
userServerConfig: UserConfig['server'];
|
||||
rootDir: string;
|
||||
[key: string]: any;
|
||||
}) {
|
||||
const { userServerConfig } = options;
|
||||
const { userServerConfig, compileIncludes } = options;
|
||||
const { webpackConfig = {} } = userServerConfig;
|
||||
const definitions = await this.getEsbuildInject();
|
||||
return getWebpackConfig({
|
||||
|
|
@ -63,7 +65,7 @@ export class WebpackServerCompiler {
|
|||
define: options.define,
|
||||
optimization: { ...webpackConfig.optimization } as any,
|
||||
minify: options.minify,
|
||||
compileIncludes: webpackConfig.transformInclude,
|
||||
compileIncludes,
|
||||
swcOptions: {
|
||||
compilationConfig: {
|
||||
jsc: {
|
||||
|
|
@ -90,9 +92,9 @@ export class WebpackServerCompiler {
|
|||
|
||||
private async getEsbuildInject(): Promise<Record<string, string | string[]>> {
|
||||
const provideRecord = {};
|
||||
const allInjects = await Promise.all(this.options.inject.map((inj) => import(inj)));
|
||||
const allInjects = await Promise.all(this.options.inject.map((inj) => getExportsVariables(inj)));
|
||||
allInjects.forEach((injs, index) => {
|
||||
Object.keys(injs).forEach((key) => {
|
||||
injs.forEach((key) => {
|
||||
provideRecord[key] = [this.options.inject[index], key];
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -251,14 +251,7 @@ export interface UserConfig {
|
|||
/**
|
||||
* webpack config, only works when bundler is webpack
|
||||
*/
|
||||
webpackConfig?: Pick<WebpackConfiguration, 'plugins' | 'optimization' | 'output' | 'module'> & {
|
||||
/**
|
||||
* we exclude the node_modules/* by default
|
||||
*
|
||||
* use this if you need to transform some packages inside of node_modues
|
||||
*/
|
||||
transformInclude?: Array<RegExp | string>;
|
||||
};
|
||||
webpackConfig?: Pick<WebpackConfiguration, 'plugins' | 'optimization' | 'output' | 'module'>;
|
||||
};
|
||||
/**
|
||||
* Optimization options for build.
|
||||
|
|
|
|||
|
|
@ -0,0 +1,59 @@
|
|||
import fs from 'fs';
|
||||
import { swc } from '@ice/bundles';
|
||||
|
||||
/**
|
||||
* Parses a JavaScript file and extracts all named exports.
|
||||
*
|
||||
* @param {string} filePath The path to the JavaScript file.
|
||||
* @returns {Promise<string[]>} A promise that resolves to an array of collected export names.
|
||||
*/
|
||||
export async function getExportsVariables(filePath: string) {
|
||||
const fileContent = await fs.promises.readFile(filePath, 'utf-8');
|
||||
const ast = await swc.parse(fileContent, {
|
||||
syntax: 'ecmascript', // or 'typescript' if you might have TypeScript files
|
||||
jsx: true, // Set to true if you might have JSX
|
||||
});
|
||||
|
||||
const exportNames = new Set();
|
||||
|
||||
for (const node of ast.body) {
|
||||
if (node.type === 'ExportDeclaration') {
|
||||
// Handles: export const a = 1; export class MyClass {}
|
||||
if (node.declaration) {
|
||||
if (node.declaration.type === 'VariableDeclaration') {
|
||||
for (const declarator of node.declaration.declarations) {
|
||||
if (declarator.id.type === 'Identifier') {
|
||||
exportNames.add(declarator.id.value);
|
||||
} else if (declarator.id.type === 'ObjectPattern') {
|
||||
// Handles object destructuring in export: export const { a, b } = {};
|
||||
for (const prop of declarator.id.properties) {
|
||||
if (prop.type === 'Property' && prop.key.type === 'Identifier') {
|
||||
exportNames.add(prop.key.value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (node.declaration.type === 'FunctionDeclaration' || node.declaration.type === 'ClassDeclaration') {
|
||||
if (node.declaration.identifier) {
|
||||
exportNames.add(node.declaration.identifier.value);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (node.type === 'ExportNamedDeclaration') {
|
||||
// Handles: export { foo } from './foo'; export { foo as foo1 };
|
||||
// export * as aaa from './aaa'
|
||||
for (const specifier of node.specifiers) {
|
||||
if (specifier.type === 'ExportSpecifier') {
|
||||
exportNames.add((specifier.exported || specifier.orig).value);
|
||||
} else if (specifier.type === 'ExportNamespaceSpecifier') {
|
||||
exportNames.add(specifier.name.value);
|
||||
}
|
||||
}
|
||||
} else if (node.type === 'ExportDefaultExpression') {
|
||||
// Handles: export default ...
|
||||
exportNames.add('default');
|
||||
}
|
||||
}
|
||||
|
||||
return Array.from(exportNames);
|
||||
}
|
||||
|
|
@ -59,6 +59,7 @@ interface RenderOptions {
|
|||
publicPath?: string;
|
||||
serverData?: any;
|
||||
streamOptions?: RenderToPipeableStreamOptions;
|
||||
documentProps?: Record<string, unknown>;
|
||||
}
|
||||
|
||||
export async function renderToHTML(requestContext, options: RenderOptions = {}) {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,11 @@
|
|||
// @ts-nocheck
|
||||
export const a = 1;
|
||||
export function myFunc() {}
|
||||
export class MyClass {}
|
||||
const b = 2;
|
||||
export { b as c, myFunc as anotherFunc };
|
||||
export { foo } from './foo';
|
||||
export { default as bar } from './bar';
|
||||
export default 'hello';
|
||||
export { baz as qux } from './baz';
|
||||
export * as aaa from './aaa'
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
import path from 'path';
|
||||
import { fileURLToPath } from 'url';
|
||||
import { expect, test } from 'vitest';
|
||||
import { getExportsVariables } from '../src/utils/getExportsVariables';
|
||||
|
||||
const __dirname = fileURLToPath(path.dirname(import.meta.url));
|
||||
|
||||
test('getExportsVariables', async () => {
|
||||
const exports = await getExportsVariables(path.resolve(__dirname, './fixtures/exports.ts'));
|
||||
expect(exports).toStrictEqual(['a', 'myFunc', 'MyClass', 'c', 'anotherFunc', 'foo', 'bar', 'default', 'qux', 'aaa']);
|
||||
});
|
||||
|
|
@ -1,5 +1,11 @@
|
|||
# @ice/jsx-runtime
|
||||
|
||||
## 0.3.2
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 41951673: chore: update @swc/helpers to 0.5.17
|
||||
|
||||
## 0.3.1
|
||||
|
||||
### Patch Changes
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@ice/jsx-runtime",
|
||||
"version": "0.3.1",
|
||||
"version": "0.3.2",
|
||||
"description": "JSX runtime for ice.",
|
||||
"files": [
|
||||
"esm",
|
||||
|
|
|
|||
|
|
@ -1,5 +1,18 @@
|
|||
# @ice/miniapp-react-dom
|
||||
|
||||
## 1.1.4
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- @ice/miniapp-runtime@1.2.4
|
||||
|
||||
## 1.1.3
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [d27ad76c]
|
||||
- @ice/miniapp-runtime@1.2.3
|
||||
|
||||
## 1.1.2
|
||||
|
||||
### Patch Changes
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@ice/miniapp-react-dom",
|
||||
"version": "1.1.2",
|
||||
"version": "1.1.4",
|
||||
"description": "like react-dom, but for miniapps.",
|
||||
"type": "module",
|
||||
"types": "./esm/index.d.ts",
|
||||
|
|
|
|||
|
|
@ -1,5 +1,18 @@
|
|||
# Changelog
|
||||
|
||||
## 1.2.4
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [cc0792b0]
|
||||
- @ice/runtime@1.5.3
|
||||
|
||||
## 1.2.3
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- d27ad76c: fix: enter same page twice then exit should not throw error
|
||||
|
||||
## 1.2.2
|
||||
|
||||
### Patch Changes
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@ice/miniapp-runtime",
|
||||
"version": "1.2.2",
|
||||
"version": "1.2.4",
|
||||
"description": "ice runtime for miniapps.",
|
||||
"type": "module",
|
||||
"types": "./esm/index.d.ts",
|
||||
|
|
|
|||
|
|
@ -1,5 +1,11 @@
|
|||
# @ice/plugin-externals
|
||||
|
||||
## 1.0.1
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 4569200c: fix: support externals field in assets-manifest
|
||||
|
||||
## 1.0.0
|
||||
|
||||
- Initial release
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@ice/plugin-externals",
|
||||
"version": "1.0.0",
|
||||
"version": "1.0.1",
|
||||
"description": "plugin to make externals much easier in ice.js",
|
||||
"files": [
|
||||
"esm",
|
||||
|
|
@ -21,7 +21,7 @@
|
|||
},
|
||||
"devDependencies": {
|
||||
"@ice/app": "^3.3.2",
|
||||
"@ice/runtime": "^1.2.9",
|
||||
"@ice/runtime": "^1.5.4",
|
||||
"@types/react": "^18.0.0",
|
||||
"@types/react-dom": "^18.0.0",
|
||||
"webpack": "^5.88.0"
|
||||
|
|
|
|||
|
|
@ -26,7 +26,9 @@ export default class InjectExternalScriptsWebpackPlugin {
|
|||
if (assetsManifest) {
|
||||
const json = JSON.parse(assetsManifest.source().toString());
|
||||
delete compilation.assets[ASSET_MANIFEST_JSON_NAME];
|
||||
json.entries.main.unshift(...this.options.externals);
|
||||
// Ensure externals array exists and add new externals at the beginning.
|
||||
json.externals ||= [];
|
||||
json.externals.unshift(...this.options.externals);
|
||||
compilation.emitAsset(
|
||||
ASSET_MANIFEST_JSON_NAME,
|
||||
new webpack.sources.RawSource(JSON.stringify(json)),
|
||||
|
|
|
|||
|
|
@ -1,5 +1,16 @@
|
|||
# @ice/plugin-i18n
|
||||
|
||||
## 5.0.2
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 41951673: chore: update @swc/helpers to 0.5.17
|
||||
- Updated dependencies [41951673]
|
||||
- Updated dependencies [795c1986]
|
||||
- Updated dependencies [59414ba4]
|
||||
- @ice/jsx-runtime@0.3.2
|
||||
- @ice/app@3.6.2
|
||||
|
||||
## 5.0.1
|
||||
|
||||
### Patch Changes
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@ice/plugin-i18n",
|
||||
"version": "5.0.1",
|
||||
"version": "5.0.2",
|
||||
"description": "I18n plugin for ice.js 3.",
|
||||
"files": [
|
||||
"es2017",
|
||||
|
|
@ -39,7 +39,7 @@
|
|||
"plugin"
|
||||
],
|
||||
"dependencies": {
|
||||
"@ice/jsx-runtime": "^0.3.1",
|
||||
"@ice/jsx-runtime": "^0.3.2",
|
||||
"@swc/helpers": "^0.5.17",
|
||||
"accept-language-parser": "^1.5.0",
|
||||
"universal-cookie": "^4.0.4",
|
||||
|
|
@ -56,8 +56,8 @@
|
|||
"webpack-dev-server": "4.15.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@ice/app": "^3.6.1",
|
||||
"@ice/runtime": "^1.5.2"
|
||||
"@ice/app": "^3.6.3",
|
||||
"@ice/runtime": "^1.5.4"
|
||||
},
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
|
|
|
|||
|
|
@ -1,5 +1,9 @@
|
|||
# Changelog
|
||||
|
||||
## 1.2.1
|
||||
|
||||
- fix: plugin type definition of `library`
|
||||
|
||||
## 1.2.0
|
||||
|
||||
### Minor Changes
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@ice/plugin-icestark",
|
||||
"version": "1.2.0",
|
||||
"version": "1.2.1",
|
||||
"description": "Easy use `icestark` in icejs.",
|
||||
"author": "ice-admin@alibaba-inc.com",
|
||||
"homepage": "",
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ import type { Plugin } from '@ice/app/types';
|
|||
|
||||
interface PluginOptions {
|
||||
type: 'child' | 'framework';
|
||||
library?: string;
|
||||
library?: string | string[];
|
||||
}
|
||||
|
||||
const PLUGIN_NAME = '@ice/plugin-icestark';
|
||||
|
|
|
|||
|
|
@ -1,5 +1,28 @@
|
|||
# Changelog
|
||||
|
||||
## 1.2.6
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- @ice/miniapp-runtime@1.2.5
|
||||
- @ice/miniapp-react-dom@1.1.5
|
||||
|
||||
## 1.2.5
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- @ice/miniapp-runtime@1.2.4
|
||||
- @ice/miniapp-react-dom@1.1.4
|
||||
|
||||
## 1.2.4
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 3670eadc: fix: miniapp using absolute path to match route manifest
|
||||
- Updated dependencies [d27ad76c]
|
||||
- @ice/miniapp-runtime@1.2.3
|
||||
- @ice/miniapp-react-dom@1.1.3
|
||||
|
||||
## 1.2.3
|
||||
|
||||
### Patch Changes
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@ice/plugin-miniapp",
|
||||
"version": "1.2.3",
|
||||
"version": "1.2.6",
|
||||
"description": "ice.js plugin for miniapp.",
|
||||
"license": "MIT",
|
||||
"type": "module",
|
||||
|
|
@ -50,8 +50,8 @@
|
|||
"sax": "^1.2.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@ice/app": "^3.6.1",
|
||||
"@ice/runtime": "^1.5.2",
|
||||
"@ice/app": "^3.6.3",
|
||||
"@ice/runtime": "^1.5.4",
|
||||
"webpack": "^5.88.0"
|
||||
},
|
||||
"repository": {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,11 @@
|
|||
# Changelog
|
||||
|
||||
## 0.4.1
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 41951673: chore: update @swc/helpers to 0.5.17
|
||||
|
||||
## 0.4.0
|
||||
|
||||
### Minor Changes
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "rax-compat",
|
||||
"version": "0.4.0",
|
||||
"version": "0.4.1",
|
||||
"description": "Rax compatible mode, running rax project on the react runtime.",
|
||||
"files": [
|
||||
"esm",
|
||||
|
|
|
|||
|
|
@ -1,5 +1,11 @@
|
|||
# @ice/rspack-config
|
||||
|
||||
## 1.2.4
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 182929ca: feat: add support for custom loaders in rspack configuration
|
||||
|
||||
## 1.2.3
|
||||
|
||||
### Patch Changes
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@ice/rspack-config",
|
||||
"version": "1.2.3",
|
||||
"version": "1.2.4",
|
||||
"repository": "alibaba/ice",
|
||||
"bugs": "https://github.com/alibaba/ice/issues",
|
||||
"homepage": "https://v3.ice.work",
|
||||
|
|
|
|||
|
|
@ -1,5 +1,17 @@
|
|||
# @ice/runtime
|
||||
|
||||
## 1.5.4
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 4569200c: fix: support externals field in assets-manifest
|
||||
|
||||
## 1.5.3
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- cc0792b0: feat: support custom props when render document
|
||||
|
||||
## 1.5.2
|
||||
|
||||
### Patch Changes
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@ice/runtime",
|
||||
"version": "1.5.2",
|
||||
"version": "1.5.4",
|
||||
"description": "Runtime module for ice.js",
|
||||
"type": "module",
|
||||
"types": "./esm/index.d.ts",
|
||||
|
|
|
|||
|
|
@ -129,6 +129,9 @@ export const Scripts: ScriptsType = (props: ScriptsProps) => {
|
|||
return (
|
||||
<>
|
||||
<Data ScriptElement={ScriptElement} />
|
||||
{assetsManifest.externals?.map(external => (
|
||||
<ScriptElement key={external} src={external} {...rest} data-external-script />
|
||||
))}
|
||||
{
|
||||
routeScripts.map(routeScriptProps => {
|
||||
return <ScriptElement key={routeScriptProps.src} {...rest} {...routeScriptProps} data-route-script />;
|
||||
|
|
|
|||
|
|
@ -45,6 +45,7 @@ export function renderDocument(options: RenderDocumentOptions): Response {
|
|||
basename,
|
||||
routesConfig = {},
|
||||
serverData,
|
||||
documentProps,
|
||||
} = renderOptions;
|
||||
|
||||
const appData = null;
|
||||
|
|
@ -84,7 +85,7 @@ export function renderDocument(options: RenderDocumentOptions): Response {
|
|||
<AppContextProvider value={appContext}>
|
||||
<DocumentContextProvider value={documentContext}>
|
||||
{
|
||||
Document && <Document pagePath={routePath} />
|
||||
Document && <Document pagePath={routePath} {...documentProps} />
|
||||
}
|
||||
</DocumentContextProvider>
|
||||
</AppContextProvider>,
|
||||
|
|
|
|||
|
|
@ -283,7 +283,7 @@ async function renderServerEntry(
|
|||
renderOptions,
|
||||
}: RenderServerEntry,
|
||||
): Promise<Response> {
|
||||
const { Document } = renderOptions;
|
||||
const { Document, documentProps } = renderOptions;
|
||||
const appContext = runtime.getAppContext();
|
||||
const { routes, routePath, loaderData, basename } = appContext;
|
||||
const AppRuntimeProvider = runtime.composeAppProvider() || React.Fragment;
|
||||
|
|
@ -307,7 +307,7 @@ async function renderServerEntry(
|
|||
<AppRuntimeProvider>
|
||||
<DocumentContextProvider value={documentContext}>
|
||||
{
|
||||
Document && <Document pagePath={routePath} />
|
||||
Document && <Document pagePath={routePath} {...documentProps} />
|
||||
}
|
||||
</DocumentContextProvider>
|
||||
</AppRuntimeProvider>
|
||||
|
|
|
|||
|
|
@ -205,6 +205,7 @@ export interface RouteModules {
|
|||
}
|
||||
|
||||
export interface AssetsManifest {
|
||||
externals?: string[];
|
||||
dataLoader?: string;
|
||||
publicPath: string;
|
||||
entries: {
|
||||
|
|
@ -338,6 +339,7 @@ export interface RenderOptions {
|
|||
runtimeOptions?: Record<string, any>;
|
||||
serverData?: any;
|
||||
streamOptions?: RenderToPipeableStreamOptions;
|
||||
documentProps?: Record<string, unknown>;
|
||||
}
|
||||
|
||||
declare global {
|
||||
|
|
|
|||
|
|
@ -1962,10 +1962,10 @@ importers:
|
|||
packages/plugin-externals:
|
||||
devDependencies:
|
||||
'@ice/app':
|
||||
specifier: ^3.3.2
|
||||
specifier: ^3.6.4
|
||||
version: link:../ice
|
||||
'@ice/runtime':
|
||||
specifier: ^1.2.9
|
||||
specifier: ^1.5.4
|
||||
version: link:../runtime
|
||||
'@types/react':
|
||||
specifier: ^18.0.0
|
||||
|
|
@ -1990,7 +1990,7 @@ importers:
|
|||
packages/plugin-i18n:
|
||||
dependencies:
|
||||
'@ice/jsx-runtime':
|
||||
specifier: ^0.3.1
|
||||
specifier: ^0.3.2
|
||||
version: link:../jsx-runtime
|
||||
'@swc/helpers':
|
||||
specifier: ^0.5.17
|
||||
|
|
@ -2157,10 +2157,10 @@ importers:
|
|||
version: 1.2.4
|
||||
devDependencies:
|
||||
'@ice/app':
|
||||
specifier: ^3.6.1
|
||||
specifier: ^3.6.4
|
||||
version: link:../ice
|
||||
'@ice/runtime':
|
||||
specifier: ^1.5.2
|
||||
specifier: ^1.5.4
|
||||
version: link:../runtime
|
||||
webpack:
|
||||
specifier: ^5.88.0
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ describe(`build ${example}`, () => {
|
|||
sizeFallback = fs.statSync(fallbackPath).size;
|
||||
|
||||
expect(sizeFallback).toBeLessThan(sizeServer);
|
||||
// The Stat size of fallback entry will reduce more than 50kb.
|
||||
expect(sizeServer - sizeFallback).toBeGreaterThan(50 * 1024);
|
||||
// The Stat size of fallback entry will reduce more than 50kb, minify size is 20kb.
|
||||
expect(sizeServer - sizeFallback).toBeGreaterThan(20 * 1024);
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -56,7 +56,6 @@ nrm use taobao
|
|||
- [Visual Studio Code](https://code.visualstudio.com/)(推荐)
|
||||
- [WebStorm](https://www.jetbrains.com/webstorm/)(推荐)
|
||||
- [Sublime Text](https://www.sublimetext.com/)
|
||||
- [Atom](https://atom.io/)
|
||||
|
||||
## 小程序开发者工具
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue