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

Add node-12-esm, node-14-esm and node-16-esm to bases #76

Closed
orta opened this issue Oct 2, 2021 · 14 comments
Closed

Add node-12-esm, node-14-esm and node-16-esm to bases #76

orta opened this issue Oct 2, 2021 · 14 comments

Comments

@orta
Copy link
Member

orta commented Oct 2, 2021

No description provided.

@cspotcode
Copy link

Are these to use module: node12 or module: esnext?

@orta
Copy link
Member Author

orta commented Oct 12, 2021

node12 for 12, esnext for the others I think

@cspotcode
Copy link

Does esnext allow dynamic imports in a CommonJS file? Or maybe we're getting nodenext and esnext mixed up?

As far as I know, node12 and nodenext are the only module options that allow mixing sync and async module loading in a CommonJS file:

import foo from 'foo'; // compiled to require()
const promise = import('bar'); // compiled to import()

@orta
Copy link
Member Author

orta commented Oct 12, 2021

Ah yeah, nodenext!

@boda-sh
Copy link
Contributor

boda-sh commented Nov 24, 2021

With TypeScript 4.5 and module: es2022 out, would you say this is a good node16-esm config to start with?

{
  "$schema": "https://json.schemastore.org/tsconfig",
  "display": "Node 16 ESM",

  "compilerOptions": {
    "module": "es2022",
    "moduleResolution": "node",
    "target": "es2021",
    "lib": ["es2021"],

    "strict": true,
    "esModuleInterop": true,
    "skipLibCheck": true,
    "forceConsistentCasingInFileNames": true
  }
}

@cspotcode
Copy link

@bodazhao Should these node*-esm configs use the forthcoming module: nodenext or module: node12? I thought that was the intent, perhaps @orta knows.

@boda-sh
Copy link
Contributor

boda-sh commented Jan 19, 2022

that has been delayed, see microsoft/TypeScript#46452

@frank-dspeed
Copy link

No sorry it is not delayed it is integrated and there is no save default stay with node as default is fine use node12 (cjs & es2015 modules aka __esModules = true)if you want to depend on import export filds of package.json files and finally use esnext the most complicated one which adds the same as node12 but out of esm context view.

@orta
Copy link
Member Author

orta commented Feb 14, 2022

Handled by #90 - at least for node 16

@mikemykhaylov
Copy link

@orta

node12 for 12, esnext for the others I think

With Typescript 4.7 introducing "module": "node16" and "nodenext", would it make sense to use the "node16" for Node 16 + ESM and derivative configs?

@frank-dspeed
Copy link

@mmykhaylov depends on the packages that the project consumes this sets if if moduleResolution is not configured diffrent also the moduleResolution so everything with a package.json and not propper exports fild will fail.

i added a node16 consumer folder as composit project for that case and stick with node as resolve algo for the legacy part my final target is ESNext but you could set it to node16 if you do nodejs only packaging and code.

@evantill
Copy link

@orta what's the meaning of label you can do this?

something like pr are welcomes ? or like do it in your tsconfig ?

@cspotcode
Copy link

cspotcode commented Apr 10, 2023 via email

@orta
Copy link
Member Author

orta commented Apr 10, 2023

Actually, this should be closed - we dont support merging tsconfigs now that they can have array extends - I guess you can use node16 and esm now?

@orta orta closed this as completed Apr 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants