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

extensions order using loaders option is not respected (workaround found) #384

Open
christophehurpeau opened this issue Dec 5, 2024 · 0 comments

Comments

@christophehurpeau
Copy link

christophehurpeau commented Dec 5, 2024

esbuild({
  loaders: { '.web.ts': 'ts', '.ts': 'ts' }
})

for const extensions = Object.keys(loaders); will result in :

[".js", ".jsx", ".ts", ".tsx", ".web.ts"]

because the loaders object is initialized which sets the properties order

const loaders = {
    ...defaultLoaders
  };

There is a workaround because properties can be configured twice, once with and once without . (key = key[0] === "." ? key : .${key};):

  loaders: { ts: false, '.web.ts': 'ts', '.ts': 'ts' }

ts: false deletes in the object, then '.ts': 'ts' adds it back at the end.

However I feel like it should be working properly as resolving filename with multiple possible extensions can be a common case ?

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

1 participant