Skip to content

Commit

Permalink
Compile TS to ES2020 (except for standalone lib)
Browse files Browse the repository at this point in the history
  • Loading branch information
yo35 committed Jan 20, 2024
1 parent fd77dbe commit dc98efe
Show file tree
Hide file tree
Showing 4 changed files with 112 additions and 5 deletions.
103 changes: 103 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
"nyc": "^15.1.0",
"rimraf": "^5.0.5",
"ssh2-sftp-client": "^10.0.0",
"tsify": "^5.0.4",
"typedoc": "0.23.28",
"typedoc-plugin-extras": "2.3.2",
"typescript": "5.0.4",
Expand Down
10 changes: 7 additions & 3 deletions scripts/build-archive.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,11 @@ const fs = require('fs');
const path = require('path');
const process = require('process');
const { author, license, version } = require('../package.json');
const { compilerOptions } = require('../tsconfig.json');

const output = path.resolve(__dirname, `../dist/kokopu-${version}.zip`);
const infoFiles = [ 'README.md', 'CHANGELOG.md', 'LICENSE' ].map(file => path.resolve(__dirname, '../' + file));
const inputLibFile = path.resolve(__dirname, '../dist/lib/index.js');
const inputFile = path.resolve(__dirname, '../src/index.ts');
const browserifiedLibFile = path.resolve(__dirname, '../build/kokopu.js');
const minifiedLibFile = path.resolve(__dirname, '../build/kokopu.min.js');

Expand All @@ -41,14 +42,17 @@ async function buildBrowserifiedLib() {
fs.mkdirSync(path.dirname(browserifiedLibFile), { recursive: true });
const browserifiedLibStream = fs.createWriteStream(browserifiedLibFile, { encoding: 'utf8' });
browserifiedLibStream.write(
`/**
`/*!
* kokopu (https://www.npmjs.com/package/kokopu)
* @version ${version}
* @author ${author}
* @license ${license}
*/
`);
browserify(inputLibFile, { standalone: 'kokopu' }).bundle().pipe(browserifiedLibStream);
browserify(inputFile, { standalone: 'kokopu' })
.plugin('tsify', { target: 'es6', lib: [ compilerOptions.target ] })
.bundle()
.pipe(browserifiedLibStream);
return new Promise(resolve => browserifiedLibStream.on('finish', resolve));
}

Expand Down
3 changes: 1 addition & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
"sourceMap": true,
"declaration": true,
"module": "CommonJS",
"target": "es2015",
"lib": [ "es2020" ],
"target": "es2020",
"types": [],
"allowJs": false,
"strict": true,
Expand Down

0 comments on commit dc98efe

Please sign in to comment.