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

Default loader logic completely ignores Loader API #3

Open
mbullington opened this issue Feb 7, 2022 · 1 comment
Open

Default loader logic completely ignores Loader API #3

mbullington opened this issue Feb 7, 2022 · 1 comment

Comments

@mbullington
Copy link
Contributor

Description

The bug comes from this line:

const loader = JS_EXTENSIONS.has(extension) ? 'jsx' : extension;

This completely ignores the https://esbuild.github.io/api/#loader API, for example in your ESBuild config if you were to do ".css": "text" this wouldn't work.

Solutions

Not sure how hard it would be, but ideally we'd check the Loader API options here.

An alternative approach would be to change the default filter so this plugin only runs on JS/JSX/TS/TSX files.

@g-otn
Copy link

g-otn commented Nov 24, 2023

I happened upon this problem when I tried using the plugin on my project which imports a .webp file:

✘ [ERROR] [plugin lodash] Invalid loader value: "webp"

    app/images/index.ts:1:34:
      1 │ export { default as MyImage } from './my_image.webp';

The workaround was to pass the filter option via lodashTransform() param:

lodashTransformer({
  filter: /\.(js|mjs|ts|tsx|mts)$/,
})

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

No branches or pull requests

2 participants