Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
87 changes: 61 additions & 26 deletions gruntfile.js
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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