1
1
import { existsSync } from "node:fs" ;
2
2
import { access , constants , copyFile , readFile , writeFile } from "node:fs/promises" ;
3
3
import { basename , dirname , join } from "node:path" ;
4
+ import { fileURLToPath } from "node:url" ;
4
5
import type { Config , Style } from "./config.js" ;
5
6
import { mergeStyle } from "./config.js" ;
6
7
import { Loader } from "./dataloader.js" ;
@@ -14,7 +15,12 @@ import {Telemetry} from "./telemetry.js";
14
15
import { faint } from "./tty.js" ;
15
16
import { resolvePath } from "./url.js" ;
16
17
17
- const EXTRA_FILES = new Map ( [ [ "node_modules/@observablehq/runtime/dist/runtime.js" , "_observablehq/runtime.js" ] ] ) ;
18
+ const EXTRA_FILES = new Map ( [
19
+ [
20
+ join ( fileURLToPath ( import . meta. resolve ( "@observablehq/runtime" ) ) , "../../dist/runtime.js" ) ,
21
+ "_observablehq/runtime.js"
22
+ ]
23
+ ] ) ;
18
24
19
25
// TODO Remove library helpers (e.g., duckdb) when they are published to npm.
20
26
function clientBundles ( clientPath : string ) : [ entry : string , name : string ] [ ] {
@@ -156,8 +162,7 @@ export async function build(
156
162
await effects . writeFile ( outputPath , contents ) ;
157
163
}
158
164
159
- // Copy over required distribution files from node_modules.
160
- // TODO: Note that this requires that the build command be run relative to the node_modules directory.
165
+ // Copy over required distribution files.
161
166
if ( addPublic ) {
162
167
for ( const [ sourcePath , outputPath ] of EXTRA_FILES ) {
163
168
effects . output . write ( `${ faint ( "copy" ) } ${ sourcePath } ${ faint ( "→" ) } ` ) ;
0 commit comments