jashkenas / jashkenas/coffeescript
Proposal: cake command should support ES6 modules
- Dominant language
- CoffeeScript
- Stars
- 16.6k
- Forks
- 2k
- PR merge metrics
- No merged PRs in 30d
Description
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
```coffee
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
Contributor guide
Research direction
Trace the cake command's Cakefile loading path and how the project's package.json type setting is handled; first reproduce the import failure with the provided Cakefile example. Done means ES6 imports work in a Cakefile when the project is configured as a module, without breaking existing Cakefile behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- coffeescript, javascript, node.js
- Domain
- build-system, cli
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100