Skip to content

Ensure all node_modules are compatible with IE11 #1193

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

Merged
merged 2 commits into from
Apr 7, 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 20 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -197,11 +197,29 @@ require('core-js/modules/es.object.assign');
require('core-js/modules/es.object.keys');
require('regenerator-runtime/runtime');

// ...

const ExcelJS = require('exceljs/dist/es5');
```

For IE 11, you'll also need a polyfill to support unicode regex patterns. For example,

```js
const rewritePattern = require('regexpu-core');
const {generateRegexpuOptions} = require('@babel/helper-create-regexp-features-plugin/lib/util');

const {RegExp} = global;
try {
new RegExp('a', 'u');
} catch (err) {
global.RegExp = function(pattern, flags) {
if (flags && flags.includes('u')) {
return new RegExp(rewritePattern(pattern, flags, generateRegexpuOptions({flags, pattern})));
}
return new RegExp(pattern, flags);
};
global.RegExp.prototype = RegExp;
}
```

## Browserify

ExcelJS publishes two browserified bundles inside the dist/ folder:
Expand Down
9 changes: 0 additions & 9 deletions _patch-fast-csv.js

This file was deleted.

17 changes: 14 additions & 3 deletions gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,21 @@ 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: './dist/exceljs.bare.js',
dest: './build/exceljs.bare.js',
options: {
browserifyOptions: {
standalone: 'ExcelJS',
Expand All @@ -34,7 +44,7 @@ module.exports = function(grunt) {
},
bundle: {
src: ['./build/lib/exceljs.browser.js'],
dest: './dist/exceljs.js',
dest: './build/exceljs.js',
options: {
browserifyOptions: {
standalone: 'ExcelJS',
Expand All @@ -48,6 +58,7 @@ module.exports = function(grunt) {
},
terser: {
options: {
sourceMap: true,
output: {
preamble: '/*! ExcelJS <%= grunt.template.today("dd-mm-yyyy") %> */\n',
},
Expand Down Expand Up @@ -94,6 +105,6 @@ module.exports = function(grunt) {
},
});

grunt.registerTask('build', ['babel', 'browserify', 'terser', 'copy']);
grunt.registerTask('build', ['babel:dist', 'browserify', 'babel:bundle', 'terser', 'copy']);
grunt.registerTask('ug', ['terser']);
};
17 changes: 17 additions & 0 deletions lib/exceljs.browser.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,26 @@
/* eslint-disable import/no-extraneous-dependencies,node/no-unpublished-require */
require('core-js/modules/es.promise');
require('core-js/modules/es.string.includes');
require('core-js/modules/es.object.assign');
require('core-js/modules/es.object.keys');
require('regenerator-runtime/runtime');

const rewritePattern = require('regexpu-core');
const {generateRegexpuOptions} = require('@babel/helper-create-regexp-features-plugin/lib/util');

const {RegExp} = global;
try {
RegExp('a', 'u');
} catch (err) {
global.RegExp = function(pattern, flags) {
if (flags && flags.includes('u')) {
return new RegExp(rewritePattern(pattern, flags, generateRegexpuOptions({flags, pattern})));
}
return new RegExp(pattern, flags);
};
global.RegExp.prototype = RegExp;
}

const ExcelJS = {
Workbook: require('./doc/workbook'),
};
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,9 @@
"lint:fix": "prettier-eslint --write $(pwd)'/**/*.js'",
"lint:staged": "lint-staged",
"clean": "rm -rf build/ && rm -rf dist",
"patch:fast-csv": "node _patch-fast-csv.js",
"benchmark": "node --expose-gc benchmark",
"benchmark:debug": "node --expose-gc --inspect-brk --trace-deopt benchmark",
"build": "npm run patch:fast-csv && grunt build",
"build": "grunt build",
"preversion": "npm run clean && npm run build && npm run test:all && npm run test:dist",
"postversion": "git push --no-verify && git push --tags --no-verify"
},
Expand Down Expand Up @@ -106,6 +105,7 @@
"devDependencies": {
"@babel/cli": "^7.6.4",
"@babel/core": "^7.9.0",
"@babel/helper-create-regexp-features-plugin": "^7.8.8",
"@babel/preset-env": "^7.9.0",
"@types/chai": "^4.2.11",
"@types/mocha": "^5.2.7",
Expand Down Expand Up @@ -139,6 +139,7 @@
"prettier-eslint": "^9.0.0",
"prettier-eslint-cli": "^5.0.0",
"regenerator-runtime": "^0.13.5",
"regexpu-core": "^4.7.0",
"semver": "^5.6.0",
"ts-node": "^8.8.1",
"typescript": "^3.8.3"
Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy