Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Feature]: support dynamic import by default #27

@hardfist

Description

@hardfist

when I use tsm register to transpile module which contains dynamic import, it's broken

  • src/index.ts
async function main(){
  const mod = await import('./lib');
}
main();
  • src/lib.ts
export const answer = 42;

It's broken
image

It's because esbuild will keep dynamic import for high version of node, even you set format=cjs evanw/esbuild#1636
image

when I set target to node12, it works fine now, because it will transform dynamic import to require

  • tsm.js
module.exports = {
  common: {
   target: 'node12'
  }
}

so I think we could set target=node12 by default to support dynamic import by default

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions