Skip to content

Add patchStackTrace export; test that all named exports are detected by Node #5411

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

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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/v2/annotated-source/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -485,6 +485,7 @@ <h1>index.coffee</h1>
module.<span class="hljs-built_in">exports</span>.<span class="hljs-built_in">eval</span> = CoffeeScript.<span class="hljs-built_in">eval</span>
module.<span class="hljs-built_in">exports</span>.run = CoffeeScript.run
module.<span class="hljs-built_in">exports</span>.transpile = CoffeeScript.transpile
module.<span class="hljs-built_in">exports</span>.patchStackTrace = CoffeeScript.patchStackTrace
module.<span class="hljs-built_in">exports</span>._compileRawFileContent = CoffeeScript._compileRawFileContent
module.<span class="hljs-built_in">exports</span>._compileFile = CoffeeScript._compileFile</pre></div></div>

Expand Down
30 changes: 30 additions & 0 deletions docs/v2/test.html
Original file line number Diff line number Diff line change
Expand Up @@ -31451,6 +31451,36 @@ <h2>Another heading</h2>
].join('\n')
ok new OptionParser(flags).help() is expected

</script>
<script type="text/x-coffeescript" class="test" id="package">
return if window? or testingBrowser?

{EventEmitter} = require 'events'
{join} = require 'path'
{cwd} = require 'process'
{pathToFileURL} = require 'url'


packageEntryPath = join cwd(), 'lib/coffeescript/index.js'
packageEntryUrl = pathToFileURL packageEntryPath


test "the coffeescript package exposes all members as named exports in Node", ->

requiredPackage = require packageEntryPath
requiredKeys = Object.keys requiredPackage

importedPackage = await import(packageEntryUrl)
importedKeys = new Set Object.keys(importedPackage)

# In `command.coffee`, CoffeeScript extends a `new EventEmitter`;
# we want to ignore these additional added keys.
eventEmitterKeys = new Set Object.getOwnPropertyNames(Object.getPrototypeOf(new EventEmitter))

for key in requiredKeys when not eventEmitterKeys.has(key)
# Use `eq` test so that missing keys have their names printed in the error message.
eq (if importedKeys.has(key) then key else undefined), key

</script>
<script type="text/x-coffeescript" class="test" id="parser">
# Parser
Expand Down
2 changes: 2 additions & 0 deletions lib/coffeescript/index.js

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

1 change: 1 addition & 0 deletions src/index.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -155,5 +155,6 @@ module.exports.register = CoffeeScript.register
module.exports.eval = CoffeeScript.eval
module.exports.run = CoffeeScript.run
module.exports.transpile = CoffeeScript.transpile
module.exports.patchStackTrace = CoffeeScript.patchStackTrace
module.exports._compileRawFileContent = CoffeeScript._compileRawFileContent
module.exports._compileFile = CoffeeScript._compileFile
27 changes: 27 additions & 0 deletions test/package.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
return if window? or testingBrowser?

{EventEmitter} = require 'events'
{join} = require 'path'
{cwd} = require 'process'
{pathToFileURL} = require 'url'


packageEntryPath = join cwd(), 'lib/coffeescript/index.js'
packageEntryUrl = pathToFileURL packageEntryPath


test "the coffeescript package exposes all members as named exports in Node", ->

requiredPackage = require packageEntryPath
requiredKeys = Object.keys requiredPackage

importedPackage = await import(packageEntryUrl)
importedKeys = new Set Object.keys(importedPackage)

# In `command.coffee`, CoffeeScript extends a `new EventEmitter`;
# we want to ignore these additional added keys.
eventEmitterKeys = new Set Object.getOwnPropertyNames(Object.getPrototypeOf(new EventEmitter))

for key in requiredKeys when not eventEmitterKeys.has(key)
# Use `eq` test so that missing keys have their names printed in the error message.
eq (if importedKeys.has(key) then key else undefined), key