@@ -5,15 +5,17 @@ import path from "node:path";
55const args = process . argv . slice ( 2 ) ;
66const tsc = process . env . CI || args . includes ( "--tsc" ) ;
77
8+ // pnpm workspaces do not understand Deno projects and vice versa so we need a way to specify which projects need their node_modules updating
9+ const denoNodeModulesPaths = args
10+ . find ( ( arg ) => arg . includes ( "--deno-node-modules-paths=" ) )
11+ ?. split ( "=" ) [ 1 ]
12+ . split ( "," ) ;
13+ console . log ( "denoNodeModulesPaths" , denoNodeModulesPaths ) ;
14+
815const ROOT_DIR = process . cwd ( ) ;
916const PACKAGES_PATH = path . join ( ROOT_DIR , "packages" ) ;
1017const DEFAULT_BUILD_PATH = path . join ( ROOT_DIR , "build" ) ;
1118
12- // pnpm workspaces do not understand Deno projects and vice versa so we need to specify which projects need their node_modules updating
13- const DENO_NODE_MODULES_PATHS = [
14- path . join ( ROOT_DIR , "integration/helpers/vite-deno-template/node_modules" ) ,
15- ] ;
16-
1719let activeOutputDir = DEFAULT_BUILD_PATH ;
1820if ( process . env . LOCAL_BUILD_DIRECTORY ) {
1921 let appDir = path . resolve ( process . env . LOCAL_BUILD_DIRECTORY ) ;
@@ -64,25 +66,27 @@ async function copyBuildToDist() {
6466 let copyQueue = [ ] ;
6567 for ( let pkg of packages ) {
6668 try {
67- // Copy entire build artifact to node_modules dir for each Deno project that requires it
68- for ( let denoNodeModulesPath of DENO_NODE_MODULES_PATHS ) {
69- let destPath = path . join ( denoNodeModulesPath , pkg . nodeModulesPath ) ;
70- if ( await fse . pathExists ( destPath ) ) {
71- copyQueue . push (
72- ( async ( ) => {
73- console . log (
74- chalk . yellow (
75- ` 🛠 🦕 Copying ${ path . relative (
76- ROOT_DIR ,
77- pkg . build
78- ) } to ${ path . relative ( ROOT_DIR , destPath ) } `
79- )
80- ) ;
81- fse . copy ( pkg . build , destPath , {
82- recursive : true ,
83- } ) ;
84- } ) ( )
85- ) ;
69+ if ( denoNodeModulesPaths ) {
70+ // Copy entire build artifact to node_modules dir for each Deno project that requires it
71+ for ( let denoNodeModulesPath of denoNodeModulesPaths ) {
72+ let destPath = path . join ( denoNodeModulesPath , pkg . nodeModulesPath ) ;
73+ if ( await fse . pathExists ( destPath ) ) {
74+ copyQueue . push (
75+ ( async ( ) => {
76+ console . log (
77+ chalk . yellow (
78+ ` 🛠 🦕 Copying ${ path . relative (
79+ ROOT_DIR ,
80+ pkg . build
81+ ) } to ${ path . relative ( ROOT_DIR , destPath ) } `
82+ )
83+ ) ;
84+ fse . copy ( pkg . build , destPath , {
85+ recursive : true ,
86+ } ) ;
87+ } ) ( )
88+ ) ;
89+ }
8690 }
8791 }
8892
0 commit comments