Skip to content
This repository has been archived by the owner on Feb 18, 2024. It is now read-only.

Consider case when 'core-js' is located in 'babel-polyfill' root #181

Merged
merged 8 commits into from
Apr 15, 2017
Merged

Consider case when 'core-js' is located in 'babel-polyfill' root #181

merged 8 commits into from
Apr 15, 2017

Conversation

constgen
Copy link
Contributor

This change fixes situation when there are more than one 'core-js' library versions in the project. In this case 'babel-polyfill' downloads its verison to '/node_modules/babel-polyfill/node_modules/core-js'. That means babel-preset-env can't correctly resolve paths to 'core-js' when process import 'babel-polyfill'. Babel will try to find it in '/node_modules/core-js' where the wrong version will be located.

There is a particular project example when build fails because of core-js@1.x.x in the root node_modules and core-js@2.x.x in the babel-polyfill
error
paths

This fix also expects that babel-polyfill structure is '/libs/index.js'. Hope it will not be changed.

@constgen constgen changed the title Consider case when 'core-js' is locatde in 'babel-polyfill' root Consider case when 'core-js' is located in 'babel-polyfill' root Apr 13, 2017
@codecov
Copy link

codecov bot commented Apr 13, 2017

Codecov Report

Merging #181 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #181   +/-   ##
=======================================
  Coverage   93.43%   93.43%           
=======================================
  Files          36       36           
  Lines         518      518           
=======================================
  Hits          484      484           
  Misses         34       34
Impacted Files Coverage Δ
packages/neutrino-preset-web/index.js 97.61% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 425f3ac...d3c856b. Read the comment docs.

Copy link
Member

@eliperelman eliperelman left a comment

Choose a reason for hiding this comment

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

Just a couple changes and I think we can ship this.

@@ -99,6 +99,10 @@ module.exports = (neutrino) => {
.chunkFilename('[id].[chunkhash].js')
.end()
.resolve
.alias
Copy link
Member

Choose a reason for hiding this comment

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

Indent this line 2 more spaces.

@@ -99,6 +99,10 @@ module.exports = (neutrino) => {
.chunkFilename('[id].[chunkhash].js')
.end()
.resolve
.alias
// TIP: make sure 2 version of "core-js" always match in package.json and babel-polyfill/package.json
Copy link
Member

Choose a reason for hiding this comment

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

  • We can remove the "TIP" word here
  • Capitalize "make" to "Make"
  • Replace "version" with "versions"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes. I thought what is the best here. "Make sure 2 versions of "core-js" always match in package.json and babel-polyfill/package.json" sounds like the next line of code do this. But it actually not. This comment should play a role of a reminder.

@@ -99,6 +99,10 @@ module.exports = (neutrino) => {
.chunkFilename('[id].[chunkhash].js')
.end()
.resolve
.alias
// TIP: make sure 2 version of "core-js" always match in package.json and babel-polyfill/package.json
.set('core-js', join(require.resolve('core-js'), '..'))
Copy link
Member

Choose a reason for hiding this comment

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

Instead of a join with .., let's use dirname from path:

const { join, dirname } = require('path');

// ...

.set('core-js', dirname(require.resolve('core-js')))

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agree. Should think of this from the very beginning.

@eliperelman eliperelman merged commit b7269df into neutrinojs:master Apr 15, 2017
@constgen constgen deleted the core-js branch April 15, 2017 22:27
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants