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

Add strict mode directive to module bundles #8710

Open
wants to merge 18 commits into
base: v2
Choose a base branch
from

Conversation

mischnic
Copy link
Member

Closes #8706

@parcel-benchmark
Copy link

parcel-benchmark commented Dec 21, 2022

Benchmark Results

Kitchen Sink ✅

Timings

Description Time Difference
Cold 1.83s -28.00ms
Cached 412.00ms +5.00ms

Cold Bundles

Bundle Size Difference Time Difference
dist/legacy/index.7d75205b.js 1.63kb -13.00b 🚀 457.00ms +14.00ms

Cached Bundles

Bundle Size Difference Time Difference
dist/legacy/index.7d75205b.js 1.63kb -13.00b 🚀 447.00ms +5.00ms

React HackerNews ✅

Timings

Description Time Difference
Cold 8.65s +66.00ms
Cached 522.00ms +9.00ms

Cold Bundles

Bundle Size Difference Time Difference
dist/index.js 463.02kb -3.55kb 🚀 1.26s -13.00ms
dist/PermalinkedComment.60e78a07.js 4.18kb -26.00b 🚀 506.00ms -76.00ms 🚀
dist/UserProfile.c18819ee.js 1.57kb +0.00b 506.00ms -75.00ms 🚀
dist/NotFound.cfeedbab.js 427.00b +0.00b 506.00ms -76.00ms 🚀

Cached Bundles

Bundle Size Difference Time Difference
dist/index.js 463.02kb -3.55kb 🚀 1.38s +66.00ms
dist/PermalinkedComment.60e78a07.js 4.18kb -26.00b 🚀 590.00ms +48.00ms ⚠️
dist/UserProfile.c18819ee.js 1.57kb +0.00b 590.00ms +47.00ms ⚠️
dist/NotFound.cfeedbab.js 427.00b +0.00b 590.00ms +47.00ms ⚠️

AtlasKit Editor ✅

Timings

Description Time Difference
Cold 1.26m -1.11s
Cached 2.66s +143.00ms ⚠️

Cold Bundles

Bundle Size Difference Time Difference
dist/refractor.c460668c.js 601.81kb +0.00b 12.74s -640.00ms 🚀
dist/popup.2cbde099.js 329.78kb +0.00b 12.74s -722.00ms 🚀
dist/EmojiPickerComponent.a25bd8e7.js 196.67kb +0.00b 12.74s -717.00ms 🚀
dist/esm.6df2a542.js 64.51kb +0.00b 12.74s -723.00ms 🚀
dist/esm.bd488cd8.js 40.24kb +0.00b 12.74s -720.00ms 🚀
dist/smartMediaEditor.8713e5a6.js 22.24kb +0.00b 12.74s -727.00ms 🚀
dist/esm.a10f92b5.js 21.06kb +0.00b 12.74s -727.00ms 🚀
dist/dropzone.4b8113c9.js 14.00kb +0.00b 12.74s -723.00ms 🚀
dist/dropzone.ae8c8d79.js 11.95kb +0.00b 12.74s -723.00ms 🚀
dist/Toolbar.7fda8a1b.js 9.30kb +0.00b 12.74s -727.00ms 🚀
dist/clipboard.ef3ddc39.js 8.22kb +0.00b 12.74s -723.00ms 🚀
dist/mobile-upload.31f0e326.js 8.08kb +0.00b 12.74s -727.00ms 🚀
dist/browser.0a7fd453.js 7.48kb +0.00b 12.74s -722.00ms 🚀
dist/index.6d0e3617.js 7.32kb +0.00b 12.74s -727.00ms 🚀
dist/index.b16227d6.css 4.08kb +0.00b 12.79s -731.00ms 🚀
dist/media-picker-analytics-error-boundary.627962a5.js 3.46kb +0.00b 12.74s -721.00ms 🚀
dist/media-card-analytics-error-boundary.ec5ff8ee.js 3.45kb +0.00b 12.74s -722.00ms 🚀
dist/workerHasher.13de9709.js 1.72kb +0.00b 12.74s -723.00ms 🚀
dist/workerHasher.99c37306.js 1.72kb +0.00b 12.74s -720.00ms 🚀
dist/workerHasher.c5ba46bc.js 1.72kb +0.00b 12.74s -720.00ms 🚀
dist/simpleHasher.a19114f9.js 687.00b +0.00b 12.74s -723.00ms 🚀
dist/simpleHasher.023b58fa.js 687.00b +0.00b 12.74s -720.00ms 🚀
dist/simpleHasher.97222d8a.js 687.00b +0.00b 12.74s -727.00ms 🚀

Cached Bundles

Bundle Size Difference Time Difference
dist/pdfRenderer.4f3765de.js 1.11mb +0.00b 15.15s +877.00ms ⚠️
dist/media-viewer.bd165005.js 542.15kb +0.00b 9.89s +560.00ms ⚠️
dist/ConfigPanelFieldsLoader.f06a6b36.js 312.08kb +0.00b 9.90s +549.00ms ⚠️
dist/card.501ecffa.js 143.52kb +0.00b 9.89s +560.00ms ⚠️
dist/ConfigPanelFieldsLoader.e1ae433f.js 83.45kb +0.00b 9.90s +548.00ms ⚠️
dist/ElementBrowser.3bcad544.js 65.85kb +0.00b 9.90s +548.00ms ⚠️
dist/esm.945b66be.js 60.94kb +0.00b 9.89s +559.00ms ⚠️
dist/DatePicker.3a60f244.js 48.38kb +0.00b 7.48s +455.00ms ⚠️
dist/DatePicker.b0a4d8f4.js 25.21kb +0.00b 7.48s +454.00ms ⚠️
dist/ConfigPanelFieldsLoader.ef739802.js 16.14kb +0.00b 9.90s +549.00ms ⚠️
dist/ui.2de0ef21.js 14.88kb +0.00b 9.90s +548.00ms ⚠️
dist/ConfigPanelFieldsLoader.c68d84ab.js 14.25kb +0.00b 9.90s +549.00ms ⚠️
dist/pdfRenderer.187ba54d.js 12.21kb +0.00b 9.89s +560.00ms ⚠️
dist/mobile-upload.136dd5cb.js 8.08kb +0.00b 9.90s +548.00ms ⚠️
dist/mobile-upload.0bdb676c.js 8.08kb +0.00b 9.90s +563.00ms ⚠️
dist/ru.896915b9.js 2.94kb +0.00b 9.89s +560.00ms ⚠️
dist/uk.48c97550.js 2.89kb +0.00b 9.90s +560.00ms ⚠️
dist/codeViewerRenderer.915ef6b3.js 2.84kb +0.00b 9.89s -2.96s 🚀
dist/th.31044730.js 2.73kb +0.00b 9.89s +560.00ms ⚠️
dist/ResourcedEmojiComponent.04d67e5e.js 2.69kb +0.00b 7.48s +454.00ms ⚠️
dist/pl.5f36d63e.js 2.38kb +0.00b 7.48s +455.00ms ⚠️
dist/cs.971d1d60.js 2.36kb +0.00b 7.48s +456.00ms ⚠️
dist/de.6efbb375.js 2.30kb +0.00b 7.48s +455.00ms ⚠️
dist/fr.af2c92ae.js 2.25kb +0.00b 7.48s +455.00ms ⚠️
dist/es.23f0c164.js 2.25kb +0.00b 7.48s +454.00ms ⚠️
dist/hu.8323f36b.js 2.23kb +0.00b 7.48s +454.00ms ⚠️
dist/fi.7ed4b1b5.js 2.22kb +0.00b 7.48s +454.00ms ⚠️
dist/ja.5653161c.js 2.22kb +0.00b 7.48s +454.00ms ⚠️
dist/vi.d8dcb67a.js 2.22kb +0.00b 9.90s +561.00ms ⚠️
dist/pt_BR.eccfad73.js 2.19kb +0.00b 7.48s +454.00ms ⚠️
dist/tr.46f26598.js 2.16kb +0.00b 9.89s +560.00ms ⚠️
dist/ko.2cf2bbda.js 2.11kb +0.00b 7.48s +454.00ms ⚠️
dist/sv.13d93533.js 2.10kb +0.00b 9.89s +560.00ms ⚠️
dist/it.601d375a.js 2.10kb +0.00b 7.48s +454.00ms ⚠️
dist/nb.b300dd3e.js 2.09kb +0.00b 7.48s +454.00ms ⚠️
dist/date.7b2f9581.js 2.07kb +0.00b 6.79s +353.00ms ⚠️
dist/da.21385cf2.js 2.07kb +0.00b 7.48s +455.00ms ⚠️
dist/nl.3999ea58.js 2.07kb +0.00b 7.48s +454.00ms ⚠️
dist/images.46c877f3.js 2.03kb +0.00b 6.79s +353.00ms ⚠️
dist/zh_TW.afaf6222.js 1.98kb +0.00b 9.90s +549.00ms ⚠️
dist/zh.fcdc32bb.js 1.96kb +0.00b 9.90s +549.00ms ⚠️
dist/feedback.fd1f6260.js 1.89kb +0.00b 7.48s +454.00ms ⚠️
dist/status.6f638b3d.js 1.80kb +0.00b 6.80s +352.00ms ⚠️
dist/workerHasher.ef49a7fc.js 1.72kb +0.00b 9.90s +548.00ms ⚠️
dist/workerHasher.9d5fe27b.js 1.72kb +0.00b 9.90s +563.00ms ⚠️
dist/code.ef3dfa9c.js 1.69kb +0.00b 6.79s +353.00ms ⚠️
dist/list-number.35bc7f17.js 1.60kb +0.00b 6.80s +353.00ms ⚠️
dist/heading6.974f167d.js 1.49kb +0.00b 7.48s +454.00ms ⚠️
dist/heading3.9ad47cbe.js 1.48kb +0.00b 6.80s +352.00ms ⚠️
dist/link.542e87bf.js 1.41kb +0.00b 6.80s +353.00ms ⚠️
dist/emoji.79757e2c.js 1.38kb +0.00b 6.79s +353.00ms ⚠️
dist/heading5.023a8f1f.js 1.36kb +0.00b 7.48s +455.00ms ⚠️
dist/expand.801fc3a0.js 1.31kb +0.00b 7.48s +454.00ms ⚠️
dist/heading2.bffcdf12.js 1.30kb +0.00b 6.80s +352.00ms ⚠️
dist/heading4.05995ed9.js 1.25kb +0.00b 6.80s +353.00ms ⚠️
dist/mention.adafe481.js 1.21kb +0.00b 6.80s +353.00ms ⚠️
dist/layout.40f6b132.js 1.17kb +0.00b 6.80s +354.00ms ⚠️
dist/divider.616b37d8.js 1.17kb +0.00b 6.79s +353.00ms ⚠️
dist/action.361730a6.js 1.15kb +0.00b 6.79s +353.00ms ⚠️
dist/heading1.495af5dc.js 1.14kb +0.00b 6.80s +352.00ms ⚠️
dist/list.c5ad55b6.js 1.11kb +0.00b 6.80s +353.00ms ⚠️
dist/quote.235ab420.js 1.11kb +0.00b 6.80s +353.00ms ⚠️
dist/decision.36a0b771.js 1.10kb +0.00b 6.79s +352.00ms ⚠️
dist/panel-warning.7e72ad42.js 1.07kb +0.00b 6.80s +352.00ms ⚠️
dist/16.0d8c3c9e.js 1.06kb +0.00b 6.79s +353.00ms ⚠️
dist/table.389f0908.js 1.05kb +0.00b 6.80s +352.00ms ⚠️
dist/panel.7cee1972.js 1017.00b +0.00b 6.80s +353.00ms ⚠️
dist/panel-error.e46252ff.js 994.00b +0.00b 6.80s +353.00ms ⚠️
dist/16.dcf139e7.js 951.00b +0.00b 6.79s +353.00ms ⚠️
dist/panel-success.dbd2515b.js 935.00b +0.00b 6.80s +353.00ms ⚠️
dist/panel-note.b6c94ff5.js 925.00b +0.00b 6.80s +353.00ms ⚠️
dist/16.f6395317.js 876.00b +0.00b 6.79s +353.00ms ⚠️
dist/sk.101f1705.js 786.00b +0.00b 9.89s +560.00ms ⚠️
dist/pt_PT.402f9c4e.js 765.00b +0.00b 7.48s +454.00ms ⚠️
dist/et.69382942.js 763.00b +0.00b 7.48s +454.00ms ⚠️
dist/simpleHasher.f1f58b0a.js 687.00b +0.00b 9.90s +548.00ms ⚠️
dist/simpleHasher.09f4d713.js 687.00b +0.00b 9.90s +563.00ms ⚠️
dist/is.5b945719.js 625.00b +0.00b 7.48s +454.00ms ⚠️
dist/ro.a6eff34a.js 612.00b +0.00b 7.48s -1.78s 🚀
dist/en_GB.61f7112a.js 602.00b +0.00b 7.48s +454.00ms ⚠️
dist/en.41261459.js 599.00b +0.00b 7.48s +455.00ms ⚠️

Three.js ✅

Timings

Description Time Difference
Cold 5.86s -56.00ms
Cached 312.00ms -12.00ms

Cold Bundles

No bundle changes detected.

Cached Bundles

No bundle changes detected.

Click here to view a detailed benchmark overview.

@mischnic

This comment was marked as resolved.

@@ -1 +1 @@
output = require('./');
global.output = require('./');
Copy link
Member Author

Choose a reason for hiding this comment

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

Due to nodejs/node#38918 (comment) (only needed if the value being assigned is a function)

@@ -3611,7 +3611,8 @@ describe('scope hoisting', function () {
assert.equal(output, 42);
});

it('builds commonjs modules that assigns to module.exports before exports', async function () {
// TODO this should be working
it.skip('builds commonjs modules that assigns to module.exports before exports', async function () {
Copy link
Member Author

@mischnic mischnic Dec 22, 2022

Choose a reason for hiding this comment

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

The output right now is

parcelRequire.register("5CKoA", function(module, exports) {
module.exports = 42;
module.exports.foo = 27;
});

which is invalid in strict mode (something like "cannot add property to number")

Copy link
Member

Choose a reason for hiding this comment

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

should we just change the first assignment to an object?

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah, forgot to include the input code:

module.exports = 42;
exports.foo = 27;

so this really is a failing test (just like the other one with the undeclared variable).
(The correct behaviour here is that "42" is exported and the second line does nothing)

Copy link
Member

@devongovett devongovett left a comment

Choose a reason for hiding this comment

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

Seems fine. We should come back to the failing tests at some point.

@devongovett
Copy link
Member

@mischnic do you still want to merge this?

@phfaist
Copy link

phfaist commented Jul 20, 2023

Hi, thanks a lot for the progress so far! I was wondering if there is any plan to merge this fix, or if there is an alternative workaround/fix planned? Thanks again!

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.

Inconsistent javascript arguments behavior between live development and production builds
4 participants