Skip to content

Proposal: cake command should support ES6 modules #5451

Open
@johndeighan

Description

@johndeighan

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

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