Skip to content

Can't use dynamic imports with swc #1508

@petercoulton

Description

@petercoulton

Search Terms

  • swc dynamic imports
  • swc 'regenerator-runtime'

Expected Behavior

Dynamic imports should continue to work after switching to the swc transpiler.

Actual Behavior

Throws Error: Cannot find module 'regenerator-runtime

Steps to reproduce the problem

const example = async () => {
    const other = await import('./other')
    console.log(other)
}

example().then(() => console.log(`done`))

See TypeStrong/ts-node-repros#20 for full example.

Minimal reproduction

TypeStrong/ts-node-repros#20

Specifications

  • ts-node version: v10.2.1
  • node version: v16.8.0
  • TypeScript version: 4.4.3
  • tsconfig.json, if you're using one:
{
  "extends": "ts-node/node16/tsconfig.json",

  "ts-node": {
    "transpileOnly": true,
    "transpiler": "ts-node/transpilers/swc-experimental"
  },

  "include": ["**/*.ts"],
  "exclude": ["node_modules"]
}

  • Operating system and version: macOS 11.6 Big Sur
  • If Windows, are you using WSL or WSL2?: no

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions