Skip to content

Commit

Permalink
Remove polyfills for not supported browsers (#1030)
Browse files Browse the repository at this point in the history
* Remove TerserPlugin configuration for GPU support (no longer needed)

* Change the supported browsers to 2 latest versions of the major browsers.

* Update changelog

* Fix tests

* Setup externals in webpack configuration

* Change babel configuration to polyfill only the UMD bundles

* Add all the dependencies to the UMD installation instructions for non-full version

* Add info about bessel and jStat being included in src/interpreter/plugin/3rdparty to the dependencies.md

Co-authored-by: Marcin Warpechowski <warpech@gmail.com>
  • Loading branch information
sequba and warpech committed Sep 6, 2022
1 parent 2805b59 commit c43a7fe
Show file tree
Hide file tree
Showing 10 changed files with 94 additions and 82 deletions.
18 changes: 12 additions & 6 deletions .config/webpack/development.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,24 @@ module.exports.create = function create() {
c.devtool = 'source-map';
// Exclude all external dependencies from 'base' bundle
c.externals = {
moment: {
root: 'moment',
commonjs2: 'moment',
commonjs: 'moment',
amd: 'moment',
},
chevrotain: {
root: 'chevrotain',
commonjs2: 'chevrotain',
commonjs: 'chevrotain',
amd: 'chevrotain',
},
'tiny-emitter': {
root: 'TinyEmitter',
commonjs2: 'tiny-emitter',
commonjs: 'tiny-emitter',
amd: 'tiny-emitter',
},
unorm: {
root: 'unorm',
commonjs2: 'unorm',
commonjs: 'unorm',
amd: 'unorm',
},
};
c.plugins.push(new WebpackBar({ name: ` ${PACKAGE_FILENAME}.js` }));
});
Expand Down
9 changes: 1 addition & 8 deletions .config/webpack/production.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,7 @@ module.exports.create = function create() {

c.optimization = {
minimize: true,
minimizer: [
new TerserPlugin({
terserOptions: {
mangle: false, // This option has to be disabled, otherwise GPU function doesn't work for min files.
compress: false, // This option has to be disabled, otherwise GPU function doesn't work for min files.
}
})
]
minimizer: [new TerserPlugin()]
};

c.plugins.forEach((plugin) => {
Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added
- Added MAXIFS and MINIFS functions. [#1049](https://github.com/handsontable/hyperformula/issues/1049)

### Changed
- Removed all polyfills from the CommonJS and ES Modules builds. Only keep the minimum required polyfills for the [supported browsers](https://hyperformula.handsontable.com/guide/supported-browsers.html) in the UMD build. [#1011](https://github.com/handsontable/hyperformula/issues/1011)

### Fixed
- Fixed TEXT function rounding issue that caused incorrect conversion of date and time values to strings. [#1043](https://github.com/handsontable/hyperformula/issues/1043)
- Fixed functions SUMIF, SUMIFS, AVERAGEIF, COUNTIF, COUNTIFS to handle complex numeric values correctly. [#951](https://github.com/handsontable/hyperformula/issues/951)
Expand Down
28 changes: 11 additions & 17 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -1,36 +1,30 @@
module.exports = {
presets: [
['@babel/preset-env', {
targets: {
chrome: '64',
firefox: '58',
ie: '11',
safari: '11'
},
modules: false,
debug: false,
useBuiltIns: 'usage',
corejs: 3,
}]
],
plugins: [
['transform-inline-environment-variables']
['transform-inline-environment-variables'],
],
env: {
// Environment for transpiling files to be compatible with UMD.
commonjs: {
dist: {
presets: [
['@babel/preset-env', {
modules: false,
useBuiltIns: 'usage',
corejs: '3.23',
}]
],
plugins: [
['@babel/plugin-transform-runtime', {
corejs: false,
helpers: false,
regenerator: false,
useESModules: false,
version: '^7.18.9',
}],
['@babel/plugin-transform-modules-commonjs', { loose: true }]
]
},
// Environment for transpiling files to be compatible with CommonJS.
commonjs_dist: {
commonjs: {
plugins: [
['@babel/plugin-transform-modules-commonjs', { loose: true }],
],
Expand Down
4 changes: 3 additions & 1 deletion docs/guide/client-side-installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ Full build will include all the required dependencies:
Or you may load just a minimal build and add the dependencies on your own:

```html
<script src="https://cdn.jsdelivr.net/npm/chevrotain@6/lib/chevrotain.js"></script>
<script src="https://cdn.jsdelivr.net/npm/chevrotain@6/lib/chevrotain.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/tiny-emitter@2/dist/tinyemitter.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/unorm@1/lib/unorm.js"></script>
<script src="https://cdn.jsdelivr.net/npm/hyperformula/dist/hyperformula.min.js"></script>
```

Expand Down
22 changes: 11 additions & 11 deletions docs/guide/dependencies.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@ HyperFormula depends on a few external libraries, as listed below.
These dependencies are used to support some of the library's core
features.

| Name | License | Author |
| :--- | :--- | :--- |
| [bessel](https://github.com/SheetJS/bessel) | Apache v2.0 | SheetJS |
| [Chevrotain](https://github.com/SAP/chevrotain) | Apache v2.0 | SAP SE or an SAP affiliate company |
| [core-js](https://github.com/zloirock/core-js) | The MIT License | Denis Pushkarev |
| [jStat](https://github.com/jstat/jstat) | The MIT License | jStat |
| [regenerator-runtime](https://github.com/facebook/regenerator/tree/master/packages/regenerator-runtime) | The MIT License | Facebook, Inc. |
| [tiny-emitter](https://github.com/scottcorgan/tiny-emitter) | The MIT License | Scott Corgan |
| [unorm](https://github.com/walling/unorm) | The MIT License | Matsuza, Bjarke Walling |
| Name | License | Author |
|:------------------------------------------------------------|:----------------|:-----------------------------------|
| [bessel](https://github.com/SheetJS/bessel) | Apache v2.0 | SheetJS |
| [Chevrotain](https://github.com/SAP/chevrotain) | Apache v2.0 | SAP SE or an SAP affiliate company |
| [core-js](https://github.com/zloirock/core-js) | The MIT License | Denis Pushkarev |
| [jStat](https://github.com/jstat/jstat) | The MIT License | jStat |
| [tiny-emitter](https://github.com/scottcorgan/tiny-emitter) | The MIT License | Scott Corgan |
| [unorm](https://github.com/walling/unorm) | The MIT License | Matsuza, Bjarke Walling |

<br>

We want to express gratitude and appreciation for all of the hard
The _bessel_ and _jStat_ projects are distributed with the code repository at the path `src/interpreter/plugin/3rdparty` and bundled with the code package.

We want to express gratitude and appreciation for all the hard
work put into these awesome libraries by their authors and maintainers.
37 changes: 20 additions & 17 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 20 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "hyperformula",
"description": "HyperFormula is a JavaScript engine for efficient processing of spreadsheet-like data and formulas",
"homepage": "https://handsontable.com/docs/hyperformula",
"homepage": "https://hyperformula.handsontable.com/",
"repository": {
"type": "git",
"url": "https://github.com/handsontable/hyperformula.git"
Expand Down Expand Up @@ -34,6 +34,18 @@
"open formula",
"openformula"
],
"browserslist": [
"last 2 chrome versions",
"last 2 and_chr versions",
"last 2 firefox versions",
"last 2 and_ff versions",
"last 2 safari versions",
"last 2 ios_saf versions",
"last 2 edge versions",
"last 2 and_uc versions",
"last 2 and_qq versions",
"last 2 op_mob versions"
],
"license": "GPL-3.0-only",
"module": "es/index.js",
"main": "commonjs/index.js",
Expand All @@ -47,9 +59,9 @@
"bundle-all": "cross-env HF_COMPILE=1 npm-run-all clean compile bundle:** verify-bundles",
"bundle:es": "(node script/if-ne-env.js HF_COMPILE=1 || npm run compile) && cross-env-shell BABEL_ENV=es env-cmd -f ht.config.js babel lib --out-dir es",
"bundle:cjs": "(node script/if-ne-env.js HF_COMPILE=1 || npm run compile) && cross-env-shell BABEL_ENV=commonjs env-cmd -f ht.config.js babel lib --out-dir commonjs",
"bundle:development": "(node script/if-ne-env.js HF_COMPILE=1 || npm run compile) && cross-env-shell BABEL_ENV=commonjs NODE_ENV=development env-cmd -f ht.config.js webpack ./lib/index.js",
"bundle:production": "(node script/if-ne-env.js HF_COMPILE=1 || npm run compile) && cross-env-shell BABEL_ENV=commonjs NODE_ENV=production env-cmd -f ht.config.js webpack ./lib/index.js",
"bundle:languages": "(node script/if-ne-env.js HF_COMPILE=1 || npm run compile) && cross-env-shell BABEL_ENV=commonjs NODE_ENV=languages env-cmd -f ht.config.js webpack",
"bundle:development": "(node script/if-ne-env.js HF_COMPILE=1 || npm run compile) && cross-env-shell BABEL_ENV=dist NODE_ENV=development env-cmd -f ht.config.js webpack ./lib/index.js",
"bundle:production": "(node script/if-ne-env.js HF_COMPILE=1 || npm run compile) && cross-env-shell BABEL_ENV=dist NODE_ENV=production env-cmd -f ht.config.js webpack ./lib/index.js",
"bundle:languages": "(node script/if-ne-env.js HF_COMPILE=1 || npm run compile) && cross-env-shell BABEL_ENV=dist NODE_ENV=languages env-cmd -f ht.config.js webpack",
"bundle:typings": "tsc --emitDeclarationOnly -d --outDir typings",
"verify-bundles": "run-p verify:**",
"verify:umd": "node script/check-file.js dist/hyperformula.js",
Expand All @@ -64,8 +76,8 @@
"test:coverage": "npm run test:unit -- --coverage",
"test:logMemory": "cross-env NODE_ICU_DATA=node_modules/full-icu jest --runInBand --logHeapUsage",
"test:unit.ci": "cross-env NODE_ICU_DATA=node_modules/full-icu node --expose-gc ./node_modules/jest/bin/jest --forceExit",
"test:browser": "cross-env-shell BABEL_ENV=commonjs env-cmd -f ht.config.js karma start",
"test:browser.debug": "cross-env-shell BABEL_ENV=commonjs NODE_ENV=debug env-cmd -f ht.config.js karma start",
"test:browser": "cross-env-shell BABEL_ENV=dist env-cmd -f ht.config.js karma start",
"test:browser.debug": "cross-env-shell BABEL_ENV=dist NODE_ENV=debug env-cmd -f ht.config.js karma start",
"test:performance": "npm run benchmark:basic && npm run benchmark:cruds",
"typedoc:build": "typedoc --options .typedoc.ts",
"typedoc:build-api": "typedoc --options .typedoc.md.ts",
Expand All @@ -89,7 +101,7 @@
"@babel/plugin-transform-runtime": "^7.8.3",
"@babel/preset-env": "^7.8.4",
"@babel/register": "^7.9.0",
"@babel/runtime": "^7.8.4",
"@babel/runtime": "^7.18.9",
"@microsoft/tsdoc": "^0.12.16",
"@types/jasmine": "^3.5.10",
"@types/jest": "^25.1.3",
Expand All @@ -104,6 +116,7 @@
"babel-loader": "^8.0.6",
"babel-plugin-transform-inline-environment-variables": "^0.4.3",
"canvas": "^2.6.1",
"core-js": "^3.23.0",
"cross-env": "^7.0.0",
"env-cmd": "^10.1.0",
"eslint": "^6.8.0",
Expand Down Expand Up @@ -143,8 +156,6 @@
},
"dependencies": {
"chevrotain": "^6.5.0",
"core-js": "^3.6.4",
"regenerator-runtime": "^0.13.3",
"tiny-emitter": "^2.1.0",
"unorm": "^1.6.0"
}
Expand Down
8 changes: 4 additions & 4 deletions test/unsupported-types.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ describe('unsupported types should result in error', () => {
// eslint-disable-next-line
// @ts-ignore
expect(() => HyperFormula.buildFromArray([[() => {}]]))
.toThrowError(/^Unable to parse value\: "(\(\) \=\> \{ \}|function \(\) \{\})"$/)
.toThrowError(/^Unable to parse value\: "(\(\) => \{\s*\}|function \(\) \{\s*\})"$/)
})
it('should give parsing error #4', () => {
expect(() => HyperFormula.buildFromSheets({
Expand All @@ -38,7 +38,7 @@ describe('unsupported types should result in error', () => {
// @ts-ignore
Sheet2: [[() => {}]]
}))
.toThrowError(/^Unable to parse value\: "(\(\) \=\> \{ \}|function \(\) \{\})"$/)
.toThrowError(/^Unable to parse value\: "(\(\) \=\> \{\s*\}|function \(\) \{\s*\})"$/)
})
it('should give parsing error #5', () => {
// eslint-disable-next-line
Expand Down Expand Up @@ -90,11 +90,11 @@ describe('unsupported types should result in error', () => {
// eslint-disable-next-line
// @ts-ignore
expect(() => engine.setCellContents(adr('A1'), () => {}))
.toThrowError(/^Unable to parse value\: "(\(\) \=\> \{ \}|function \(\) \{\})"$/)
.toThrowError(/^Unable to parse value\: "(\(\) \=\> \{\s*\}|function \(\) \{\s*\})"$/)
// eslint-disable-next-line
// @ts-ignore
expect(() => engine.setSheetContent(0, [[() => {}]]))
.toThrowError(/^Unable to parse value\: "(\(\) \=\> \{ \}|function \(\) \{\})"$/)
.toThrowError(/^Unable to parse value\: "(\(\) \=\> \{\s*\}|function \(\) \{\s*\})"$/)
})

it('should give error when not an array', () => {
Expand Down
18 changes: 9 additions & 9 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -935,10 +935,10 @@
"pirates" "^4.0.5"
"source-map-support" "^0.5.16"

"@babel/runtime@^7.11.0", "@babel/runtime@^7.8.4":
"integrity" "sha512-38Y8f7YUhce/K7RMwTp7m0uCumpv9hZkitCbBClqQIow1qSbCvGkcegKOXpEWCQLfWmevgRiWokZ1GkpfhbZug=="
"resolved" "https://registry.npmjs.org/@babel/runtime/-/runtime-7.18.3.tgz"
"version" "7.18.3"
"@babel/runtime@^7.11.0", "@babel/runtime@^7.18.9", "@babel/runtime@^7.8.4":
"integrity" "sha512-lkqXDcvlFT5rvEjiu6+QYO+1GXrEHRo2LOtS7E4GtX5ESIZOgepqsZBVIj6Pv+a6zqsya9VCgiK1KAK4BvJDAw=="
"resolved" "https://registry.npmjs.org/@babel/runtime/-/runtime-7.18.9.tgz"
"version" "7.18.9"
dependencies:
"regenerator-runtime" "^0.13.4"

Expand Down Expand Up @@ -3752,10 +3752,10 @@
"browserslist" "^4.20.3"
"semver" "7.0.0"

"core-js@^3.6.4", "core-js@^3.6.5":
"integrity" "sha512-UoGQ/cfzGYIuiq6Z7vWL1HfkE9U9IZ4Ub+0XSiJTCzvbZzgPA69oDF2f+lgJ6dFFLEdjW5O6svvoKzXX23xFkA=="
"resolved" "https://registry.npmjs.org/core-js/-/core-js-3.22.8.tgz"
"version" "3.22.8"
"core-js@^3.23.0", "core-js@^3.6.4", "core-js@^3.6.5":
"integrity" "sha512-7Vh11tujtAZy82da4duVreQysIoO2EvVrur7y6IzZkH1IHPSekuDi8Vuw1+YKjkbfWLRD7Nc9ICQ/sIUDutcyg=="
"resolved" "https://registry.npmjs.org/core-js/-/core-js-3.23.5.tgz"
"version" "3.23.5"

"core-util-is@~1.0.0", "core-util-is@1.0.2":
"integrity" "sha512-3lqz5YjWTYnW6dlDa5TLaTCcShfar1e40rmcJVwCBJC6mWlFuj0eCHIElmG1g5kyuJ/GD+8Wn4FFCcz4gJPfaQ=="
Expand Down Expand Up @@ -9920,7 +9920,7 @@
"resolved" "https://registry.npmjs.org/regenerate/-/regenerate-1.4.2.tgz"
"version" "1.4.2"

"regenerator-runtime@^0.13.3", "regenerator-runtime@^0.13.4":
"regenerator-runtime@^0.13.4":
"integrity" "sha512-p3VT+cOEgxFsRRA9X4lkI1E+k2/CtnKtU4gcxyaCUreilL/vqI6CdZ3wxVUx3UOUg+gnUOQQcRI7BmSI656MYA=="
"resolved" "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.9.tgz"
"version" "0.13.9"
Expand Down

0 comments on commit c43a7fe

Please sign in to comment.