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

Expose @babel/eslint-parser/experimental-worker #13398

Merged
merged 2 commits into from Aug 3, 2021

Conversation

nicolo-ribaudo
Copy link
Member

@nicolo-ribaudo nicolo-ribaudo commented May 30, 2021

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

Exposing the worker implementation makes it possible for our users to start testing it (and to start using mjs config files) before that we make it the default.

It was initially implemented in #13199 behind the BABEL_8_BREAKING flag. This PR reorganizes the implementation so that it can live side-by-side with the sync one.

@nicolo-ribaudo nicolo-ribaudo added PR: New Feature 🚀 A type of pull request used for our changelog categories area: eslint labels May 30, 2021
MAYBE_PARSE_SYNC: "MAYBE_PARSE_SYNC",
};

class Client {
Copy link
Member Author

Choose a reason for hiding this comment

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

I reorganized this file so that it can both run Babel using worker_threads or in the same thread. The Client class is the "public interface", while the WorkerClient and LocalClient provide the communication implementation.

@codesandbox-ci
Copy link

codesandbox-ci bot commented May 30, 2021

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit ed21d0b:

Sandbox Source
babel-repl-custom-plugin Configuration
babel-plugin-multi-config Configuration

@babel-bot
Copy link
Collaborator

babel-bot commented May 30, 2021

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

@nicolo-ribaudo
Copy link
Member Author

CI is failing because of #13399

@JLHwung
Copy link
Contributor

JLHwung commented Jun 22, 2021

The CI error seems related.

@nicolo-ribaudo nicolo-ribaudo force-pushed the eslint-worker-babel-7 branch 3 times, most recently from 928f6bd to b6a3f83 Compare June 23, 2021 01:14
@@ -164,12 +164,13 @@ function writeHelpers(runtimeName, { corejs } = {}) {
// - Node.js <13.2.0 will fail resolving the first array entry, and will
// fallback to the second entry (the CJS file)
// In Babel 8 we can simplify this.
helperSubExports[`./${helperPath}`] = [
helperSubExports[`./${path.posix.join("helpers", helperName)}`] = [
Copy link
Member Author

Choose a reason for hiding this comment

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

Otherwise it was using mixed / and \.

@nicolo-ribaudo nicolo-ribaudo added this to the v7.15.0 milestone Jul 1, 2021
? it.skip
: it;

babel7node12("experimental worker works with babel.config.mjs", () => {
Copy link
Member

Choose a reason for hiding this comment

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

nice simple test!

Copy link
Contributor

@JLHwung JLHwung left a comment

Choose a reason for hiding this comment

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

LGTM with small nits. Awesome work!

static #worker_threads_cache;
static get #worker_threads() {
return (WorkerClient.#worker_threads_cache ??= require("worker_threads"));
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Q: What's the intention of private static getter? Doesn't static #worker_threads = require("worker_threads") work here?

Copy link
Member Author

Choose a reason for hiding this comment

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

This file is always executed, but require("worker_threads") is only necessary when actually using the experimental implementation.

static #handleMessage;

constructor() {
LocalClient.#handleMessage ??= require("./worker/handle-message.cjs");
Copy link
Contributor

Choose a reason for hiding this comment

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

ditto.

@JLHwung JLHwung added the PR: Ready to be Merged A pull request with already two approvals, but waiting for the next minor release label Aug 3, 2021
@nicolo-ribaudo nicolo-ribaudo merged commit 885e1e0 into babel:main Aug 3, 2021
@nicolo-ribaudo nicolo-ribaudo deleted the eslint-worker-babel-7 branch August 3, 2021 21:23
@github-actions github-actions bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label Nov 3, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 3, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: eslint outdated A closed issue/PR that is archived due to age. Recommended to make a new issue PR: New Feature 🚀 A type of pull request used for our changelog categories PR: Ready to be Merged A pull request with already two approvals, but waiting for the next minor release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: @babel/eslint-parser doesn't work with an ESM babel config file
4 participants