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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consider using ESM by default in JavaScript and TypeScript templates #244

Open
lukehoban opened this issue Jan 17, 2022 · 3 comments
Open
Labels
kind/enhancement Improvements or new features

Comments

@lukehoban
Copy link
Member

lukehoban commented Jan 17, 2022

Hello!

  • Vote on this issue by adding a 馃憤 reaction
  • If you want to implement this feature, comment to let us know (we'll work with you on design, scheduling, etc.)

Issue details

We now (pulumi/pulumi#7764, pulumi/pulumi#8655) support the use of ECMAScript modules as Pulumi entrypoints. We support this natively in JavaScript and in pre-compiled TypeScript, and via some additional custom flags (using experimental Node.js loader features) for on-the-fly-compiler TypeScript.

This also enables the use of await at top level in Pulumi programs as in pulumi/pulumi#5161 (comment).

At some point, we may want our templates to make this the default for all new projects. I don't think we can do that yet for TypeScript because the features we depend on our experimental, and have in practice seen breaking changes, so this would risk exposing users to breaking changes in Node.js in the future. Given that, I'm inclined to also leave JavaScript templates as is for now, so that JavaScript and TypeScript are consistent by default.

Once these Node.js features are sufficiently stable though, we can revisit this.

@simenandre
Copy link
Contributor

Maybe we should create some of the basic templates with ESM? I was thinking about creating a guide, and it would be awesome if I could point to a template.

@vtereshyn
Copy link

I am trying to make it work with ESM configuration of my Pulumi project, but I am getting an error:

Error: Cannot find module './config.js'

Is there a way to not use module: "commonjs" that specified in Pulumi by default?

@jkodroff
Copy link
Member

jkodroff commented Apr 3, 2023

@lukehoban Is there a link to where we can track the upstream Node.js features?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/enhancement Improvements or new features
Projects
None yet
Development

No branches or pull requests

4 participants