You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I noticed that build size is increased dramatically compared to app.import() if used to import sjcl.
A new ember project has a build size of 722.68 KB (190.55 KB gzipped) for vendor.js. Importing sjcl using app.import() increases the build size by 24,18 KB (8,46 KB gzipped). This matches with the size of node_modules/sjcl/sjcl.js (28 KB) and their docs:
The minified version of the library is under 6.4KB compressed, and yet it posts impressive speed results.
Using ember-auto-import instead of app.import() the build size is increased by ~300 KB (103,79 KB gzipped) to 1.02 MB (294.34 KB gzipped).
ember new ember-auto-import-build-size
cd ember-auto-import-build-size/
# reference size
ember build --prod
yarn add --dev sjcl
sed -i "1s/^/import sjcl from 'sjcl';\n/" app/router.js
# import sjcl using app.import()
sed -i "22s/^/app.import('node_modules\/sjcl\/sjcl.js', { using: [{ transformation: 'amd', as: 'sjcl' }] });\n/" ember-cli-build.js
ember build --prod
# import sjcl using ember-auto-import
git checkout ember-cli-build.js
ember install ember-auto-import
ember build --prod
The text was updated successfully, but these errors were encountered:
sjcl includes the line require('crypto'). That's an unambiguous request to try to use node's crypto library and webpack obliges by packaging up a portable version of said library. The sjcl maintainers closed the issue, which unfortunately punts the solution onto anyone who is consuming sjcl via webpack.
The right place to fix this is still upstream in sjcl, probably by having separate entrypoint for browesr vs node, and using the main and browser fields in package.json to distinguish them.
As a meta point for any future readers: whenever some library is acting weird when used via ember-auto-import, search their issues for "webpack" and you'll almost always find out why. The ubiquity of webpack means that most of these bugs have been seen before (that is one reason I chose to build on top of webpack).
I noticed that build size is increased dramatically compared to
app.import()
if used to importsjcl
.A new ember project has a build size of 722.68 KB (190.55 KB gzipped) for
vendor.js
. Importing sjcl usingapp.import()
increases the build size by 24,18 KB (8,46 KB gzipped). This matches with the size ofnode_modules/sjcl/sjcl.js
(28 KB) and their docs:Using ember-auto-import instead of
app.import()
the build size is increased by ~300 KB (103,79 KB gzipped) to 1.02 MB (294.34 KB gzipped).I don't see any hints in debug output:
Steps to reproduce:
The text was updated successfully, but these errors were encountered: