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

Missing file extensions for multi-line imports #16

Closed
manzt opened this issue Dec 8, 2021 · 1 comment · Fixed by #17
Closed

Missing file extensions for multi-line imports #16

manzt opened this issue Dec 8, 2021 · 1 comment · Fixed by #17

Comments

@manzt
Copy link
Contributor

manzt commented Dec 8, 2021

Thank you for your work on this project. It is (nearly) perfect for my use case. I'm authoring a pure ESM library in typescript, so the addition of file extensions to imports is very very nice.

However, I've seemed to find a bug... If import statements are over multiple lines, the file extensions does not seem to be resolved in the output (making the ESM dist incompatible with Node and the browser).

Example

// src/index.ts
import { a } from './a';
import {
  b
} from './b';
export { a, b }
$ mkdist
// dist/index.mjs
import { a } from './a.mjs';
import { 
  b
} from './b'; // <- .mjs missing, breaks ESM
export { a, b }

This is the commit where I changed imports and things started working correctly: manzt/zarrita.js@bd6706a (#29)

@manzt
Copy link
Contributor Author

manzt commented Dec 9, 2021

It appears this comes from the regex in make.ts:

/(import|export)(.* from ['"])(.*)(['"])/g,

https://regex101.com/r/bLBOuI/1

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.

1 participant