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

no way to prevent interpret from transpiling the config, even if another tool has been configured #3195

Closed
hedgepigdaniel opened this issue Apr 7, 2022 · 2 comments · Fixed by #3329
Labels

Comments

@hedgepigdaniel
Copy link

It's nice that interpret is used to allow configuration to be written in ES/TS/etc without configuration. However, it is not always desired that a loader hook is automatically registered, and sometimes it can cause a bug.

I think it should be configurable, just as --config-register can be used to register additional hooks, it should be possible to turn off the use of interpret.

What is the current behavior?

When using a configuration with one of the matched filetypes, for example webpack.config.ts, node-interpret registers a loader (e.g. ts-node to be used to transpile the configuration. There is no way to prevent this behaviour except uninstalling the loader (for example uninstalling ts-node. But this is virtually impossible in a larger project - since usually something else will depend on ts-node and cause it to be installed.

To Reproduce

Steps to reproduce the behavior:

  1. Configure webpack using a configuration webpack.config.ts, including using Typescript syntax and types.
  2. Install ts-node in the project
  3. Install tsm in the project, because you want to use esbuild to transpile your scripts and webpack configuration, not ts-node.
  4. run the compilation with node -r tsm $(yarn bin webpack)

There will be type errors, because the following happens:

  1. tsm is registered as a require hook for ts files
  2. ts-node is additionally registered as a require hook for ts files, which I didn't ask for and don't want
  3. The webpack configuration is correctly transpiled to JS by tsm/esbuild
  4. ts-node is incorrectly used to transpile the configuration, but at this point it has already been transpiled. By default, there will be type errors and the compilation will fail. As suggested in Cannot use custom type definitions in webpack.config.ts webpack#13844 (comment), you can work around this by configuring ts-node to skip type checking, but it should not have been used in the first place!

Expected behavior

It should be possible to turn off the use of interpret, so that it does not conflict with the user's intended strategy for transpiling scripts and configuration.

@alexander-akait
Copy link
Member

PR welcome, should not be hard

@alexander-akait
Copy link
Member

Done #3329

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants