Skip to content

Commit a853c54

Browse files
committed
Adding rollup es5 step
1 parent 63dc5c2 commit a853c54

File tree

3 files changed

+28
-5
lines changed

3 files changed

+28
-5
lines changed

packages/webchannel-wrapper/gulpfile.js

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ const sourcemaps = require('gulp-sourcemaps');
2424
const { resolve } = require('path');
2525
const commonjs = require('rollup-plugin-commonjs');
2626
const rollupSourcemaps = require('rollup-plugin-sourcemaps');
27+
const { terser } = require('rollup-plugin-terser');
28+
const typescriptPlugin = require('rollup-plugin-typescript2');
29+
const typescript = require('typescript');
2730

2831
// The optimization level for the JS compiler.
2932
// Valid levels: WHITESPACE_ONLY, SIMPLE_OPTIMIZATIONS, ADVANCED_OPTIMIZATIONS.
@@ -95,7 +98,16 @@ function createRollupTask(inputPath, outputExtension) {
9598
return async function rollupBuild() {
9699
const inputOptions = {
97100
input: inputPath,
98-
plugins: [rollupSourcemaps(), commonjs()]
101+
plugins: [
102+
rollupSourcemaps(),
103+
commonjs(),
104+
typescriptPlugin({
105+
typescript,
106+
compilerOptions: { allowJs: true, include: [inputPath], target: "ES5" },
107+
input: inputPath
108+
}),
109+
terser()
110+
]
99111
};
100112

101113
const outputOptions = {
@@ -126,7 +138,7 @@ gulp.task('cjs', cjsBuild);
126138
// 2) Use rollup to convert result to ESM format.
127139
const intermediateEsmFile = 'temp/esm.js';
128140
const intermediateEsmPath = resolve(__dirname, 'dist/', intermediateEsmFile);
129-
const esmBuild = createBuildTask(intermediateEsmFile, '', '');
141+
const esmBuild = createBuildTask(intermediateEsmFile, '', '', 'ECMASCRIPT_2017');
130142
const rollupTask = createRollupTask(intermediateEsmPath, 'esm');
131143
gulp.task('esm', gulp.series(esmBuild, rollupTask));
132144

packages/webchannel-wrapper/package.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,15 @@
1616
},
1717
"license": "Apache-2.0",
1818
"devDependencies": {
19-
"google-closure-compiler": "20200112.0.0",
20-
"google-closure-library": "20200112.0.0",
19+
"google-closure-compiler": "20200204.0.0",
20+
"google-closure-library": "20200204.0.0",
2121
"gulp": "4.0.2",
2222
"gulp-sourcemaps": "2.6.5",
2323
"rollup": "2.6.1",
2424
"rollup-plugin-commonjs": "10.1.0",
25-
"rollup-plugin-sourcemaps": "0.5.0"
25+
"rollup-plugin-sourcemaps": "0.5.0",
26+
"rollup-plugin-terser": "5.3.0",
27+
"rollup-plugin-typescript2": "0.27.0"
2628
},
2729
"repository": {
2830
"directory": "packages/webchannel-wrapper",
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"extends": "../../config/tsconfig.base.json",
3+
"compilerOptions": {
4+
"outDir": "dist"
5+
},
6+
"exclude": [
7+
"dist/**/*"
8+
]
9+
}

0 commit comments

Comments
 (0)