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

ERROR in only one instance of babel-polyfill is allowed @ ./~/bootstrap-loader/loader.js 1:0-44 #16

Closed
AllenFang opened this issue Jan 7, 2016 · 27 comments · Fixed by #29

Comments

@AllenFang
Copy link
Contributor

I upgrade bootstrap-loader according #13, and it work for [email protected] and earlier, but I got another problem for babel-polyfill is loaded repeatedly.

the error message is in the following:

ERROR in only one instance of babel-polyfill is allowed  @ ./~/bootstrap-loader/loader.js 1:0-44

The root cause is I wrote my dev webpack config with es6, and I add require('babel/register'); this line in my webpack-dev-server.js

Anyway, if re-write whole webpack config with es5 and it's work, so have any idea to solve it or did I miss something?

Thanks :)

@strawbrary
Copy link

I was about to create an issue for this but you beat me to it :) Are you using Babel 5 in your project? bootstrap-loader v1.0.3 includes the Babel 6 polyfill which will throw that error if your project is also pulling in the Babel 5 polyfill. You could try installing v1.0.1 of bootstrap-loader for now and see if that resolves it.

@AllenFang
Copy link
Contributor Author

yep, I'm trying to upgrade to babel 6, but there some troubles I need to solve ;( But to the user of babel 5, your solutions seems like a workaround for now

@strawbrary
Copy link

I'm in the same boat, still on Babel 5, which is why I was going to create an issue to see if they intended to support projects which haven't upgraded yet.

@AllenFang
Copy link
Contributor Author

👍

@alex35mil
Copy link
Member

@AllenFang @strawbrary
Hey guys, somehow I wasn't subscribed to this repo and missed issue, sorry. I'll take a look at this tomorrow. Guess I can check what version of babel is installed and require it.

@alex35mil
Copy link
Member

Also I'll check node version so babel-polyfill will be required only for node@<=0.12 users.

@AllenFang
Copy link
Contributor Author

@alexfedoseev, it's a bad news for this repo and thanks your helping. Anyway, is there any basic docs or getting started for contributing this repo, I thinks maybe I can do some bug fixing or something like that.

@justin808
Copy link
Member

@AllenFang I invited you to our slack room! Thanks so much for offering help!

@alex35mil
Copy link
Member

@AllenFang I added Contributing guide with short explanations how things work. Let me know if you want to hack on this issue.

My current plan is:

/* ./src/bootstrap.loader.js */

if (semver.lte(process.version, '0.12.x')) {
  const babelLatest = 'babel-polyfill';
  const babelPrev = 'babel/polyfill';

  const isBabelLatest = require.resolve(babelLatest);
  const isBabelPrev = require.resolve(babelPrev);

  if (!isBabelLatest && !isBabelPrev) {
    throw ...
  }

  if (isBabelLatest) {
    require(babelLatest);
  } else {
    require(babelPrev);
  }
}

// imports ...

@AllenFang
Copy link
Contributor Author

Thanks your helping, I'll spend some time to study and try my best to contribute this repo

@alex35mil
Copy link
Member

Thanks, @AllenFang!

@alex35mil
Copy link
Member

@AllenFang any updates on this? If you're currently busy, I can handle this issue.

@AllenFang
Copy link
Contributor Author

um.. little busy, i think you can patch this issue if you have free times. sorry

@alex35mil
Copy link
Member

@AllenFang Sure 👍

@genaro-picazo
Copy link

I am also having this issue when trying to use both bootstrap-loader and awesome-typescript-loader.

@alex35mil
Copy link
Member

@AllenFang @strawbrary @gpicazo 1.0.5 is published. Can you confirm that issue is solved?

@strawbrary
Copy link

@alexfedoseev It's working for me. Thanks!

@yourmediafriend
Copy link

@alexfedoseev I am using it with the react-starter-kit and was still showing an issue with regards to babel-polyfill

@justin808
Copy link
Member

@yourmediafriend What version of node are you using? Any help debugging your situation would be appreciated.

@gpicazo did the latest fix your issue?

@yourmediafriend
Copy link

@justin808 Turns out I was using an antique version of node. Upgraded to v5.4.1 and everything is working fine. Thanks for pointing me in the right direction.

@AllenFang
Copy link
Contributor Author

@alexfedoseev, finally, I've time to test this issues, but some problem still remain
I use babel 5 and I downgrade nodejs from 4.x to 0.12.0, because my project required.

Then I remove node_modules and install again and run my webpack dev command, but got the following message:

ERROR in Cannot find module 'babel-polyfill'
 @ ./~/bootstrap-loader/loader.js 1:0-44

There's a first problem:
For the user of babel@5, I think babel/polyfill is necessary instead of babel-polyfill

However, I just install [email protected] and run again, but got another issues

ERROR in only one instance of babel-polyfill is allowed
 @ ./~/bootstrap-loader/loader.js 1:0-44

It's the second problem
This problem is same as my first post in this thread, because I wrote my webpack with es6 and run following command to execute

node --harmony ./webpack/webpack-dev-server.js

so I need to add this require('babel/register'); at first line in webpack-dev-server.js for es6 compatibility. But this will cause a duplicate of babel instance.

@alex35mil
Copy link
Member

@AllenFang 1.0.6 is published. Please, try it out and close/comment on this issue.

@AllenFang
Copy link
Contributor Author

@alexfedoseev, ok, I will try it !

@AllenFang
Copy link
Contributor Author

@alexfedoseev, please check #29, I think this patch should solve this issues correctly

@justin808
Copy link
Member

@alexfedoseev Should we merge?
@AllenFang Can you confirm this does affect users of Node 5.5?

@alex35mil
Copy link
Member

@justin808 @AllenFang

Can you confirm this does affect users of Node 5.5?

This part shouldn't affect users >=4.0.0 users, b/c there's no need in polyfill there.
I'll release it later today.

@AllenFang
Copy link
Contributor Author

I've tested it on [email protected] and it's work fine

logankoester added a commit to logankoester/node-simple-schema that referenced this issue Sep 28, 2016
An error is thrown if a process attempts to load babel-polyfill more
than once:

`ERROR in only one instance of babel-polyfill is allowed`.

See shakacode/bootstrap-loader#16

Signed-off-by: Logan Koester <[email protected]>
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 a pull request may close this issue.

6 participants