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

Proposal: cake command should support ES6 modules #5451

Open
johndeighan opened this issue Aug 16, 2023 · 2 comments
Open

Proposal: cake command should support ES6 modules #5451

johndeighan opened this issue Aug 16, 2023 · 2 comments

Comments

@johndeighan
Copy link

Choose one: is this a bug report or feature request?
Let's call it a feature request, though I personally consider it a bug

Input Code

import fs from 'fs'

option '-o', '--output [DIR]', 'directory for compiled code'

task 'hello', 'print hello message', (options) ->
  console.log "Hello, Cakefile!"
  fs.writeFile "./hello.txt", "Hi, there"

Expected Behavior

Import should work

Current Behavior

Error message:
SyntaxError: Cannot use import statement outside a module

Possible Solution

Support ES6 modules in a Cakefile if the current project type is "module"

Context

I would prefer to not use require() anywhere in my code

Environment

Latest version of Windows 11

  • CoffeeScript version: 2.7.0
  • Node.js version: v20.3.1
@johndeighan
Copy link
Author

Tried using cake - got the error "Cannot use import statement outside a module". So, I went to GitHub to report this as a bug since my package.json files ALWAYS have "type": "module" in them. Come to find out that I'd already reported that as a bug way back last year. LOL.

@GeoffreyBooth
Copy link
Collaborator

If #5447 gets finished, it would resolve this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants