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.

Modules export minified code

See original GitHub issue

The UMD modules available in npm export minified code. While this does not stop us using these modules, it throws warnings in our Webpack dev server. Since these are source modules would it make more sense to export them un-minified and leave the end user to handle minification?

Example of console warning:

./~/braintree-web/client.js
Critical dependencies:
1:438-445 This seems to be a pre-built javascript file. Though this is possible, it's not recommended. Try to require the original source to get better results.
@ ./~/braintree-web/client.js 1:438-445

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:3
  • Comments:10 (4 by maintainers)

github_iconTop GitHub Comments

5reactions
crookedneighborcommented, Aug 23, 2016

The problem is not that it’s minified, but that it is pre-built using Browserify. If you use the the debug versions of the files which are not minified (like require('braintree-web/client.debug')), you’ll get the same error because they are still bundled beforehand.

We’re discussing how we can support Webpack without displaying these errors, but it requires us to change how we distribute the files and we want to make sure we don’t break anyone who is already using the package. For example, if someone is downloading the module through npm and then copying the files from the node_modules folder directly to their frontend, providing pre-built files would break their integration as soon as they upgraded to a new minor version.

4reactions
mrakcommented, Sep 21, 2016

Thanks for the detailed response, @M-Porter. You are absolutely correct; we overlooked our index.js and debug.js files which still had references to require.

We have just released version 3.3.0 where these two files are correctly bundled without references to require.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to minify/obfuscate separate JS modules in a way that ...
So I need the API to be minified in the same way, to use the same names. For example - if export function...
Read more >
The JavaScript Modules Handbook – Complete Guide to ES ...
A JavaScript module is a file that allows you to export its code. ... In other words, distribution code is the minified and...
Read more >
Package exports - webpack
The exports field in the package.json of a package allows to declare which module should be used when using module requests like import...
Read more >
Modules, introduction - The Modern JavaScript Tutorial
A module code is evaluated only the first time when imported · A module exports some means of configuration, e.g. a configuration object....
Read more >
Best Practice Tips for Writing Your JS Modules
Just output the code as authored or as close to it as possible and let the client figure out if they want it...
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