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

Auto Bundles were not working in AMD Environment #263

Merged
merged 3 commits into from
Mar 7, 2017

Conversation

azizhk
Copy link
Contributor

@azizhk azizhk commented Feb 25, 2017

This was because of this code:

typeof define === 'function' && define.amd ? define(factory) :
(global.ES6Promise = factory());

ES6Promise would not be defined on global and we would get an error saying, "Cannot read property polyfill of undefined".
Though there are multiple workarounds, I thought this would be the best way to fix this.

I would have preferred to export nothing, just call the polyfill function, which would make it inline in the minified version, but that would break semver.
Also I would love to change the module name from ES6Promise to es6-promise, to keep it the same in NPM and on the browser. (But that would make it window['es6-promise'] for non AMD 😢 )
Also this is my first time with Broccoli.js. So please correct me if I'm doing something wrong.
Also I did not commit all of the dist files. Let me know if I should not commit them.

@stefanpenner
Copy link
Owner

@azizhk thanks for digging into this. Do you think we should just always install the ES6Promise global even in AMD environments? I suspect the lack of this may be causing #257 as well, as causing this issue.

What do you think?

@azizhk
Copy link
Contributor Author

azizhk commented Mar 2, 2017

Do you think we should just always install the ES6Promise global even in AMD environments?

If you mean we should just set window.ES6Promise then no, we should not.
If you mean we should polyfill it then yes. He is requesting for the auto version.

@stefanpenner
Copy link
Owner

If you mean we should just set window.ES6Promise then no, we should not.

👍

If you mean we should polyfill it then yes. He is requesting for the auto version.

Good catch.

@stefanpenner
Copy link
Owner

I'm trying to replicate the above test failure locally, but without much luck...

@azizhk
Copy link
Contributor Author

azizhk commented Mar 2, 2017

Same here. I was pretty sure they were working when I opened my PR. Damn.

@stefanpenner
Copy link
Owner

stefanpenner commented Mar 2, 2017

I'm rebuilding master on travis, lets see if its node 4 also fails. If so, then maybe its some transitive?


I really wish I could replicate locally...

@stefanpenner
Copy link
Owner

stefanpenner commented Mar 2, 2017

Ya, it failed again. I really wish it was easily replicatable.

I am at work right now, I'll have to take deeper look later...

Brocfile.js Outdated
return new Rollup(es5, {
rollup: {
entry: 'lib/' + entry,
cache: 'BUILD:es6-promise',
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does naming it do?

Copy link
Contributor Author

@azizhk azizhk Mar 2, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have two rollups with almost every file repeated so to reuse the same cache (of file reads, AST etc.) for both of them.
https://github.com/rollup/rollup/wiki/JavaScript-API#cache

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok I'm not doing it correctly.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://github.com/chadhietala/broccoli-rollup/blob/master/src/index.js
Ok just saw this plugin automatically does it for me. I was surprised why was I getting good speeds, the plugin was overriding the cache variable for me. 😜

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

chadhietala/broccoli-rollup@5aaf8f3
That was added by you. I feel like such an idiot.

Copy link
Owner

@stefanpenner stefanpenner Mar 2, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@azizhk haha no worries, I thought maybe you found some better caching strategy hidden deep inside rollup itself (you got my hopes up :trollface: ).

@stefanpenner
Copy link
Owner

stefanpenner commented Mar 7, 2017

Im really not sure whats up. I have tested this thoroughly locally in node 4 (the failing test) without any issues.. Going to merge this.

@stefanpenner stefanpenner merged commit 3df3f7d into stefanpenner:master Mar 7, 2017
@stefanpenner
Copy link
Owner

moving node 4 to allowed failures for now: #272

Will test node 4 locally to confirm until we resolved the node 4 issue.

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