-
-
Notifications
You must be signed in to change notification settings - Fork 34.1k
repl: display dynamic import version in error message. #48129
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
Changes from 1 commit
3bb9b4e
653dd2b
65aff1f
d2891e1
0752958
1837614
16ea5fc
b1b6a8a
3f08ac7
3b569cf
708665d
6e2f835
74df404
f259a5f
556fa83
f42f73c
a83915d
64842ac
c7c8488
00348c9
7d4b2c9
01daa46
d59d33d
91210be
4d61565
9a619e5
9ef0490
605c8cb
89e992c
1b0bb6c
b9903ba
e9fe193
c045901
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -818,7 +818,41 @@ const tcpTests = [ | |||||
| kArrow, | ||||||
| '', | ||||||
| 'Uncaught:', | ||||||
| /^SyntaxError: .* dynamic import/, | ||||||
| 'SyntaxError: Cannot use import statement inside the Node.js REPL, \ | ||||||
| alternatively use dynamic import: const comeOn = await import(\'fhqwhgads\');', | ||||||
| ] | ||||||
| }, | ||||||
| { | ||||||
| send: 'import { export1, export2 } from "module-name"', | ||||||
aduh95 marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
| expect: [ | ||||||
| kSource, | ||||||
| kArrow, | ||||||
| '', | ||||||
| 'Uncaught:', | ||||||
| 'SyntaxError: Cannot use import statement inside the Node.js REPL, \ | ||||||
| alternatively use dynamic import: const {export1,export2} = await import(\'module-name\');', | ||||||
| ] | ||||||
| }, | ||||||
| { | ||||||
| send: 'import * as name from "module-name";', | ||||||
| expect: [ | ||||||
| kSource, | ||||||
| kArrow, | ||||||
| '', | ||||||
| 'Uncaught:', | ||||||
| 'SyntaxError: Cannot use import statement inside the Node.js REPL, \ | ||||||
| alternatively use dynamic import: const name = await import(\'module-name\');', | ||||||
| ] | ||||||
| }, | ||||||
| { | ||||||
| send: 'import "module-name";', | ||||||
| expect: [ | ||||||
| kSource, | ||||||
| kArrow, | ||||||
| '', | ||||||
| 'Uncaught:', | ||||||
| 'SyntaxError: Cannot use import statement inside the Node.js REPL, \ | ||||||
| alternatively use dynamic import: const moduleName = await import(\'module-name\');', | ||||||
|
||||||
| alternatively use dynamic import: const moduleName = await import(\'module-name\');', | |
| alternatively use dynamic import: await import(\'module-name\');', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we just wanted this, we need no acron and likes? We could have just extracted the label after from and wrap it in an await import(...)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it depends, i think. if i static import with explicit bindings, or with * as, then those need to be used to set the result of await import().
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the error message if all that we need is await import(<module_name>) it can be a RE?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Due to the complexity of import statements and their grammar, I don't think anything short of a parser will be a reliable approach.
If using a parser isn't desirable, then I'm not sure why we'd even bother with more than a link to MDN's page on dynamic import, and they can figure it out for themselves.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the user wrote import 'module-name' in REPL, they meant await import("module-name"), not const moduleName = await import('module-name') (otherwise they would have written import * as moduleName from 'module-name')). Using Acorn is probably still more reliable, and more future proof.
Uh oh!
There was an error while loading. Please reload this page.