-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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
module,src: add --experimental-entry-url
flag
#49975
Conversation
Review requested:
|
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.
Is there a reason to reject relative URLs without leading ./
?
path. The URL must either start with `./` (e.g. `./entry.js`) or be absolute | ||
(e.g. `file:///home/user/entry.js`). Bare specifier (e.g. `entry.js`) won't | ||
work. |
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.
This part sounds a bit vague: does "won't work" mean throwing an error, or being interpreted as relative URL? Can relative URL start with ../
? Would relative URL starting from /
, ?
, #
, %2E/
, etc. throw as well?
assert.strictEqual(signal, null); | ||
}); | ||
|
||
it('should reject loading relative URLs without trailing `./`', async () => { |
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('should reject loading relative URLs without trailing `./`', async () => { | |
it('should reject loading relative URLs without leading `./`', async () => { |
execPath, | ||
[ | ||
'--experimental-entry-url', | ||
'./printA.js?key=value', |
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.
Doesn't have to be in this PR, but we'll need to test search
and hash
being passed correctly and not stripped by fileURLToPath()
anywhere.
I think that |
@@ -617,6 +617,20 @@ files with no extension will be treated as WebAssembly if they begin with the | |||
WebAssembly magic number (`\0asm`); otherwise they will be treated as ES module | |||
JavaScript. | |||
|
|||
### `--experimental-entry-url` |
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.
I think we can call the flag --entry-url
, with a printed experimental warning and the docs listing it as experimental. This isn’t a very risky feature that we need the experimental
part in the flag name.
} catch { | ||
// Ignore exception | ||
} catch (err) { | ||
if (isMain && !shouldBeTreatedAsRelativeOrAbsolutePath(specifier)) { throw err; } |
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.
Can you please add a comment explaining this?
This has stalled. |
👋 I implemented this with some slight differences, addressing comments, at #54933 |
Co-Authored-By: Antoine du Hamel <[email protected]> PR-URL: #54933 Refs: #49975 Reviewed-By: James M Snell <[email protected]> Reviewed-By: LiviaMedeiros <[email protected]> Reviewed-By: Stephen Belanger <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Antoine du Hamel <[email protected]>
Co-Authored-By: Antoine du Hamel <[email protected]> PR-URL: #54933 Refs: #49975 Reviewed-By: James M Snell <[email protected]> Reviewed-By: LiviaMedeiros <[email protected]> Reviewed-By: Stephen Belanger <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Antoine du Hamel <[email protected]>
Co-Authored-By: Antoine du Hamel <[email protected]> PR-URL: #54933 Refs: #49975 Reviewed-By: James M Snell <[email protected]> Reviewed-By: LiviaMedeiros <[email protected]> Reviewed-By: Stephen Belanger <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Antoine du Hamel <[email protected]>
Co-Authored-By: Antoine du Hamel <[email protected]> PR-URL: nodejs#54933 Refs: nodejs#49975 Reviewed-By: James M Snell <[email protected]> Reviewed-By: LiviaMedeiros <[email protected]> Reviewed-By: Stephen Belanger <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Antoine du Hamel <[email protected]>
Co-Authored-By: Antoine du Hamel <[email protected]> PR-URL: nodejs#54933 Refs: nodejs#49975 Reviewed-By: James M Snell <[email protected]> Reviewed-By: LiviaMedeiros <[email protected]> Reviewed-By: Stephen Belanger <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Antoine du Hamel <[email protected]>
--experimental-entry-url
is a new boolean flag that causes the entry point string to be parsed as a URL and loaded by the ESM loader:node --experimental-entry-url --enable-source-maps ./entry.js?foo=bar
Refs: #49432 (comment)