Skip to content

Conversation

@publicarray
Copy link

allows rollup and webpack to load the lib as a module by default

allows rollup and webpack to load the lib as a module by default
@donmccurdy
Copy link
Contributor

Hi @publicarray, thanks for the PR and your patience. :)

I'm not sure how to test this — would Rollup also require some special handling for the SCSS and HTML in dat.gui?

@backspaces
Copy link

@publicarray See #132 for a discussion on es6 modules. We understand the modules: index.js property in package.json can be a help for Rollup & Webpack.

Could you elaborate? What would we have to do to the dat.gui workflow to insure es6 module support?

@publicarray
Copy link
Author

The PR only makes it easier to add dot.gui as a module (when css and html are strings or imported/manipulated with plugins). Users of the lib don't need to know the file structure. So @backspaces is correct.

// before
import * as dat from '../node_modules/dat.gui/index'
// after
import * as dat from 'dat.gui'

@donmccurdy
Copy link
Contributor

Thanks, I'm happy to merge the PR, I'd just like to know how to test and verify that it works. Currently when I try something like this:

// index.js
import * as dat from 'dat.gui';
const gui = new dat.GUI();
gui.add({message: 'hello world'}, 'message');
gui.add({value: 0.5}, 'value', 0, 1);
// rollup.config.js
import resolve from 'rollup-plugin-node-resolve';
export default {
  input: 'index.js',
  output: {file: 'bundle.js', format: 'iife'},
  name: 'MyModule',
  plugins: [resolve()]
};

I get an error when running rollup -c from the HTML imported by dat.gui:

[!] Error: Unexpected token
../../Documents/Projects/dat.gui/src/dat/gui/saveDialogue.html (1:0)
1: <div id="dg-save" class="dg dialogue">
   ^
2:
3:   Here's the new load parameter for your <code>GUI</code>'s constructor:

This error seems to be the same whether I include "module": "index.js" or not.

@donmccurdy
Copy link
Contributor

With v0.7.0 there are both UMD and ES6 modules in package.json, let me know if you run into any issues with this. :)

@donmccurdy donmccurdy closed this Jan 21, 2018
@publicarray
Copy link
Author

publicarray commented Jan 22, 2018

Thanks, Looks good 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants