Skip to content

Add .js to relative import statements in es output at build time#2011

Merged
mfedderly merged 2 commits intomasterfrom
mf/fix-webpack-5-extensions
Jan 19, 2021
Merged

Add .js to relative import statements in es output at build time#2011
mfedderly merged 2 commits intomasterfrom
mf/fix-webpack-5-extensions

Conversation

@mfedderly
Copy link
Copy Markdown
Collaborator

In #1942 (comment) it was pointed out that Turf does not quite work in Webpack 5 without a workaround.

This change adds a build-time transform onto the dist/es output files that adds the .js extensions to all of the outputs.

I would have preferred to specify the .js extension directly in the imports in the source, but that was not working well with the way we use ts-node to run test and bench. I'm a little worried that this is a little fragile because it is a regular expression, but I'm hoping that this ages gracefully and prevents us from needing an entire codemod framework to do the same thing.

@mfedderly
Copy link
Copy Markdown
Collaborator Author

@lcrosetto FYSA

Copy link
Copy Markdown
Member

@rowanwins rowanwins left a comment

Choose a reason for hiding this comment

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

I set this up locally and it seems straight forward enough, a bit finickity that we have to do it but 🤷‍♂️ what can you do, maybe one day we'll be able to dispense with it.

@mfedderly mfedderly merged commit bec40ec into master Jan 19, 2021
@mfedderly mfedderly deleted the mf/fix-webpack-5-extensions branch January 19, 2021 19:31
@lcrosetto
Copy link
Copy Markdown

@lcrosetto FYSA

Thank you!

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 this pull request may close these issues.

3 participants