mirror of https://github.com/alibaba/ice.git
commit
7cec9980fd
|
@ -6,6 +6,7 @@ export default defineConfig(() => ({
|
|||
ignoreFiles: ['about.tsx', 'products.tsx'],
|
||||
defineRoutes: (route) => {
|
||||
route('/about-me', 'about.tsx');
|
||||
route('/about.html', 'about.tsx');
|
||||
|
||||
route('/', 'layout.tsx', () => {
|
||||
route('/product', 'products.tsx');
|
||||
|
|
|
@ -1,6 +1,10 @@
|
|||
import * as React from 'react';
|
||||
import { Link } from 'ice';
|
||||
import { Link, definePageConfig } from 'ice';
|
||||
|
||||
export default function About() {
|
||||
return <><h2>About</h2><Link to="/">home</Link></>;
|
||||
}
|
||||
|
||||
export const pageConfig = definePageConfig(() => ({
|
||||
|
||||
}));
|
|
@ -1,5 +1,13 @@
|
|||
# Changelog
|
||||
|
||||
## 3.2.2
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- f652be72: fix: import identifier is invalid in route config
|
||||
- Updated dependencies [a4b85144]
|
||||
- @ice/webpack-config@1.0.15
|
||||
|
||||
## 3.2.1
|
||||
|
||||
### Patch Changes
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@ice/app",
|
||||
"version": "3.2.1",
|
||||
"version": "3.2.2",
|
||||
"description": "provide scripts and configuration used by web framework ice",
|
||||
"type": "module",
|
||||
"main": "./esm/index.js",
|
||||
|
@ -39,7 +39,7 @@
|
|||
"@ice/bundles": "0.1.10",
|
||||
"@ice/route-manifest": "1.2.0",
|
||||
"@ice/runtime": "^1.2.1",
|
||||
"@ice/webpack-config": "1.0.14",
|
||||
"@ice/webpack-config": "1.0.15",
|
||||
"@swc/helpers": "0.5.1",
|
||||
"@types/express": "^4.17.14",
|
||||
"address": "^1.1.2",
|
||||
|
|
|
@ -66,7 +66,7 @@ export function getRoutesDefinition(nestRouteManifest: NestedRouteManifest[], la
|
|||
if (lazy) {
|
||||
loadStatement = `import(/* webpackChunkName: "p_${componentName}" */ '${formatPath(componentPath)}')`;
|
||||
} else {
|
||||
const routeSpecifier = id.replace(/[./-]/g, '_').replace(/[:*]/g, '$');
|
||||
const routeSpecifier = formatRouteSpecifier(id);
|
||||
routeImports.push(`import * as ${routeSpecifier} from '${formatPath(componentPath)}';`);
|
||||
loadStatement = routeSpecifier;
|
||||
}
|
||||
|
@ -145,7 +145,7 @@ function generateRouteConfig(
|
|||
const componentFile = file.replace(new RegExp(`${fileExtname}$`), '');
|
||||
const componentPath = path.isAbsolute(componentFile) ? componentFile : `@/pages/${componentFile}`;
|
||||
|
||||
const loaderName = `${exportKey}_${id}`.replace(/[-/]/g, '_');
|
||||
const loaderName = formatRouteSpecifier(`${exportKey}_${id}`);
|
||||
const fullPath = path.join(parentPath, routePath);
|
||||
imports.push([id, loaderName, fullPath]);
|
||||
str = `import { ${exportKey} as ${loaderName} } from '${componentPath}';\n`;
|
||||
|
@ -162,3 +162,7 @@ function generateRouteConfig(
|
|||
}
|
||||
return template(importConfig(routes, ''), imports);
|
||||
}
|
||||
|
||||
function formatRouteSpecifier(routeId: string) {
|
||||
return routeId.replace(/[./-]/g, '_').replace(/[:*]/g, '$');
|
||||
}
|
||||
|
|
|
@ -55,7 +55,7 @@
|
|||
"webpack-dev-server": "^4.13.2"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@ice/app": "^3.2.1",
|
||||
"@ice/app": "^3.2.2",
|
||||
"@ice/runtime": "^1.2.1"
|
||||
},
|
||||
"publishConfig": {
|
||||
|
|
|
@ -1,5 +1,11 @@
|
|||
# Changelog
|
||||
|
||||
## 1.0.15
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- a4b85144: fix: compatible with code has import.meta
|
||||
|
||||
## 1.0.14
|
||||
|
||||
### Patch Changes
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@ice/webpack-config",
|
||||
"version": "1.0.14",
|
||||
"version": "1.0.15",
|
||||
"repository": "alibaba/ice",
|
||||
"bugs": "https://github.com/alibaba/ice/issues",
|
||||
"homepage": "https://v3.ice.work",
|
||||
|
|
|
@ -12,7 +12,8 @@ const transformImport = async (source: string, coreJsPath: string) => {
|
|||
const str = () => s || (s = new MagicString(source));
|
||||
const isESM = exports.length > 0 || imports.some((targetImport) => {
|
||||
const importString = targetImport.n;
|
||||
return !importString.includes('core-js') && !importString.includes('@swc/helpers');
|
||||
// `targetImport.n` get undefined when code has `import.meta.*`.
|
||||
return importString && !importString.includes('core-js') && !importString.includes('@swc/helpers');
|
||||
});
|
||||
imports.forEach((targetImport) => {
|
||||
if (!targetImport.n) {
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
if (import.meta.rerender === 'client') console.log(true);
|
|
@ -47,4 +47,9 @@ describe('transform core js path', () => {
|
|||
expect(await transformImport(orignalCode, coreJsPath))
|
||||
.toBe('var _object_spread = require(\'@swc/helpers/cjs/_object_spread.cjs\')._;module.exports = {};');
|
||||
});
|
||||
it('with import.meta', async () => {
|
||||
const orignalCode = fs.readFileSync(path.join(__dirname, './fixtures/transformImport/importMeta.js'), 'utf-8');
|
||||
expect(await transformImport(orignalCode, coreJsPath))
|
||||
.toBe('if (import.meta.rerender === \'client\') console.log(true);');
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1058,7 +1058,7 @@ importers:
|
|||
'@ice/bundles': 0.1.10
|
||||
'@ice/route-manifest': 1.2.0
|
||||
'@ice/runtime': ^1.2.1
|
||||
'@ice/webpack-config': 1.0.14
|
||||
'@ice/webpack-config': 1.0.15
|
||||
'@swc/helpers': 0.5.1
|
||||
'@types/babel__generator': ^7.6.4
|
||||
'@types/babel__traverse': ^7.17.1
|
||||
|
|
Loading…
Reference in New Issue