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: normalize moduleName of absolute runtime #10242

Closed

Conversation

JLHwung
Copy link
Contributor

@JLHwung JLHwung commented Jul 19, 2019

Q                       A
Fixed Issues? Fixes #10209
Patch: Bug Fix? Yes
Major: Breaking Change?
Minor: New Feature?
Tests Added + Pass? Nope 😢
Documentation PR Link
Any Dependency Changes?
License MIT

The moduleName of resolved absolute runtime should be normalized, otherwise it will return
PATH\\TO\\MODULE on Windows 7, which is apparently incorrect.

I don't know how to add a unit test given that CI runs on Linux only.

@babel-bot
Copy link
Collaborator

babel-bot commented Jul 19, 2019

Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/11180/

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.

Would path.posix.dirname work instead?

I don't know how to add a unit test given that CI runs on Linux only.

It's ok; in the future we should use Travis CI to test Babel on windows maybe.

cc @sag1v
Could you try cloning this branch and checking if it works? Neither me nor @JLHwung have Windows to test it.

@nicolo-ribaudo nicolo-ribaudo added the PR: Bug Fix 🐛 A type of pull request used for our changelog categories label Jul 19, 2019
@JLHwung
Copy link
Contributor Author

JLHwung commented Jul 19, 2019

@sag1v Could you test on your machine to see if the test is now fixed on this branch?

git fetch origin refs/pull/10242/head
git checkout FETCH_HEAD
// build babel
make build
// now run the test
yarn jest transform-runtime

@sag1v
Copy link
Contributor

sag1v commented Jul 19, 2019

@JLHwung When i run git fetch origin refs/pull/10242/head
I get

fatal: Couldn't find remote ref refs/pull/10242/head

I think its because i'm on a fork and not the actual repo?

Edit
Aw, maybe i could just clone @JLHwung's fork and test it...

@JLHwung
Copy link
Contributor Author

JLHwung commented Jul 19, 2019

I think its because i'm on a fork and not the actual repo?

Oh I just assume everyone is cloning babel/babel, in this case you can add it as a new remote

git remote add upstream https://github.com/babel/babel
git fetch upstream refs/pull/10242/head

maybe i could just clone @JLHwung's fork and test it...

Surely you can. Note that git remote add would save your time on make bootstrap and yarn.

@sag1v
Copy link
Contributor

sag1v commented Jul 19, 2019

Thanks @JLHwung !

As for the tests, still failing.
When i run yarn jest transform-runtime i get 2 failing tests:

- var _classCallCheck = require("<CWD>/packages/babel-plugin-transform-runtime/node_modules/@babel/runtime/helpers/classCallCheck");
+ var _classCallCheck = require("./helpers/classCallCheck");
- var _classCallCheck = require("<CWD>/packages/babel-plugin-transform-runtime/node_modules/@babel/runtime/helpers/classCallCheck");
+ var _classCallCheck = require("./helpers/classCallCheck");

And when i run make test i get 13 faild tests:
Example:

- "fixtures/sourcemaps/call-identifiers/input.js",
+ "fixtures\\sourcemaps\\call-identifiers\\input.js",

@JLHwung
Copy link
Contributor Author

JLHwung commented Jul 21, 2019

When i run yarn jest transform-runtime i get 2 failing tests:

Interesting. It seems like I have replaced a bug with another one. I will investigate later.

- "fixtures/sourcemaps/call-identifiers/input.js", + "fixtures\\sourcemaps\\call-identifiers\\input.js",

This one is related to how sourcemap is generated.

@sag1v Thank you for posting test results. I guess I had better get a Windows environment running and go through these issues.

@JLHwung
Copy link
Contributor Author

JLHwung commented Jul 21, 2019

@nicolo-ribaudo My perspective on this PR has changed: Even if we may normalize the path separator in the import call, the transformed result injected with absolute path can only run on Windows -- we cannot get rid of the leading disk label anyway.

As Windows build of Node.js support both \ and / in module resolution. The transformed result is effectively working on Windows machine. Therefore I think we don't need fix this.

The test failure is expected, as the behavior of injecting absolute path runtime, is os-dependent.
If we agree, we should close this PR and mark it as won't fix.

@sag1v There are other issues, i.e. source maps that may need fix. The discussions above focus only on the absoluteRuntime of transform-runtime. We may track these issues on different thread.

@nicolo-ribaudo
Copy link
Member

I'm ok with closing it as "wontfix", but I'd really like to have an option to skip running a test on some platform. Something like this:

{
  "plugins": [ /* ... */ ],
  "os": ["Linux"]
}

Similar to minNodeVersion:

if (taskOpts.minNodeVersion) {

@JLHwung
Copy link
Contributor Author

JLHwung commented Jul 22, 2019

@nicolo-ribaudo Good idea. Let's discuss the os field design on #10252 . Closing this PR now as wontfix.

@JLHwung JLHwung closed this Jul 22, 2019
@lock lock bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label Oct 22, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Oct 22, 2019
@JLHwung JLHwung deleted the normalize-absolute-runtime-module-name branch December 15, 2020 15:42
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
outdated A closed issue/PR that is archived due to age. Recommended to make a new issue PR: Bug Fix 🐛 A type of pull request used for our changelog categories
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Failing tests on a windows machine due to path format
4 participants