Skip to content

Commit

Permalink
build: Make ES3 only in prod env
Browse files Browse the repository at this point in the history
  • Loading branch information
AnnAngela committed Apr 26, 2023
1 parent 162ec89 commit 9c426d6
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 16 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@

机器人通过以下流程编译代码,然后提交到萌百:

- 执行 `tsc --build --verbose` 以编译 `*.js` 代码;
- 执行 `tsc --project tsconfig.production.json` 以编译 `*.js` 代码;
- 执行 `npx postcss src/**/*.css --base src/ -d dist/ --verbose` 以编译 `*.css` 代码;
- 根据模板生成 `MediaWiki:Gadgets-definition` 页面。

Expand Down
2 changes: 1 addition & 1 deletion scripts/generatePolyfill/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ for (const file of await findPolyfillFiles()) {
console.info("Start to compile src/ to temporary bundle file...");
const bundlePath = path.join(tempPath, "bundle.js");
console.log("bundlePath:", bundlePath);
await exec(`npx tsc --project tsconfig.json --outFile ${bundlePath}`);
await exec(`npx tsc --project tsconfig.production.json --outFile ${bundlePath}`);
console.info("\tDone.");
console.info("Start to analyse the temporary bundle file...");
const analysisReport = [...new Set(JSON.parse(await exec(`npx @financial-times/js-features-analyser analyse --file ${path.relative(".", bundlePath)}`)))].sort();
Expand Down
2 changes: 1 addition & 1 deletion scripts/generateUnrecognizableFeatures/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const tempPath = await mkdtmp();
console.info("Start to compile src/ to temporary bundle file...");
const bundlePath = path.join(tempPath, "bundle.js");
console.log("bundlePath:", bundlePath);
await exec(`npx tsc --project tsconfig.json --outFile ${bundlePath}`);
await exec(`npx tsc --project tsconfig.production.json --outFile ${bundlePath}`);
console.info("\tDone.");
console.info("Start to analyse the temporary bundle file...");
const analysisReport = [...new Set(JSON.parse(await exec(`npx @financial-times/js-features-analyser analyse --file ${path.relative(".", bundlePath)}`)))].sort();
Expand Down
15 changes: 2 additions & 13 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,15 @@
"compilerOptions": {
"allowJs": true,
"removeComments": true,
"target": "ES3",
"target": "ESNext",
"outDir": "dist/",
"alwaysStrict": true,
"strict": true,
"downlevelIteration": true,
"incremental": true,
"lib": [
"ES5",
"ES2015",
"ES2016",
"ES2017",
"ES2018",
"ES2019",
"ES2020",
"ES2021",
"ES2022",
"ESNext",
"DOM"
],
"ignoreDeprecations": "5.0"
]
},
"include": [
"src",
Expand Down
22 changes: 22 additions & 0 deletions tsconfig.production.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"compilerOptions": {
"allowJs": true,
"removeComments": true,
"target": "ES3",
"outDir": "dist/",
"alwaysStrict": true,
"strict": true,
"downlevelIteration": true,
"lib": [
"ESNext",
"DOM"
],
"ignoreDeprecations": "5.0"
},
"include": [
"src",
],
"exclude": [
"dist",
],
}

0 comments on commit 9c426d6

Please sign in to comment.