1- import path from "node:path" ;
2- import fse from "fs-extra" ;
31import chalk from "chalk" ;
2+ import fse from "fs-extra" ;
3+ import path from "node:path" ;
44
55const args = process . argv . slice ( 2 ) ;
66const tsc = process . env . CI || args . includes ( "--tsc" ) ;
@@ -9,6 +9,11 @@ const ROOT_DIR = process.cwd();
99const PACKAGES_PATH = path . join ( ROOT_DIR , "packages" ) ;
1010const DEFAULT_BUILD_PATH = path . join ( ROOT_DIR , "build" ) ;
1111
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+
1217let activeOutputDir = DEFAULT_BUILD_PATH ;
1318if ( process . env . LOCAL_BUILD_DIRECTORY ) {
1419 let appDir = path . resolve ( process . env . LOCAL_BUILD_DIRECTORY ) ;
@@ -38,6 +43,8 @@ async function copyBuildToDist() {
3843 PACKAGES_PATH ,
3944 parentDir === "@remix-run" ? `remix-${ dirName } ` : dirName
4045 ) ,
46+ nodeModulesPath :
47+ parentDir === "@remix-run" ? `${ parentDir } /${ dirName } ` : dirName ,
4148 } ;
4249 } ) ;
4350
@@ -57,6 +64,28 @@ async function copyBuildToDist() {
5764 let copyQueue = [ ] ;
5865 for ( let pkg of packages ) {
5966 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+ ) ;
86+ }
87+ }
88+
6089 let srcPath = path . join ( pkg . build , "dist" ) ;
6190 let destPath = path . join ( pkg . src , "dist" ) ;
6291 if ( ! ( await fse . stat ( srcPath ) ) . isDirectory ( ) ) {
0 commit comments