-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4010 from alibaba/release-next
Release/1.4.1
- Loading branch information
Showing
166 changed files
with
4,139 additions
and
1,440 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import React from 'react'; | ||
import ReactDOM from 'react-dom'; | ||
|
||
ReactDOM.render(<h2>Detail Page</h2>, document.body); |
12 changes: 6 additions & 6 deletions
12
examples/basic-spa/mock/index.js → examples/basic-spa/mock/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,17 @@ | ||
const projects = require('./projects'); | ||
import projects from './projects'; | ||
|
||
const status = 'SUCCESS'; | ||
// mock/index.js | ||
module.exports = { | ||
export default { | ||
'GET /api/repo': { | ||
status: 'SUCCESS', | ||
status, | ||
data: { | ||
group: 'ice.js', | ||
url: 'http://github.com/ice-lab/ice.js' | ||
} | ||
}, | ||
|
||
'GET /api/projects': { | ||
status: 'SUCCESS', | ||
data: projects | ||
status, | ||
data: projects | ||
} | ||
}; |
2 changes: 1 addition & 1 deletion
2
examples/basic-spa/mock/projects.js → examples/basic-spa/mock/projects.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
module.exports = [ | ||
export default [ | ||
{ | ||
id: 1, | ||
name: 'facebook/react', | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
declare module '*.module.scss' { | ||
const classes: { [key: string]: string }; | ||
export default classes; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# @builder/babel-preset-ice |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
{ | ||
"name": "@builder/babel-preset-ice", | ||
"version": "1.0.0", | ||
"description": "Basic babel preset", | ||
"main": "lib/index.js", | ||
"types": "types/index.d.ts", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
"keywords": [ | ||
"plugin", | ||
"babel" | ||
], | ||
"author": "", | ||
"license": "MIT", | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"dependencies": { | ||
"@babel/plugin-proposal-class-properties": "^7.1.0", | ||
"@babel/plugin-proposal-decorators": "^7.1.2", | ||
"@babel/plugin-proposal-do-expressions": "^7.0.0", | ||
"@babel/plugin-proposal-export-default-from": "^7.0.0", | ||
"@babel/plugin-proposal-export-namespace-from": "^7.0.0", | ||
"@babel/plugin-proposal-function-bind": "^7.0.0", | ||
"@babel/plugin-proposal-function-sent": "^7.1.0", | ||
"@babel/plugin-proposal-json-strings": "^7.0.0", | ||
"@babel/plugin-proposal-logical-assignment-operators": "^7.0.0", | ||
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.0.0", | ||
"@babel/plugin-proposal-numeric-separator": "^7.0.0", | ||
"@babel/plugin-proposal-optional-chaining": "^7.0.0", | ||
"@babel/plugin-proposal-pipeline-operator": "^7.0.0", | ||
"@babel/plugin-proposal-throw-expressions": "^7.0.0", | ||
"@babel/plugin-syntax-dynamic-import": "^7.0.0", | ||
"@babel/plugin-syntax-import-meta": "^7.0.0", | ||
"@babel/plugin-transform-runtime": "^7.1.0", | ||
"@babel/preset-env": "^7.4.0", | ||
"@babel/preset-react": "^7.0.0", | ||
"@babel/preset-typescript": "^7.3.3" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
interface IOpts { | ||
typescript?: boolean; | ||
env?: object; | ||
react?: boolean; | ||
} | ||
/** | ||
* babel config | ||
*/ | ||
function resolvePlugin(plugins) { | ||
return plugins.filter(Boolean).map((plugin) => { | ||
if (Array.isArray(plugin)) { | ||
const [pluginName, ...args] = plugin; | ||
return [require.resolve(pluginName), ...args]; | ||
} | ||
return require.resolve(plugin); | ||
}); | ||
} | ||
|
||
export default (opts: IOpts = {}) => { | ||
const plugins = [ | ||
// Stage 0 | ||
'@babel/plugin-proposal-function-bind', | ||
// Stage 1 | ||
'@babel/plugin-proposal-export-default-from', | ||
'@babel/plugin-proposal-logical-assignment-operators', | ||
['@babel/plugin-proposal-optional-chaining', { loose: false }], | ||
['@babel/plugin-proposal-pipeline-operator', { proposal: 'minimal' }], | ||
['@babel/plugin-proposal-nullish-coalescing-operator', { loose: false }], | ||
'@babel/plugin-proposal-do-expressions', | ||
// Stage 2 | ||
['@babel/plugin-proposal-decorators', { legacy: true }], | ||
'@babel/plugin-proposal-function-sent', | ||
'@babel/plugin-proposal-export-namespace-from', | ||
'@babel/plugin-proposal-numeric-separator', | ||
'@babel/plugin-proposal-throw-expressions', | ||
// Stage 3 | ||
'@babel/plugin-syntax-dynamic-import', | ||
'@babel/plugin-syntax-import-meta', | ||
['@babel/plugin-proposal-class-properties', { loose: true }], | ||
'@babel/plugin-proposal-json-strings', | ||
]; | ||
|
||
return { | ||
presets: resolvePlugin([ | ||
opts.env && [ | ||
'@babel/preset-env', opts.env, | ||
], | ||
opts.typescript && '@babel/preset-typescript', | ||
opts.react && '@babel/preset-react', | ||
]), | ||
plugins: resolvePlugin(plugins), | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"extends": "../../tsconfig.settings.json", | ||
"compilerOptions": { | ||
"baseUrl": "./", | ||
"rootDir": "src", | ||
"outDir": "lib" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "@builder/app-helpers", | ||
"version": "2.0.3", | ||
"version": "2.1.0", | ||
"description": "build helpers for app framework", | ||
"author": "[email protected]", | ||
"homepage": "", | ||
|
@@ -20,7 +20,9 @@ | |
"test": "echo \"Error: run tests from root\" && exit 1" | ||
}, | ||
"dependencies": { | ||
"@babel/parser": "^7.12.11", | ||
"@babel/traverse": "^7.12.12", | ||
"fs-extra": "^8.1.0", | ||
"lodash": "^4.17.20" | ||
} | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
packages/build-app-helpers/src/checkExportDefaultDeclarationExists.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import * as fse from 'fs-extra'; | ||
import { parse } from '@babel/parser'; | ||
import traverse from '@babel/traverse'; | ||
|
||
function checkExportDefaultDeclarationExists(sourcePath: string) { | ||
if (!fse.existsSync(sourcePath)) { | ||
const ext = ['.ts', '.js', '.tsx', '.jsx'].find((extension) => fse.existsSync(`${sourcePath}${extension}`)); | ||
if (!ext) { | ||
return; | ||
} | ||
sourcePath = `${sourcePath}${ext}`; | ||
} | ||
const code = fse.readFileSync(sourcePath, 'utf-8'); | ||
const ast = parseCode(code); | ||
|
||
let exportDefaultDeclarationExists = false; | ||
traverse(ast, { | ||
ExportDefaultDeclaration() { | ||
exportDefaultDeclarationExists = true; | ||
}, | ||
}); | ||
|
||
return exportDefaultDeclarationExists; | ||
} | ||
|
||
function parseCode(code) { | ||
return parse(code, { | ||
sourceType: 'module', | ||
plugins: ['jsx', 'typescript', 'decorators-legacy', 'dynamicImport', 'classProperties'], | ||
}); | ||
} | ||
|
||
export default checkExportDefaultDeclarationExists; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "@builder/mpa-config", | ||
"version": "2.0.1", | ||
"version": "3.0.0", | ||
"description": "enable mpa project for framework", | ||
"author": "[email protected]", | ||
"homepage": "", | ||
|
@@ -20,8 +20,8 @@ | |
"test": "echo \"Error: run tests from root\" && exit 1" | ||
}, | ||
"dependencies": { | ||
"@builder/app-helpers": "^2.0.0", | ||
"fs-extra": "^8.1.0", | ||
"loader-utils": "^2.0.0", | ||
"@builder/app-helpers": "^2.0.0" | ||
"loader-utils": "^2.0.0" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.