Skip to content

Commit 796ba09

Browse files
committed
chore: don't hardcode repo directory in build script
1 parent 2397c8a commit 796ba09

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

tools/build.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { createWriteStream } from 'node:fs'
22
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'
45
import { Readable } from 'stream'
56
import { finished } from 'stream/promises'
67

@@ -11,6 +12,8 @@ import glob from 'fast-glob'
1112
const OUT_DIR = 'dist'
1213
await rm(OUT_DIR, { force: true, recursive: true })
1314

15+
const repoDirectory = dirname(resolve(fileURLToPath(import.meta.url), '..'))
16+
1417
const entryPointsESM = await glob('src/**/*.ts', { ignore: ['**/*.test.ts'] })
1518
const 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?js$/ }, (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

Comments
 (0)