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

dynamicImport option doesn't work with CJS export TypeScript #8914

Closed
aramissennyeydd opened this issue May 5, 2024 · 2 comments
Closed
Assignees
Labels
Milestone

Comments

@aramissennyeydd
Copy link

aramissennyeydd commented May 5, 2024

Describe the bug

I'm working to allow Backstage to use ESM modules using dynamic imports as part of our migration path away from CJS, backstage/backstage#22638. We're using Rollup for production builds and SWC locally. I'm unable to get SWC to keep dynamic imports in our output.

Input code

console.log(import('./test.mjs'));

Config

{
    filename,
    sourceMaps: 'inline',
    module: { type: 'commonjs' },
    jsc: {
        target: 'es2022',
        parser: {
          syntax: 'typescript',
          dynamicImport: true,
        },
      },
}

Playground link (or link to the minimal reproduction)

https://play.swc.rs/?version=1.4.13&code=H4sIAAAAAAAAA9NILK7MS1bQ0LS1q%2BZSUEjOzysuUShJBRK2ConliZklCpm5BflFJRrqmXnZ6prWKGqMMBTp6YPE9XKzikFqazUBQDmEwl8AAAA%3D&config=H4sIAAAAAAAAA2WPPQ7DMAiF954iYu5QZewNOvQQlkMiR8G2gEi1oty9dn7cVt3gffAeLJemgVEs3Jsll7mJhgW59lmR5NW8sgKaIoplFxWuJ1UpqDeTYNW65A05%2B6AYWDNVnnFj6z4CanjAQgClvbXtYQdTCIK%2FdkDOuz59H2QDRUaRv1wyfpjq%2Fp54OVKBQjdv8Hi0PFMuyG4U%2FCjwmTwTqzs4eZ7r2zPrG1secAA5AQAA

edit: updated to one with dynamicImport set - the behavior is the same.

SWC Info output

No response

Expected behavior

The import statement is preserved

Actual behavior

console.log(Promise.resolve().then(()=>/*#__PURE__*/ _interop_require_wildcard(require("./test.mjs"))));

Version

@swc/core: 1.4.8

Additional context

No response

@kdy1 kdy1 added this to the Planned milestone May 6, 2024
@kdy1 kdy1 self-assigned this May 6, 2024
@kdy1
Copy link
Member

kdy1 commented May 7, 2024

Oh it was documented. https://swc.rs/docs/configuration/modules#ignoredynamic

@kdy1 kdy1 closed this as not planned Won't fix, can't repro, duplicate, stale May 7, 2024
@kdy1 kdy1 modified the milestones: Planned, v1.5.5 May 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

2 participants