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

swcpack: Fully-Specified ESM Import Specifier Fails #3043

Closed
karlhorky opened this issue Dec 14, 2021 · 2 comments · Fixed by #3050
Closed

swcpack: Fully-Specified ESM Import Specifier Fails #3043

karlhorky opened this issue Dec 14, 2021 · 2 comments · Fixed by #3050
Labels
Milestone

Comments

@karlhorky
Copy link

karlhorky commented Dec 14, 2021

Describe the bug

Similar to this webpack bug, swcpack aka spack doesn't match the behavior and semantics of TypeScript when importing using a fully-specified path with a .js extension.

Eg. the following fails:

// index.ts
import { two } from './two.js';
// two.ts
export function two() {}

But does not fail when building with TSC.

Full repo with failing build script: https://github.com/karlhorky/swcpack-esm-fully-specified-demo

Input code

No response

Config

No response

Playground link

No response

Expected behavior

swcpack should match the semantics of TSC and TypeScript, and allow for fully-specified import paths with .js extensions for ESM.

See @RyanCavanaugh's comment here: microsoft/TypeScript#41887 (comment)

TypeScript doesn't modify JavaScript code you write, the import path you write should be the one you want to appear in the output .js file

Version

@swc/cli@0.1.55, @swc/core@1.2.120

Additional context

No response

@karlhorky
Copy link
Author

Wow, that was a super fast fix, thanks @magic-akari and @kdy1 !! 🙌 🚀

@swc-bot
Copy link
Collaborator

swc-bot commented Oct 20, 2022

This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@swc-project swc-project locked as resolved and limited conversation to collaborators Oct 20, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Development

Successfully merging a pull request may close this issue.

3 participants