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

fix: simplify rollup package #659

Merged
merged 10 commits into from
Sep 21, 2018
Merged

fix: simplify rollup package #659

merged 10 commits into from
Sep 21, 2018

Conversation

diervo
Copy link
Contributor

@diervo diervo commented Sep 20, 2018

Details

Decouple all rollup plugins, simplify code around it.

@diervo
Copy link
Contributor Author

diervo commented Sep 20, 2018

@dbajric This will probably break the current best configuration for IE11.
I will udpate it either in this PR or in a further one.

Copy link
Member

@pmdartus pmdartus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I ❤️ this PR

},
"dependencies": {
"es5-proxy-compat": "0.19.0",
"es5-proxy-compat": "0.20.3",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't es5-proxy-compat be a devDependency now?

"eslint": "~4.13.0",
"eslint-plugin-lwc": "^0.2.4",
"express": "^4.15.2",
"lwc-compiler": "0.29.1",
"lwc-engine": "0.29.1",
"lwc-jest-transformer": "0.17.15",
"rollup": "0.60.1",
"rollup-plugin-compat": "0.19.0",
"rollup-plugin-compat": "0.20.3",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If all the compat related packages are now devDependencies can we hoist them at the root of the monorepo? This would avoid running into version discrepancies.

@@ -11,7 +11,7 @@ const entry = path.resolve(__dirname, '../../src/framework/main.ts');
const commonJSDirectory = path.resolve(__dirname, '../../dist/commonjs');
const modulesDirectory = path.resolve(__dirname, '../../dist/modules');

const banner = (`/* proxy-compat-disable */`);
const banner = (`/* es5-compat-disable */\n/* proxy-compat-disable */`);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need both pragmas? One should be deprecated now.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, we need two because we need to be able to disable in engine any transform at all. That is the only only way to do it in way that doesn't require special one-offs in the rollup plugins

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the difference between both pragma?

@@ -19,7 +19,7 @@
"@babel/plugin-proposal-object-rest-spread": "7.0.0",
"@types/chokidar": "^1.7.5",
"babel-plugin-transform-lwc-class": "0.29.1",
"babel-preset-compat": "0.19.0",
"babel-preset-compat": "0.20.3",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting that the compiler depends on the babel-preset-compat. I am wondering if we can do something here as well to get rid of the direct dependency.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why? You would have to depend on all the babel dependencies and the do pretty much the same thing the package is doing. Since we own that package not sure why would we gain.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was just wondering. I agree with you.


it(`simple app`, async () => {
const lwcPath = getLwcEnginePath(rollupOptions.mode);
const lwcPath = getLwcEnginePath('compat');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand exactly what does this tests do, the title is probably wrong since you are not asserting against the generated code.

@@ -6,9 +6,11 @@ import { defineProperty } from "./language";
* creation of symbols, so we can fallback to string when native symbols
* are not supported.
*/
const supportSymbols = Symbol('x').toString() === 'Symbol(x)';
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@caridy @pmdartus I changed our check so it works when transpiling down to es5 OOTB

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should actually be faster

@@ -6,9 +6,11 @@ import { defineProperty } from "./language";
* creation of symbols, so we can fallback to string when native symbols
* are not supported.
*/
const hasNativeSymbolsSupport = Symbol('x').toString() === 'Symbol(x)';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't fully understand this change. In theory, if the env is patched, this should return true. How is that typeof Symbol() === 'symbol' is not reliable?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the only case in which the original condition is true: typeof Symbol() === 'symbol' in IE11, is if the polyfill runs first, and theengine itself gets transformed for typeof

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The polyfill MUST always run first.
Precisely the typeof doesn't work because its translated to _typeof

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for posterity, any symbol polyfill uses the toString() to generate a unique key, while the native has a very well defined output.

additionally, the original condition doesn't work because in compat mode for IE11, that typeof is also transformed, which means that the condition is always true after the polyfill and the transformation occur,

Copy link
Contributor

@caridy caridy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's clarify the runtime change in this PR before merging this.

@@ -6,9 +6,11 @@ import { defineProperty } from "./language";
* creation of symbols, so we can fallback to string when native symbols
* are not supported.
*/
const hasNativeSymbolsSupport = Symbol('x').toString() === 'Symbol(x)';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the only case in which the original condition is true: typeof Symbol() === 'symbol' in IE11, is if the polyfill runs first, and theengine itself gets transformed for typeof

Copy link
Contributor

@caridy caridy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's roll!

@salesforce-best-lwc-internal
Copy link

Benchmark results

Base commit: ee1e513 | Target commit: 12e4c63

lwc-engine-benchmark-ie11

table-append-1k metric base(ee1e513) target(12e4c63) trend
benchmark-table/append/1k duration 879.50 (±0.00 ms) 786.60 (±0.00 ms) -92.9ms (10.6%) 👌
table-clear-1k metric base(ee1e513) target(12e4c63) trend
benchmark-table/clear/1k duration 79.90 (±0.00 ms) 76.30 (±0.00 ms) -3.6ms (4.5%) 👌
table-create-10k metric base(ee1e513) target(12e4c63) trend
benchmark-table/create/10k duration 8253.80 (±0.00 ms) 7456.50 (±0.00 ms) -797.3ms (9.7%) 👌
table-create-1k metric base(ee1e513) target(12e4c63) trend
benchmark-table/create/1k duration 727.90 (±0.00 ms) 677.90 (±0.00 ms) -50.0ms (6.9%) 👌
table-update-10th-1k metric base(ee1e513) target(12e4c63) trend
benchmark-table/update-10th/1k duration 124.50 (±0.00 ms) 109.70 (±0.00 ms) -14.8ms (11.9%) 👌
tablecmp-append-1k metric base(ee1e513) target(12e4c63) trend
benchmark-table-component/append/1k duration 1542.00 (±0.00 ms) 1025.60 (±0.00 ms) -516.4ms (33.5%) 👌
tablecmp-clear-1k metric base(ee1e513) target(12e4c63) trend
benchmark-table-component/clear/1k duration 144.80 (±0.00 ms) 151.00 (±0.00 ms) +6.2ms (4.3%) 👌
tablecmp-create-10k metric base(ee1e513) target(12e4c63) trend
benchmark-table-component/create/10k duration 15996.30 (±0.00 ms) 10542.40 (±0.00 ms) -5453.9ms (34.1%) 👌
tablecmp-create-1k metric base(ee1e513) target(12e4c63) trend
benchmark-table-component/create/1k duration 1390.50 (±0.00 ms) 952.90 (±0.00 ms) -437.6ms (31.5%) 👌
tablecmp-update-10th-1k metric base(ee1e513) target(12e4c63) trend
benchmark-table-component/update-10th/1k duration 104.70 (±0.00 ms) 140.50 (±0.00 ms) +35.8ms (34.2%) 👌

lwc-engine-benchmark

table-append-1k metric base(ee1e513) target(12e4c63) trend
benchmark-table/append/1k duration 161.45 (±4.75 ms) 159.70 (±4.05 ms) -1.8ms (1.1%) 👌
table-clear-1k metric base(ee1e513) target(12e4c63) trend
benchmark-table/clear/1k duration 12.55 (±0.70 ms) 13.00 (±0.90 ms) +0.4ms (3.6%) 👎
table-create-10k metric base(ee1e513) target(12e4c63) trend
benchmark-table/create/10k duration 924.15 (±6.65 ms) 942.95 (±9.60 ms) +18.8ms (2.0%) 👎
table-create-1k metric base(ee1e513) target(12e4c63) trend
benchmark-table/create/1k duration 111.95 (±2.15 ms) 113.35 (±2.50 ms) +1.4ms (1.3%) 👎
table-update-10th-1k metric base(ee1e513) target(12e4c63) trend
benchmark-table/update-10th/1k duration 87.80 (±3.30 ms) 87.35 (±2.30 ms) -0.5ms (0.5%) 👌
tablecmp-append-1k metric base(ee1e513) target(12e4c63) trend
benchmark-table-component/append/1k duration 241.75 (±9.10 ms) 228.25 (±17.00 ms) -13.5ms (5.6%) 👍
tablecmp-clear-1k metric base(ee1e513) target(12e4c63) trend
benchmark-table-component/clear/1k duration 20.60 (±2.60 ms) 20.60 (±2.15 ms) 0.0ms (0.0%) 👌
tablecmp-create-10k metric base(ee1e513) target(12e4c63) trend
benchmark-table-component/create/10k duration 1667.65 (±11.55 ms) 1696.35 (±18.65 ms) +28.7ms (1.7%) 👎
tablecmp-create-1k metric base(ee1e513) target(12e4c63) trend
benchmark-table-component/create/1k duration 184.55 (±5.35 ms) 191.90 (±4.55 ms) +7.3ms (4.0%) 👎
tablecmp-update-10th-1k metric base(ee1e513) target(12e4c63) trend
benchmark-table-component/update-10th/1k duration 84.85 (±4.85 ms) 85.70 (±4.90 ms) +0.8ms (1.0%) 👌
wc-append-1k metric base(ee1e513) target(12e4c63) trend
benchmark-table-wc/append/1k duration 274.20 (±14.70 ms) 276.20 (±17.55 ms) +2.0ms (0.7%) 👌
wc-clear-1k metric base(ee1e513) target(12e4c63) trend
benchmark-table-wc/clear/1k duration 30.00 (±2.35 ms) 31.10 (±2.90 ms) +1.1ms (3.7%) 👌
wc-create-10k metric base(ee1e513) target(12e4c63) trend
benchmark-table-wc/create/10k duration 2149.10 (±16.55 ms) 2137.40 (±13.05 ms) -11.7ms (0.5%) 👍
wc-create-1k metric base(ee1e513) target(12e4c63) trend
benchmark-table-wc/create/1k duration 232.50 (±6.25 ms) 225.20 (±5.85 ms) -7.3ms (3.1%) 👍
wc-update-10th-1k metric base(ee1e513) target(12e4c63) trend
benchmark-table-wc/update-10th/1k duration 86.70 (±5.95 ms) 84.70 (±6.75 ms) -2.0ms (2.3%) 👌

@diervo diervo merged commit e59f0f6 into master Sep 21, 2018
@diervo diervo deleted the dval/rollupUpgrade branch September 21, 2018 05:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants