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

ES6/import with JavaScript template? #8357

Closed
leviwolfe opened this issue Nov 4, 2021 · 1 comment
Closed

ES6/import with JavaScript template? #8357

leviwolfe opened this issue Nov 4, 2021 · 1 comment
Labels
kind/bug Some behavior is incorrect or out of spec resolution/duplicate This issue is a duplicate of another issue

Comments

@leviwolfe
Copy link

Hello!

  • Vote on this issue by adding a 馃憤 reaction
  • To contribute a fix for this issue, leave a comment (and link to your pull request, if you've opened one already)

Issue details

Is it possible to use ES6/import with JavaScript (not TypeScript)? I have a sample repo using the following steps: https://github.com/leviwolfe/import-pulumi

Steps to reproduce

  1. Create a skeleton using pulumi new javascript
  2. Change const pulumi = require("@pulumi/pulumi"); into import pulumi from "@pulumi/pulumi";
  3. Add "type": "module" to package.json

Expected: The pulumi preview command to display a preview.
Actual: The pulumi preview command displays the following error:

   error: Running program 'c:\code\import-pulumi' failed with an unhandled exception:
    Error [ERR_REQUIRE_ESM]: require() of ES Module c:\code\import-pulumi\index.js from c:\code\import-pulumi\node_modules\@pulumi\pulumi\cmd\run\run.js not supported.
    Instead change the require of index.js in c:\code\import-pulumi\node_modules\@pulumi\pulumi\cmd\run\run.js to a dynamic import() which is available in all CommonJS modules.
        at Object.<anonymous> (c:\code\import-pulumi\node_modules\@pulumi\pulumi\cmd\run\run.js:219:31)
        at Generator.next (<anonymous>)
        at c:\code\import-pulumi\node_modules\@pulumi\pulumi\cmd\run\run.js:21:71
        at new Promise (<anonymous>)
        at __awaiter (c:\code\import-pulumi\node_modules\@pulumi\pulumi\cmd\run\run.js:17:12)
        at Object.runProgram [as init] (c:\code\import-pulumi\node_modules\@pulumi\pulumi\cmd\run\run.js:205:30)
        at Stack.<anonymous> (c:\code\import-pulumi\node_modules\@pulumi\pulumi\runtime\stack.js:86:43)
        at Generator.next (<anonymous>)
        at fulfilled (c:\code\import-pulumi\node_modules\@pulumi\pulumi\runtime\stack.js:18:58)

@leviwolfe leviwolfe added the kind/bug Some behavior is incorrect or out of spec label Nov 4, 2021
@emiliza emiliza added the resolution/duplicate This issue is a duplicate of another issue label Nov 5, 2021
@emiliza
Copy link
Contributor

emiliza commented Nov 5, 2021

Hi @leviwolfe - unfortunately this isn't something supported today.

We've captured the greater request of ECMAScript support for js projects in #4130 - please take a moment to upvote and use this for tracking - thanks!

@emiliza emiliza closed this as completed Nov 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Some behavior is incorrect or out of spec resolution/duplicate This issue is a duplicate of another issue
Projects
None yet
Development

No branches or pull requests

2 participants