1
1
import { createWriteStream } from 'node:fs'
2
2
import { 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'
4
5
import { Readable } from 'stream'
5
6
import { finished } from 'stream/promises'
6
7
@@ -11,6 +12,8 @@ import glob from 'fast-glob'
11
12
const OUT_DIR = 'dist'
12
13
await rm ( OUT_DIR , { force : true , recursive : true } )
13
14
15
+ const repoDirectory = dirname ( resolve ( fileURLToPath ( import . meta. url ) , '..' ) )
16
+
14
17
const entryPointsESM = await glob ( 'src/**/*.ts' , { ignore : [ '**/*.test.ts' ] } )
15
18
const entryPointsCJS = await glob ( 'src/**/*.cts' )
16
19
@@ -39,7 +42,7 @@ async function bundle(entryPoints, format, watch) {
39
42
name : 'mark-runtime-modules-as-external' ,
40
43
setup ( pluginBuild ) {
41
44
pluginBuild . onResolve ( { filter : / ^ \. .* \. c ? j s $ / } , ( args ) => {
42
- if ( args . importer . includes ( join ( 'opennextjs-netlify' , 'src' ) ) ) {
45
+ if ( args . importer . includes ( join ( repoDirectory , 'src' ) ) ) {
43
46
return { path : args . path , external : true }
44
47
}
45
48
} )
0 commit comments