11import { createWriteStream } from 'node:fs'
22import { cp , readFile , rm } from 'node:fs/promises'
3- import { join , resolve } from 'node:path'
3+ import { dirname , join , resolve } from 'node:path'
4+ import { fileURLToPath } from 'node:url'
45import { Readable } from 'stream'
56import { finished } from 'stream/promises'
67
@@ -11,6 +12,8 @@ import glob from 'fast-glob'
1112const OUT_DIR = 'dist'
1213await rm ( OUT_DIR , { force : true , recursive : true } )
1314
15+ const repoDirectory = dirname ( resolve ( fileURLToPath ( import . meta. url ) , '..' ) )
16+
1417const entryPointsESM = await glob ( 'src/**/*.ts' , { ignore : [ '**/*.test.ts' ] } )
1518const entryPointsCJS = await glob ( 'src/**/*.cts' )
1619
@@ -39,7 +42,7 @@ async function bundle(entryPoints, format, watch) {
3942 name : 'mark-runtime-modules-as-external' ,
4043 setup ( pluginBuild ) {
4144 pluginBuild . onResolve ( { filter : / ^ \. .* \. c ? j s $ / } , ( args ) => {
42- if ( args . importer . includes ( join ( 'opennextjs-netlify' , 'src' ) ) ) {
45+ if ( args . importer . includes ( join ( repoDirectory , 'src' ) ) ) {
4346 return { path : args . path , external : true }
4447 }
4548 } )
0 commit comments