Include es6 module format for dat/gui/GUI in build/
See original GitHub issueAll modern browsers now include native es6 modules (except for chrome which will land shortly we hope).
Your repo already supports es6 imports, but uses module.exports = GUI
rather than export default GUI
.
Could you include an es6 module?
Issue Analytics
- State:
- Created 6 years ago
- Reactions:2
- Comments:13 (3 by maintainers)
Top Results From Across the Web
JavaScript modules - MDN Web Docs
This guide gives you all you need to get started with JavaScript module syntax.
Read more >A Practical guide to ES6 modules - freeCodeCamp
Let's build a dashboard with modules. Now that we have a basic understanding of how modules work, let's view a practical example you'll...
Read more >16. Modules - Exploring JS
ES6 is the first time that JavaScript has built-in modules. ES6 modules are stored in files. There is exactly one module per file...
Read more >ES6 Modules and How to Use Import and Export in JavaScript
If you have any suggestions for improvements, please let us know ... With ES2015 (ES6), with get built-in support for modules in JavaScript....
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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
TL;DR: I’ve got two versions of dat.gui as modules, one making 4 modifications to the source such that rollup can build a module, the other using a “wrapper”. May be of use to you or your users.
Details: Sorry for being chatty! I definitely do not want to dominate the discussion! But I’ve now got dat.gui running as a module for my repo using one of two methods:
1 - convert to module: several dependencies are already in module form but don’t expose it. dat.gui, for example was easily converted to a module via a bash script of 4 modifications of the dat.gui source, with rollup. 2 - wrapper: for dat.gui and other repos, I have a “wraplib” node script that takes in the legacy form (foo.min.js for example) and wraps it in a module having a function that executes it wrapped with its own window, module, ‘this’, and return value … and finds the resulting foo code, exporting it as
export default foo
I’ve tested both of these with several dependencies I have. I prefer method 1, generally, because when the project converts to modules, my project can easily use it. Method 2 has the advantage that it “just works” for all the libraries I’ve tried. dat.gui works fine using either with my small set of tests. I’ll soon push this into all my demos, so should show any problems.
Details of the two stunts. Feel free to ask about details. … The dat.gui module bash script looks like
… The dat.gui wrapper created by the node wraplib.js looks like:
In my experience, the best migration to modules, and still support legacy, is:
This results in a simple modules based core, and conversion to any existing module type.