question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Dist files contain eval

See original GitHub issue

Currently, the browser field (and maybe the main field depending on #609) point to dist/autoNumeric.js, which is a bundle that uses a bunch of eval function calls to make the code work.

I wasn’t able to find anything definitive on this but I think libraries shouldn’t be distributed using eval. The only real evidence I have of my claim is that out of all the libraries my app uses, AutoNumeric is the only one that ends up with eval in my bundle.

However, it also causes a real observable issue: the eval code is full of comments and whitespace, and those are not able to be stripped out by minifying build processes since they are in an eval call where the code is just strings.

An easy solution is to simply make it point to the dist/autoNumeric.min.js file instead.

Another, arguably better solution, would be for me to simply let my Webpack build process use the module attribute (see #604), as described in Webpack’s Authoring Libraries article:

The module property should point to a script that utilizes ES2015 module syntax but no other syntax features that aren’t yet supported by browsers or node. This enables webpack to parse the module syntax itself, allowing for lighter bundles via tree shaking if users are only consuming certain parts of the library.

However, since this file uses ES6 syntax not correctly handled by browsers I need to support, I would have to complicate my build process to transpile AutoNumeric as an exception inside node_modules. There might be a way for AutoNumeric to provide a file that transpiles everything but module syntax to ES5 but I haven’t found such a way in my quick search.

All in all I am not sure of what the right solution is, I’m still relatively new to the world of webpack, but I wanted to raise the issue nonetheless.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
AlexandreBonneaucommented, Oct 13, 2018

This is live in v4.5.0

1reaction
alexturpincommented, Oct 10, 2018

Wonderful!

When using the library directly in the browser, users should not include the 1.5MB dist/autoNumeric.js file; the 190kB minified version – or even better, the 40kB compressed minified version – are preferred.

In this case, I would argue that browser in package.json should point to the minified (uncompressed) version.

Read more comments on GitHub >

github_iconTop Results From Across the Web

disallow access to filesystem inside exec and eval in Python
I'm envisioning a system where your exec-like function spawns a subprocess under a very strict AppArmor profile, such as the one used by ......
Read more >
TSConfig Reference - Docs on every TSConfig option
Specifies an allowlist of files to include in the program. An error occurs if any of the ... If your outDir was dist...
Read more >
Python eval(): Evaluate Expressions Dynamically - Real Python
Python's eval() allows you to evaluate arbitrary Python expressions from a string-based or compiled-code-based input. This function can be handy when you're ...
Read more >
Working With Files - Gradle User Manual
The Project.file(java.lang.Object) method is used to create a file or directory path relative to the current project and is a common way to...
Read more >
Python eval() - Programiz
If you allow users to input a value using eval(input()) , the user may issue commands to change file or even delete all...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found