Skip to content

Commit

Permalink
Get rid of immutable.js and implement tree-shaking for broken control…
Browse files Browse the repository at this point in the history
… flow (#3153)

* Switch to a mutable context
TODO: recursion prevention
TODO: replace "immutable" in the immutable entity path tracker

* Turn the unknown key into a Symbol

* Get rid of immutable and create a new path tracker

* Replace mutable entity tracker with the new simple path tracker

* Refactor context to align ignore properties

* Move function ignore reset to actual functions

* Prevent recursions on call expression level

* Add infinite recursion protection again

* Fix perf script

* Use a Symbol for unknown values as well

* Fix tests after merge

* Add separate context for inclusion

* Handle broken control flow due to errors

* Make if-statement logic more clear

* Simplify BreakFlow type

* Restore broken flow after conditional statements

* Also break on return statements

* Implement basic break support

* Implement continue statements and basic support

* Add basic label support

* Refine label support

* Improve switch-statement handling

* Ignore side-effects after broken control flow, treat hoisted functions as initialized

* Make sure labeled statements do not swallow other break statements

* Refactor switch statement slightly

* Update dependencies and fix tests

* Make the context the first include argument

* Reuse inclusion context when including functions

* Reuse inclusion context when including call arguments

* Reuse inclusion context when including local variables

* Improve coverage for catch scopes

* Improve coverage, check access side-effects for instantiation, respect annotations in new expressions

* Fix old Node syntax error

* Improve coverage

* Improve coverage
  • Loading branch information
lukastaegert committed Oct 15, 2019
1 parent 53266e6 commit 4b16548
Show file tree
Hide file tree
Showing 226 changed files with 3,196 additions and 1,995 deletions.
31 changes: 1 addition & 30 deletions LICENSE.md
Expand Up @@ -154,35 +154,6 @@ Repository: git@github.com:indutny/hash.js

---------------------------------------

## immutable
License: MIT
By: Lee Byron
Repository: git://github.com/facebook/immutable-js.git

> MIT License
>
> Copyright (c) 2014-present, Facebook, Inc.
>
> Permission is hereby granted, free of charge, to any person obtaining a copy
> of this software and associated documentation files (the "Software"), to deal
> in the Software without restriction, including without limitation the rights
> to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
> copies of the Software, and to permit persons to whom the Software is
> furnished to do so, subject to the following conditions:
>
> The above copyright notice and this permission notice shall be included in all
> copies or substantial portions of the Software.
>
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
> FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
> AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
> LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
> OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
> SOFTWARE.
---------------------------------------

## inherits
License: ISC
Repository: git://github.com/isaacs/inherits
Expand Down Expand Up @@ -398,7 +369,7 @@ Repository: git://github.com/kamicane/require-relative.git
## rollup-pluginutils
License: MIT
By: Rich Harris
Repository: git+https://github.com/rollup/rollup-pluginutils.git
Repository: rollup/rollup-pluginutils

---------------------------------------

Expand Down
156 changes: 98 additions & 58 deletions package-lock.json

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

13 changes: 6 additions & 7 deletions package.json
Expand Up @@ -86,13 +86,12 @@
"es6-shim": "^0.35.5",
"eslint": "^6.5.1",
"eslint-plugin-import": "^2.18.2",
"execa": "^2.0.5",
"execa": "^2.1.0",
"fixturify": "^1.2.0",
"hash.js": "^1.1.7",
"husky": "^3.0.8",
"immutable": "^4.0.0-rc.12",
"is-reference": "^1.1.4",
"lint-staged": "^9.4.1",
"lint-staged": "^9.4.2",
"locate-character": "^2.0.5",
"magic-string": "^0.25.4",
"markdownlint-cli": "^0.18.0",
Expand All @@ -105,7 +104,7 @@
"pretty-ms": "^5.0.0",
"require-relative": "^0.8.7",
"requirejs": "^2.3.6",
"rollup": "^1.23.0",
"rollup": "^1.23.1",
"rollup-plugin-alias": "^2.0.1",
"rollup-plugin-buble": "^0.19.8",
"rollup-plugin-commonjs": "^10.1.0",
Expand All @@ -123,12 +122,12 @@
"source-map": "^0.6.1",
"source-map-support": "^0.5.13",
"sourcemap-codec": "^1.4.6",
"systemjs": "^6.1.2",
"terser": "^4.3.6",
"systemjs": "^6.1.3",
"terser": "^4.3.8",
"tslib": "^1.10.0",
"tslint": "^5.20.0",
"turbocolor": "^2.6.1",
"typescript": "^3.6.3",
"typescript": "^3.6.4",
"url-parse": "^1.4.7"
},
"files": [
Expand Down
9 changes: 6 additions & 3 deletions scripts/load-perf-config.js
Expand Up @@ -8,7 +8,9 @@ const configFile = path.resolve(exports.targetDir, 'rollup.config.js');
try {
fs.accessSync(configFile, fs.constants.R_OK);
} catch (e) {
console.error(`No valid "rollup.config.js" in ${exports.targetDir}. Did you "npm run perf:init"?`);
console.error(
`No valid "rollup.config.js" in ${exports.targetDir}. Did you "npm run perf:init"?`
);
process.exit(1);
}

Expand All @@ -18,8 +20,9 @@ exports.loadPerfConfig = async () => {
external: id => (id[0] !== '.' && !path.isAbsolute(id)) || id.slice(-5, id.length) === '.json',
onwarn: warning => console.error(warning.message)
});
const configs = loadConfigFromCode((await bundle.generate({ format: 'cjs' })).code);
return Array.isArray(configs) ? configs[0] : configs;
let config = loadConfigFromCode((await bundle.generate({ format: 'cjs' })).output[0].code);
config = typeof config === 'function' ? config({}) : config;
return Array.isArray(config) ? config[0] : config;
};

function loadConfigFromCode(code) {
Expand Down

0 comments on commit 4b16548

Please sign in to comment.