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

Named exports for Node ESM for coffeescript package #5376

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
31 changes: 31 additions & 0 deletions lib/coffeescript/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions src/index.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -137,3 +137,22 @@ CoffeeScript._compileFile = (filename, options = {}) ->
CoffeeScript._compileRawFileContent raw, filename, options

module.exports = CoffeeScript

# Explicitly define all named exports so that Node’s automatic detection of
# named exports from CommonJS packages finds all of them. This enables consuming
# packages to write code like `import { compile } from 'coffeescript'`.
# Don’t simplify this into a loop or similar; the `module.exports.name` part is
# essential for Node’s algorithm to successfully detect the name.
module.exports.VERSION = CoffeeScript.VERSION
module.exports.FILE_EXTENSIONS = CoffeeScript.FILE_EXTENSIONS
module.exports.helpers = CoffeeScript.helpers
module.exports.registerCompiled = CoffeeScript.registerCompiled
module.exports.compile = CoffeeScript.compile
module.exports.tokens = CoffeeScript.tokens
module.exports.nodes = CoffeeScript.nodes
module.exports.register = CoffeeScript.register
module.exports.eval = CoffeeScript.eval
module.exports.run = CoffeeScript.run
module.exports.transpile = CoffeeScript.transpile
module.exports._compileRawFileContent = CoffeeScript._compileRawFileContent
module.exports._compileFile = CoffeeScript._compileFile