-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(build): add es2015 build target support (#3202)
* feat(build): add es2015 support * refactor(build): use await instead of promises * feat(build): clear tmp folder, fix es2015 field in package.json
- Loading branch information
1 parent
4131489
commit 735101c
Showing
5 changed files
with
470 additions
and
1 deletion.
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,30 @@ | ||
'use strict'; | ||
const path = require('path'); | ||
const execa = require('execa'); | ||
const fs = require('fs-extra'); | ||
const del = require('del'); | ||
const inlineResources = require('ngm-cli/helpers/inline-resources'); | ||
const src = 'src'; | ||
const tmp = '.tmp'; | ||
const dist = 'dist-es2015'; | ||
const tsconfigPath = '.tmp/tsconfig.json'; | ||
|
||
async function createEs2015Bundle() { | ||
await del(tmp); | ||
console.log('Copying src to temp folder'); | ||
await fs.copy(src, tmp); | ||
const tsconfig = require(path.resolve(tsconfigPath)); | ||
tsconfig.compilerOptions.target = 'es2015'; | ||
tsconfig.compilerOptions.outDir = '../' + dist; | ||
await fs.writeFile(tsconfigPath, JSON.stringify(tsconfig), 'utf8'); | ||
console.log('Inlining templates and styles'); | ||
await inlineResources.inlineResources(tmp); | ||
console.log('Compiling library from temp folder'); | ||
await execa('ngc', ['-p', tmp], { preferLocal: true }); | ||
console.log('Bundling es2015 bundle'); | ||
await execa('rollup --config ./scripts/es2015/es2015.config.js', { shell: true }); | ||
console.log('Removing temp folders'); | ||
await del([tmp, dist]); | ||
} | ||
createEs2015Bundle(); | ||
|
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,37 @@ | ||
'use strict'; | ||
const fs = require('fs-extra'); | ||
const rollup = require('rollup'); | ||
const resolve = require('rollup-plugin-node-resolve'); | ||
const commonjs = require('rollup-plugin-commonjs'); | ||
const ROLLUP_GLOBALS = require('./rollup.globals'); | ||
const libName = 'ngx-bootstrap'; | ||
const PATH_SRC = 'dist-es2015/'; | ||
const PATH_DIST = 'dist/bundles/'; | ||
|
||
export default { | ||
input: PATH_SRC + 'index.js', | ||
output: { | ||
format: 'es', | ||
file: PATH_DIST + libName + '.es2015.js', | ||
sourcemap: true, | ||
name: libName | ||
}, | ||
external: Object.keys(ROLLUP_GLOBALS), | ||
plugins: [ | ||
resolve({ | ||
module: true, | ||
main: true | ||
}), | ||
commonjs({ | ||
include: 'node_modules/**', | ||
}) | ||
], | ||
onwarn: warning => { | ||
const skip_codes = [ | ||
'THIS_IS_UNDEFINED', | ||
'MISSING_GLOBAL_NAME' | ||
]; | ||
if (skip_codes.indexOf(warning.code) != -1) return; | ||
console.error(warning); | ||
} | ||
}; |
Oops, something went wrong.
735101c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good job, thanks a lot! waiting for the release to test it!