Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

grunt: skip babel transpile for core-js #1466

Merged
merged 3 commits into from Sep 28, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
87 changes: 61 additions & 26 deletions gruntfile.js
Expand Up @@ -6,6 +6,7 @@ module.exports = function(grunt) {
grunt.loadNpmTasks('grunt-terser');
grunt.loadNpmTasks('grunt-contrib-jasmine');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-exorcise');

grunt.initConfig({
babel: {
Expand All @@ -22,57 +23,91 @@ module.exports = function(grunt) {
},
],
},
bundle: {
files: [
{
cwd: './build',
expand: true,
src: ['exceljs.bare.js', 'exceljs.js'],
dest: './dist/',
},
],
},
},
browserify: {
bare: {
src: ['./build/lib/exceljs.bare.js'],
dest: './build/exceljs.bare.js',
options: {
browserifyOptions: {
standalone: 'ExcelJS',
},
options: {
transform: [
['babelify', {
// enable babel transpile for node_modules
global: true,
presets: ['@babel/preset-env'],
// core-js should not be transpiled
// See https://github.com/zloirock/core-js/issues/514
ignore: [/node_modules[\\/]core-js/],
}],
],
browserifyOptions: {
// enable source map for browserify
debug: true,
standalone: 'ExcelJS',
},
},
bare: {
// keep the original source for source maps
src: ['./lib/exceljs.bare.js'],
dest: './dist/exceljs.bare.js',
},
bundle: {
src: ['./build/lib/exceljs.browser.js'],
dest: './build/exceljs.js',
options: {
browserifyOptions: {
standalone: 'ExcelJS',
},
},
// keep the original source for source maps
src: ['./lib/exceljs.browser.js'],
dest: './dist/exceljs.js',
},
spec: {
options: {
transform: null,
browserifyOptions: null,
},
src: ['./build/spec/browser/exceljs.spec.js'],
dest: './build/web/exceljs.spec.js',
},
},

terser: {
options: {
sourceMap: true,
output: {
preamble: '/*! ExcelJS <%= grunt.template.today("dd-mm-yyyy") %> */\n',
ascii_only: true,
},
},
dist: {
options: {
// Keep the original source maps from browserify
// See also https://www.npmjs.com/package/terser#source-map-options
sourceMap: {
content: 'inline',
url: 'exceljs.min.js.map',
},
},
files: {
'./dist/exceljs.min.js': ['./dist/exceljs.js'],
},
},
bare: {
options: {
// Keep the original source maps from browserify
// See also https://www.npmjs.com/package/terser#source-map-options
sourceMap: {
content: 'inline',
url: 'exceljs.bare.min.js.map',
},
},
files: {
'./dist/exceljs.bare.min.js': ['./dist/exceljs.bare.js'],
},
},
},

// Move source maps to a separate file
exorcise: {
bundle: {
options: {},
files: {
'./dist/exceljs.js.map': ['./dist/exceljs.js'],
'./dist/exceljs.bare.js.map': ['./dist/exceljs.bare.js'],
},
},
},

copy: {
dist: {
files: [
Expand All @@ -93,6 +128,6 @@ module.exports = function(grunt) {
},
});

grunt.registerTask('build', ['babel:dist', 'browserify', 'babel:bundle', 'terser', 'copy']);
grunt.registerTask('build', ['babel:dist', 'browserify', 'terser', 'exorcise', 'copy']);
grunt.registerTask('ug', ['terser']);
};
15 changes: 15 additions & 0 deletions lib/exceljs.browser.js
Expand Up @@ -2,8 +2,23 @@
require('core-js/modules/es.promise');
require('core-js/modules/es.object.assign');
require('core-js/modules/es.object.keys');
require('core-js/modules/es.object.values');
require('core-js/modules/es.symbol');
require('core-js/modules/es.symbol.async-iterator');
// required by core-js/modules/es.promise Promise.all
require('core-js/modules/es.array.iterator');
// required by node_modules/saxes/saxes.js SaxesParser.captureTo
require('core-js/modules/es.array.includes');
// required by lib/doc/workbook.js Workbook.model
require('core-js/modules/es.array.find-index');
// required by lib/doc/workbook.js Workbook.addWorksheet and Workbook.getWorksheet
require('core-js/modules/es.array.find');
// required by node_modules/saxes/saxes.js SaxesParser.getCode10
require('core-js/modules/es.string.from-code-point');
// required by lib/xlsx/xform/sheet/data-validations-xform.js DataValidationsXform.parseClose
require('core-js/modules/es.string.includes');
// required by lib/utils/utils.js utils.validInt and lib/csv/csv.js CSV.read
require('core-js/modules/es.number.is-nan');
require('regenerator-runtime/runtime');

const ExcelJS = {
Expand Down
1 change: 1 addition & 0 deletions package.json
Expand Up @@ -134,6 +134,7 @@
"grunt-contrib-copy": "^1.0.0",
"grunt-contrib-jasmine": "^2.1.0",
"grunt-contrib-watch": "^1.1.0",
"grunt-exorcise": "^2.1.1",
"grunt-terser": "^1.0.0",
"husky": "^4.2.5",
"lint-staged": "^10.2.13",
Expand Down