module,src: add --experimental-entry-url flag#49975
module,src: add --experimental-entry-url flag#49975aduh95 wants to merge 2 commits intonodejs:mainfrom
--experimental-entry-url flag#49975Conversation
|
Review requested:
|
LiviaMedeiros
left a comment
There was a problem hiding this comment.
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.
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.
| 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.
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 |
| WebAssembly magic number (`\0asm`); otherwise they will be treated as ES module | ||
| JavaScript. | ||
|
|
||
| ### `--experimental-entry-url` |
There was a problem hiding this comment.
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.
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 <duhamelantoine1995@gmail.com> PR-URL: #54933 Refs: #49975 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: LiviaMedeiros <livia@cirno.name> Reviewed-By: Stephen Belanger <admin@stephenbelanger.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Co-Authored-By: Antoine du Hamel <duhamelantoine1995@gmail.com> PR-URL: #54933 Refs: #49975 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: LiviaMedeiros <livia@cirno.name> Reviewed-By: Stephen Belanger <admin@stephenbelanger.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Co-Authored-By: Antoine du Hamel <duhamelantoine1995@gmail.com> PR-URL: #54933 Refs: #49975 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: LiviaMedeiros <livia@cirno.name> Reviewed-By: Stephen Belanger <admin@stephenbelanger.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Co-Authored-By: Antoine du Hamel <duhamelantoine1995@gmail.com> PR-URL: nodejs#54933 Refs: nodejs#49975 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: LiviaMedeiros <livia@cirno.name> Reviewed-By: Stephen Belanger <admin@stephenbelanger.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Co-Authored-By: Antoine du Hamel <duhamelantoine1995@gmail.com> PR-URL: nodejs#54933 Refs: nodejs#49975 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: LiviaMedeiros <livia@cirno.name> Reviewed-By: Stephen Belanger <admin@stephenbelanger.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
--experimental-entry-urlis 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=barRefs: #49432 (comment)