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

Incorrectly compiles require() inside constructor call #339

Closed
twiss opened this issue Aug 20, 2020 · 0 comments · Fixed by #340
Closed

Incorrectly compiles require() inside constructor call #339

twiss opened this issue Aug 20, 2020 · 0 comments · Fixed by #340

Comments

@twiss
Copy link

twiss commented Aug 20, 2020

$ echo "new (require('node-localstorage').LocalStorage)('')" | node
$ echo "new (require('node-localstorage').LocalStorage)('')" | npx esbuild --bundle --platform=node | node
[stdin]:1244
new require_LocalStorage().LocalStorage("");
^

TypeError: require_LocalStorage is not a constructor
    at [stdin]:1244:1
    at Script.runInThisContext (vm.js:116:20)
    at Object.runInThisContext (vm.js:306:38)
    at Object.<anonymous> ([stdin]-wrapper:9:26)
    at Module._compile (internal/modules/cjs/loader.js:959:30)
    at evalScript (internal/process/execution.js:80:25)
    at internal/main/eval_stdin.js:29:5
    at Socket.<anonymous> (internal/process/execution.js:192:5)
    at Socket.emit (events.js:215:7)
    at endReadableNT (_stream_readable.js:1184:12)

This should instead output:

new (require_LocalStorage()).LocalStorage("");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant