diff --git a/demo/17-milestone-with-framework/config/webpack/configs/watch.ts b/demo/17-milestone-with-framework/config/webpack/configs/watch.ts new file mode 100644 index 0000000..235f683 --- /dev/null +++ b/demo/17-milestone-with-framework/config/webpack/configs/watch.ts @@ -0,0 +1,6 @@ +import { isWatch } from './../utils/env'; +import { ConfigTweaker } from '../utils/types'; + +export const loadScript: ConfigTweaker = (config, resolver) => { + config.watch(isWatch); +}; diff --git a/demo/17-milestone-with-framework/config/webpack/utils/env.ts b/demo/17-milestone-with-framework/config/webpack/utils/env.ts index a7a1e5e..14f8b45 100644 --- a/demo/17-milestone-with-framework/config/webpack/utils/env.ts +++ b/demo/17-milestone-with-framework/config/webpack/utils/env.ts @@ -12,3 +12,5 @@ export const isBuilding = dev || prod; export const shouldMinify = prod; export const sourcemap = argv.devtool !== undefined ? argv.devtool : isDevMode; + +export const isWatch = argv.watch !== undefined; diff --git a/demo/17-milestone-with-framework/package.json b/demo/17-milestone-with-framework/package.json index a16ce8f..8e71b5a 100644 --- a/demo/17-milestone-with-framework/package.json +++ b/demo/17-milestone-with-framework/package.json @@ -1,7 +1,7 @@ { "scripts": { "start": "cross-env TS_NODE_PROJECT=config/tsconfig-for-webpack-config.json webpack-dev-server --open --config=config/webpack/webpack.server.ts", - "build": "npm run build:prod", + "build": "npm run build:prod --", "build:dev": "cross-env TS_NODE_PROJECT=config/tsconfig-for-webpack-config.json webpack --config=config/webpack/webpack.dev.ts", "build:prod": "cross-env TS_NODE_PROJECT=config/tsconfig-for-webpack-config.json webpack --config=config/webpack/webpack.prod.ts", "test": "open dist/index.html" diff --git a/demo/17-milestone-with-framework/src/features/index.ts b/demo/17-milestone-with-framework/src/features/index.ts index 3ea58b1..2a45eea 100644 --- a/demo/17-milestone-with-framework/src/features/index.ts +++ b/demo/17-milestone-with-framework/src/features/index.ts @@ -1,3 +1,4 @@ import './load-async-dynamic'; import './load-esnext'; +import './load-es2020'; import './load-npm'; diff --git a/demo/17-milestone-with-framework/src/features/load-es2020.ts b/demo/17-milestone-with-framework/src/features/load-es2020.ts new file mode 100644 index 0000000..44884c0 --- /dev/null +++ b/demo/17-milestone-with-framework/src/features/load-es2020.ts @@ -0,0 +1,21 @@ +{ + const def = 42; + const data = null ?? def; + console.warn('nullish', data); +} + +{ + type Struct = { + arr?: number[]; + cb?: Function; + }; + + let inst: Struct = { + cb: () => 233, + }; + + const cbRes = inst.cb?.(); + const arrRes = inst.arr?.[0]; + + console.warn(cbRes, arrRes); +} diff --git a/readme.md b/readme.md index 51811b7..75b428d 100644 --- a/readme.md +++ b/readme.md @@ -26,6 +26,7 @@ _还没写文档的_ - [14-pack-image](demo/14-pack-image) - [15-react](demo/15-react) - [16-vue](demo/16-vue) +- [17-milestone-with-framework](demo/17-milestone-with-framework)