-
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.
* feat: support swc * feat: support swc * chore: add default value * chore: add context for modularImportRuntime * chore: resolve conflict * refactor: rework swc * feat: swc plugin * chore: rename example name * chore: optimize code * chore: update lock file * chore: update version * chore: optimize code * chore: optimize code * chore: optimize code * chore: ci * chore: optimize code * chore: remove useless code
- Loading branch information
Showing
105 changed files
with
5,705 additions
and
3,501 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
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,17 @@ | ||
{ | ||
"router": false, | ||
"mpa": { | ||
"openPage": "Dashboard", | ||
"template": { | ||
"web.html": ["Dashboard", "Home"] | ||
}, | ||
"rewrites": { | ||
"dashboard": "site/dashboard" | ||
} | ||
}, | ||
"swc": true, | ||
"plugins": [], | ||
"devServer": { | ||
"writeToDisk": true | ||
} | ||
} |
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,19 @@ | ||
{ | ||
"name": "exmaple-basic-mpa", | ||
"description": "", | ||
"dependencies": { | ||
"react": "^16.4.1", | ||
"react-dom": "^16.4.1" | ||
}, | ||
"devDependencies": { | ||
"@types/react": "^16.9.13", | ||
"@types/react-dom": "^16.9.4" | ||
}, | ||
"scripts": { | ||
"start": "icejs start", | ||
"build": "icejs build" | ||
}, | ||
"engines": { | ||
"node": ">=8.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<meta http-equiv="x-ua-compatible" content="ie=edge,chrome=1" /> | ||
<meta name="viewport" content="width=device-width" /> | ||
<title>icejs · mpa example</title> | ||
</head> | ||
<body> | ||
<div>current page: <%= pageName %></div> | ||
<div id="ice-container"></div> | ||
</body> | ||
</html> |
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,14 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<meta http-equiv="x-ua-compatible" content="ie=edge,chrome=1" /> | ||
<meta name="viewport" content="width=device-width" /> | ||
<title>icejs · mpa example</title> | ||
</head> | ||
|
||
<body> | ||
<div>using web.html template</div> | ||
<div id="ice-container"></div> | ||
</body> | ||
</html> |
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,6 @@ | ||
{ | ||
"template": "node", | ||
"container": { | ||
"port": 3333 | ||
} | ||
} |
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,19 @@ | ||
import { runApp, IAppConfig } from 'ice'; | ||
import React from 'react'; | ||
import routes from './routes'; | ||
import store from './store'; | ||
|
||
const Provider = store.Provider; | ||
|
||
const appConfig: IAppConfig = { | ||
router: { | ||
routes | ||
}, | ||
app: { | ||
addProvider({ children }) { | ||
return <Provider>{children}</Provider>; | ||
} | ||
} | ||
}; | ||
|
||
runApp(appConfig); |
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,18 @@ | ||
import React from 'react'; | ||
import store from './store'; | ||
|
||
const Dashboard = () => { | ||
const [pageState, pageActions] = store.useModel('counter'); | ||
return ( | ||
<> | ||
<h2>Dashboard Page...</h2> | ||
<div> | ||
<button type="button" onClick={pageActions.increment}>+</button> | ||
<span>{pageState.count}</span> | ||
<button type="button" onClick={pageActions.decrement}>-</button> | ||
</div> | ||
</> | ||
); | ||
}; | ||
|
||
export default Dashboard; |
23 changes: 23 additions & 0 deletions
23
examples/basic-mpa-with-swc/src/pages/Dashboard/models/counter.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,23 @@ | ||
export const delay = (time) => new Promise((resolve) => setTimeout(() => resolve(), time)); | ||
|
||
export default { | ||
state: { | ||
count: 0 | ||
}, | ||
|
||
reducers: { | ||
increment (prevState) { | ||
return { count: prevState.count + 1 }; | ||
}, | ||
decrement (prevState) { | ||
return { count: prevState.count - 1 }; | ||
} | ||
}, | ||
|
||
effects: (dispatch) => ({ | ||
async decrementAsync () { | ||
await delay(10); | ||
dispatch.counter.decrement(); | ||
}, | ||
}), | ||
}; |
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,3 @@ | ||
import Index from './index'; | ||
|
||
export default [{ path: '/', component: Index }]; |
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,7 @@ | ||
import { createStore } from 'ice'; | ||
import counter from './models/counter'; | ||
|
||
const models = { counter }; | ||
const store = createStore(models); | ||
|
||
export default store; |
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); |
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,15 @@ | ||
import React from 'react'; | ||
|
||
const Home = () => { | ||
return ( | ||
<> | ||
<h2>Home Page</h2> | ||
</> | ||
); | ||
}; | ||
|
||
Home.pageConfig = { | ||
title: 'Home Page', | ||
}; | ||
|
||
export default Home; |
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,42 @@ | ||
{ | ||
"compileOnSave": false, | ||
"buildOnSave": false, | ||
"compilerOptions": { | ||
"baseUrl": ".", | ||
"outDir": "build", | ||
"module": "esnext", | ||
"target": "es6", | ||
"jsx": "react", | ||
"moduleResolution": "node", | ||
"allowSyntheticDefaultImports": true, | ||
"esModuleInterop": true, | ||
"lib": [ | ||
"es6", | ||
"dom" | ||
], | ||
"sourceMap": true, | ||
"allowJs": true, | ||
"rootDir": "./", | ||
"forceConsistentCasingInFileNames": true, | ||
"noImplicitReturns": true, | ||
"noImplicitThis": true, | ||
"noImplicitAny": false, | ||
"importHelpers": true, | ||
"strictNullChecks": true, | ||
"suppressImplicitAnyIndexErrors": true, | ||
"noUnusedLocals": true, | ||
"skipLibCheck": true, | ||
"types": ["node"], | ||
"paths": { | ||
"@/*": [ | ||
"./src/*" | ||
], | ||
"ice": [ | ||
".ice/index.ts" | ||
], | ||
"ice/*": [ | ||
".ice/pages/*" | ||
] | ||
} | ||
} | ||
} |
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 |
---|---|---|
|
@@ -9,5 +9,8 @@ | |
"dashboard": "site/dashboard" | ||
} | ||
}, | ||
"plugins": [] | ||
"plugins": [], | ||
"devServer": { | ||
"writeToDisk": true | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
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,19 @@ | ||
import { runApp, IAppConfig } from 'ice'; | ||
import React from 'react'; | ||
import routes from './routes'; | ||
import store from './store'; | ||
|
||
const Provider = store.Provider; | ||
|
||
const appConfig: IAppConfig = { | ||
router: { | ||
routes | ||
}, | ||
app: { | ||
addProvider({ children }) { | ||
return <Provider>{children}</Provider>; | ||
} | ||
} | ||
}; | ||
|
||
runApp(appConfig); |
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,7 @@ | ||
import { createStore } from 'ice'; | ||
import counter from './models/counter'; | ||
|
||
const models = { counter }; | ||
const store = createStore(models); | ||
|
||
export default store; |
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 |
---|---|---|
|
@@ -9,7 +9,7 @@ | |
}, | ||
"modeConfig": { | ||
"prod": { | ||
"ignoreHtmlTemplate": true | ||
"ignoreHtmlTemplate": false | ||
} | ||
}, | ||
"esbuild": { | ||
|
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,10 @@ | ||
const { merge } = require('lodash'); | ||
|
||
export default function(config, swcOptions) { | ||
config.module | ||
.rule('jsx') | ||
.use('swc-loader') | ||
.tap((options) => { | ||
return merge(options, swcOptions); | ||
}); | ||
} |
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-config |
Oops, something went wrong.