@@ -249,7 +249,7 @@ don't want to create a separate file for that purpose, you can pass a `data:`
249
249
URL to ` --import` :
250
250
251
251
` ` ` bash
252
- node -- import ' data:text/javascript,import { register } from "node:module"; register("http-to-https", import.meta.url );' ./my-app.js
252
+ node -- import ' data:text/javascript,import { register } from "node:module"; import { pathToFileURL } from "node:url"; register("http-to-https", pathToFileURL("./").href );' ./my-app.js
253
253
` ` `
254
254
255
255
### Chaining
@@ -803,7 +803,7 @@ console.log(VERSION);
803
803
` ` `
804
804
805
805
With the preceding hooks module , running
806
- ` node --import 'data:text/javascript,import { register } from "node:module"; register("./https-hooks.mjs", import.meta.url );' ./main.mjs`
806
+ ` node --import 'data:text/javascript,import { register } from "node:module"; import { pathToFileURL } from "node:url"; register(pathToFileURL( "./https-hooks.mjs").href );' ./main.mjs`
807
807
prints the current version of CoffeeScript per the module at the URL in
808
808
` main.mjs` .
809
809
@@ -895,7 +895,7 @@ export scream = (str) -> str.toUpperCase()
895
895
` ` `
896
896
897
897
With the preceding hooks module, running
898
- ` node -- import ' data:text/javascript,import { register } from "node:module"; register("./coffeescript-hooks.mjs", import.meta.url );' main.coffee`
898
+ ` node -- import ' data:text/javascript,import { register } from "node:module"; import { pathToFileURL } from "node:url"; register(pathToFileURL( "./coffeescript-hooks.mjs").href );' ./ main.coffee`
899
899
causes ` main.coffee` to be turned into JavaScript after its source code is
900
900
loaded from disk but before Node.js executes it; and so on for any ` .coffee` ,
901
901
` .litcoffee` or ` .coffee.md` files referenced via ` import` statements of any
@@ -909,7 +909,7 @@ which specifiers to override to other URLs (this is a very simplistic
909
909
implementation of a small subset of the "import maps" specification).
910
910
911
911
` ` ` mjs
912
- // import-map-loader .js
912
+ // import-map-hooks .js
913
913
import fs from ' node:fs/promises' ;
914
914
915
915
const { imports } = JSON .parse (await fs .readFile (' import-map.json' ));
@@ -944,7 +944,7 @@ import 'a-module';
944
944
console .log (' some module!' );
945
945
` ` `
946
946
947
- Running ` node -- import ' data:text/javascript,import { register } from "node:module"; register("./import-map-loader .js", import.meta.url );' ./import-map-loader.js main.js`
947
+ Running ` node -- import ' data:text/javascript,import { register } from "node:module"; import { pathToFileURL } from "node:url"; register(pathToFileURL( "./import-map-hooks .js").href );' ./import-map-loader.js main.js`
948
948
should print ` some module!` .
949
949
950
950
## Source map v3 support
0 commit comments