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.

[Feature Request] Add ES module format of ES5 compatible build to dist directory of NPM package

See original GitHub issue

Problem to solve

Allows for a cleaner and non-transpiling build and debug environment, is aligned with future direction of ES Module standards and allows tree shaking via Rollup.js+SystemJS which reduces code deployment sizes.

Proposed solution

At the moment, the Vuetify npm package has an es5 directory which appears to have the per-file compiled source code but in CommonJS module format.

I’m proposing to add an additional ES Module format ES5 build to the dist directory. The precedent for this is that Vue itself is now available in an ES Module format:

https://vuejs.org/v2/guide/installation.html#Explanation-of-Different-Builds

This means you can do a very clean and future proof deployment of native browser import in code and use Rollup.js+SystemJS to package it together for all browsers. This allows you to avoid the overhead and complexity of transpiling and simplifies debugging.

Some notes from Vue’s dist/README.md on this:

CommonJS and ES Module builds are intended for bundlers, therefore we don’t provide minified versions for them. You will be responsible for minifying the final bundle yourself.

CommonJS and ES Module builds also preserve raw checks for process.env.NODE_ENV to determine the mode they should run in. You should use appropriate bundler configurations to replace these environment variables in order to control which mode Vue will run in. Replacing process.env.NODE_ENV with string literals also allows minifiers like UglifyJS to completely drop the development-only code blocks, reducing final file size.

Also, more information here:

http://www.syntaxsuccess.com/viewarticle/bundle-angular-esm2015-with-rollup

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

5reactions
jbergercommented, Mar 19, 2019

I still can’t use the lib directory as an es module because of the use of say ./util/colors rather than ./util/colors.js. With just a few tweaks this seems to be close to just working in the browser directly but sadly it doesn’t seem to.

3reactions
KaelWDcommented, Nov 27, 2018

The lib directory is esm, and will be tree-shaken automatically if you use webpack 4 with vuetify-loader. We did also start switching to rollup for the main dist build, but the current setup works great for most people so it isn’t a priority.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Create a Hybrid NPM Module for ESM and CommonJS.
Author your code in ES6, ES-Next or Typescript using import and export. From this base, you can import either ES modules or CommonJS...
Read more >
How to build, test and release a node module in ES6
Create a new directory for your project that will contain the code for your npm package. Navigate to that directory. For unscoped modules...
Read more >
How to transpile ES modules with webpack and Node.js
Learn how webpack interacts with and supports ES modules in this deep dive tutorial on transpilation in Node.js.
Read more >
How to publish a module written in ES6 to NPM?
The pattern I have seen so far is to keep the es6 files in a src directory and build your stuff in npm's...
Read more >
Hybrid npm packages (ESM and CommonJS) - 2ality
Legacy approach for putting ES modules on npm · ES modules on npm for Node.js with built-in ESM and browsers. Option 1 (experimental,...
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