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

babel-loader@9.2.0 resulted in a runtime error, this.getLogger is not a function when using with thread-loader #1043

Closed
ijlee2 opened this issue Sep 16, 2024 · 11 comments · Fixed by webpack-contrib/thread-loader#216

Comments

@ijlee2
Copy link

ijlee2 commented Sep 16, 2024

BEFORE YOU SUBMIT please read the following:

Delete what isn't applicable below
I'm submitting a bug report

Please tell us about your environment:
Webpack Version: 5.94.0
Babel Core Version: 7.25.2
Babel Loader Version: 9.2.0

Current behavior:

The start and test commands for a fresh Ember app failed with a runtime error:

Module build failed (from ../../../../node_modules/.pnpm/thread-loader@3.0.4_webpack@5.94.0/node_modules/thread-loader/dist/cjs.js):
Thread Loader (Worker 0)
this.getLogger is not a function
    at PoolWorker.fromErrorObj (/node_modules/.pnpm/thread-loader@3.0.4_webpack@5.94.0/node_modules/thread-loader/dist/WorkerPool.js:346:12)
    at /node_modules/.pnpm/thread-loader@3.0.4_webpack@5.94.0/node_modules/thread-loader/dist/WorkerPool.js:219:29
    at mapSeries (/node_modules/.pnpm/neo-async@2.6.2/node_modules/neo-async/async.js:3625:14)
    at Object.loader (/node_modules/.pnpm/babel-loader@9.2.0_@babel+core@7.25.2_webpack@5.94.0/node_modules/babel-loader/lib/index.js:44:23)
    at Object.<anonymous> (/node_modules/.pnpm/babel-loader@9.2.0_@babel+core@7.25.2_webpack@5.94.0/node_modules/babel-loader/lib/index.js:39:12)

The Ember app indirectly uses @embroider/babel-loader-9, which depends on babel-loader>=9.0.0.

Expected/desired behavior:

The start and test commands run without an error.

  • If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem along with a gist/jsbin of your webpack configuration.
# Create a monorepo with `docs-app` (the Ember app in question)
npx create-v2-addon-repo@0.10.4 my-repo
cd my-repo
pnpm install

# Run `docs-app`
cd docs-app
pnpm start

# Test `docs-app`
pnpm test
  1. Verify that start and test commands run without error.
  2. Remove pnpm.overrides in the workspace root package.json, then run pnpm install to allow babel-loader@9.2.0 to be installed. Run the start and test commands again to see the error.
@ijlee2
Copy link
Author

ijlee2 commented Sep 16, 2024

I noticed that this.getLogger() is mentioned in https://github.com/babel/babel-loader/pull/1037/files#diff-bfe9874d239014961b1ae4e89875a6155667db834a410aaaa2ebe3cf89820556R56. I don't know how this could have affected @embroider/babel-loader-9.

@nicolo-ribaudo
Copy link
Member

Thanks for the report! I'm taking a look.

@adamsr123
Copy link

@nicolo-ribaudo it's also happening for 8.4.0

@JackHull
Copy link

Also experiencing this issue for ^8.0.4.

@anndro
Copy link

anndro commented Sep 16, 2024

Same issue on 8.4.0 as mentioned. Rollback to 8.3.0 fixed for now.

@JackHull
Copy link

Rollback to 8.0.4 worked for me too.

@nicolo-ribaudo
Copy link
Member

I published v8.4.1 and v9.2.1 with a workaround for this.

@ijlee2
Copy link
Author

ijlee2 commented Sep 16, 2024

@nicolo-ribaudo Thank you for your help. I confirmed that, with 9.2.1, I can run the start and test commands in a new project as well as an existing one.

@ijlee2 ijlee2 changed the title babel-loader@9.2.0 resulted in a runtime error babel-loader@9.2.0 resulted in a runtime error, this.getLogger is not a function Sep 16, 2024
@JLHwung
Copy link
Contributor

JLHwung commented Sep 16, 2024

I think this is a thread-loader issue, because it only provides a subset of methods available in webpack 5 loader context:

https://github.com/webpack-contrib/thread-loader/blob/b1affb4762aff199af109d4717f9ee7adf54a16a/src/index.js#L13-L75

I assumed the motivation here is to minimize the process communication overhead between the main and the worker, but it is better be fixed on the thread-loader side.

@JLHwung JLHwung changed the title babel-loader@9.2.0 resulted in a runtime error, this.getLogger is not a function babel-loader@9.2.0 resulted in a runtime error, this.getLogger is not a function when using with thread-loader Sep 16, 2024
@JLHwung
Copy link
Contributor

JLHwung commented Sep 16, 2024

Link to the thread-loader issue: webpack-contrib/thread-loader#185

@JLHwung
Copy link
Contributor

JLHwung commented Sep 19, 2024

Closing this issue as it has been fixed in thread-loader 4.0.4.

@JLHwung JLHwung closed this as completed Sep 19, 2024
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