Skip to content

Commit e82de9c

Browse files
Named exports for Node ESM for coffeescript package (#5376)
1 parent f5073fa commit e82de9c

File tree

2 files changed

+50
-0
lines changed

2 files changed

+50
-0
lines changed

lib/coffeescript/index.js

+31
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/index.coffee

+19
Original file line numberDiff line numberDiff line change
@@ -137,3 +137,22 @@ CoffeeScript._compileFile = (filename, options = {}) ->
137137
CoffeeScript._compileRawFileContent raw, filename, options
138138

139139
module.exports = CoffeeScript
140+
141+
# Explicitly define all named exports so that Node’s automatic detection of
142+
# named exports from CommonJS packages finds all of them. This enables consuming
143+
# packages to write code like `import { compile } from 'coffeescript'`.
144+
# Don’t simplify this into a loop or similar; the `module.exports.name` part is
145+
# essential for Node’s algorithm to successfully detect the name.
146+
module.exports.VERSION = CoffeeScript.VERSION
147+
module.exports.FILE_EXTENSIONS = CoffeeScript.FILE_EXTENSIONS
148+
module.exports.helpers = CoffeeScript.helpers
149+
module.exports.registerCompiled = CoffeeScript.registerCompiled
150+
module.exports.compile = CoffeeScript.compile
151+
module.exports.tokens = CoffeeScript.tokens
152+
module.exports.nodes = CoffeeScript.nodes
153+
module.exports.register = CoffeeScript.register
154+
module.exports.eval = CoffeeScript.eval
155+
module.exports.run = CoffeeScript.run
156+
module.exports.transpile = CoffeeScript.transpile
157+
module.exports._compileRawFileContent = CoffeeScript._compileRawFileContent
158+
module.exports._compileFile = CoffeeScript._compileFile

0 commit comments

Comments
 (0)