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

fix: use async config loading if available #825

Merged
merged 4 commits into from Nov 8, 2020

Conversation

the-spyke
Copy link
Sponsor Contributor

Please Read the CONTRIBUTING Guidelines
In particular the portion on Commit Message Formatting

Please check if the PR fulfills these requirements

  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)

What kind of change does this PR introduce? (Bug fix, feature, docs update, ...)

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Other... Please describe:

What is the current behavior? (You can also link to an open issue here)

Fixes #824

What is the new behavior?

If @babel/core is >=7.8.0, then ESM config will be found and loaded asynchronously.

Does this PR introduce a breaking change?

  • Yes
  • No

If this PR contains a breaking change, please describe the following...

  • Impact:
  • Migration path for existing applications:
  • Github Issue(s) this is regarding:

Other information:

@the-spyke
Copy link
Sponsor Contributor Author

the-spyke commented Feb 27, 2020

I have no idea why sourcemaps test fails on Windows in my branch. Probably, some dependency in the newer Babel returns broken Windows paths.

src/index.js Outdated Show resolved Hide resolved
@JLHwung
Copy link
Contributor

JLHwung commented Feb 27, 2020

the AppVeyor CI error is not directly related to this change, but babel changed some path related behaviour from 7.2.0 to 7.8.0

@the-spyke
Copy link
Sponsor Contributor Author

@JLHwung C:/projects/babel-loader/test/fixtures/basic.js definitely looks wrong.

nicolo-ribaudo
nicolo-ribaudo previously approved these changes Feb 27, 2020
Copy link
Member

@nicolo-ribaudo nicolo-ribaudo left a comment

Choose a reason for hiding this comment

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

Thanks!
We can investigate that failure separately if needed.

@nicolo-ribaudo nicolo-ribaudo dismissed their stale review February 27, 2020 20:11

Approved too early 😅

@@ -127,3 +127,38 @@ test.cb(
});
},
);

test.cb("should load ESM config files", t => {
Copy link
Member

Choose a reason for hiding this comment

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

Can we differentiate this test based on process.version?

Copy link
Sponsor Contributor Author

Choose a reason for hiding this comment

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

I was thinking about it, but I don't know if Node team will backport ESM to 12 or even 10 in the future and this test begin to fail. But okay, I'll redo it with semver check of Node version. As I remember 13.3 was the first one without --experimental flag.

Copy link
Member

Choose a reason for hiding this comment

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

Let's only test in on 13.3 for now. If they'll backport it we can update the test.

Copy link
Sponsor Contributor Author

Choose a reason for hiding this comment

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

Done

@the-spyke
Copy link
Sponsor Contributor Author

So, I've tried to overcome ESM loading on Window. But even in case of using file urls according to Node it fails. This time because of request@1.12.0 even on Linux:

Module build failed (from ./lib/index.js):
   Error: Cannot find module 'file:///home/user/babel-loader/test/fixtures/babelrc.mjs' from '/home/user/babel-loader'
       at /home/user/babel-loader/node_modules/resolve/lib/async.js:97:35
       at processDirs (/home/user/babel-loader/node_modules/resolve/lib/async.js:244:39)
       at isdir (/home/user/babel-loader/node_modules/resolve/lib/async.js:251:32)
       at /home/user/babel-loader/node_modules/resolve/lib/async.js:23:69
       at FSReqCallback.oncomplete (fs.js:166:21)

@nicolo-ribaudo
Copy link
Member

nicolo-ribaudo commented Mar 1, 2020

The windows bug should be fixed by babel/babel#11193.
I'm taking a look at the resolve failure.

@the-spyke
Copy link
Sponsor Contributor Author

the-spyke commented Mar 1, 2020

@nicolo-ribaudo So, what do we do? Leave local path as it is now, rollback to pathToUrl and wait till it's fixed, or rollback and merge now?

@nicolo-ribaudo
Copy link
Member

Let's wait for now, I'll release a patch version when there Babel PR is fixed.

@nishantjr
Copy link

Can this be merged now?

@nicolo-ribaudo nicolo-ribaudo merged commit d8cff97 into babel:master Nov 8, 2020
@nicolo-ribaudo
Copy link
Member

Thanks!

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.

ESM configs can't load
4 participants