Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ESModule fix #318

Merged
merged 10 commits into from Nov 26, 2020
Merged

ESModule fix #318

merged 10 commits into from Nov 26, 2020

Conversation

josh-hemphill
Copy link
Contributor

@josh-hemphill josh-hemphill commented Nov 21, 2020

Fixes ESModule Error in #317

Changes proposed in this pull request:

  • Fixes code substitution so that only the global declaration is removed

@josh-hemphill
Copy link
Contributor Author

@ndrsn The ESModule doesn't work without this fix, I'd like to get it added.
I didn't test the ES Module bundle correctly in #317, would you happen to have any ideas about how to include tests for ES Modules? I couldn't find a way to add it without breaking the tests.

@ndrsn
Copy link
Collaborator

ndrsn commented Nov 24, 2020

@josh-hemphill apologies, work got a bit busy — I'll take a look at this tomorrow.

I do believe, however, that there must a better way to leave out a conditional than replacing the #NO_GLOBAL? Some kind of variable injection? I'll look into this tomorrow. Thanks for the heads-up!

@ndrsn
Copy link
Collaborator

ndrsn commented Nov 24, 2020

Can we use Rollup's environment values flag instead of the replace? For example (untested):

$ rollup -c --environment EXCLUDE_GLOBAL

and

const excludeGlobal = process && process.env && process.env.EXCLUDE_GLOBAL;

if (window && !window.canvasDatagrid && !window.require && !excludeGlobal) {
  window.canvasDatagrid = function (args) {
    return new Grid(args);
  };
}

rollup.config.js Outdated Show resolved Hide resolved
@ndrsn
Copy link
Collaborator

ndrsn commented Nov 25, 2020

I didn't test the ES Module bundle correctly in #317, would you happen to have any ideas about how to include tests for ES Modules? I couldn't find a way to add it without breaking the tests.

This is a good point: right now the tests are browser based (Karma), and support for ES modules in browsers isn't complete I believe.

Right now I'd say don't worry about it — if the current Rollup config works, it works. But what we could do is add another, NodeJS-based test runner, to test just the ES module. We need to clean/split up some of the tests any way, so I'll see if I can add this in with that.

@josh-hemphill
Copy link
Contributor Author

I did some manual tests in the browser with the ES Module to be safe, it all seems to be good.

@ndrsn ndrsn merged commit 44a673b into TonyGermaneri:master Nov 26, 2020
@ndrsn
Copy link
Collaborator

ndrsn commented Nov 26, 2020

Thanks, @josh-hemphill — I've merged this and the other changes and released it as v0.25.2.

ndrsn pushed a commit to ndrsn/canvas-datagrid that referenced this pull request Dec 10, 2020
* Added ESModule Distribution

* Fixed window property substitution

* fixed ESModule code substitution

* remove esFill

* fix indentation

* Removal of globals (use treeshaking)

* Fixed build option, added comment

* Replaced variable with string
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.

None yet

2 participants