Skip to content

Commit

Permalink
chore: fix Windows build (#4358)
Browse files Browse the repository at this point in the history
Co-authored-by: Divyansh Singh <40380293+brc-dd@users.noreply.github.com>
  • Loading branch information
userquin and brc-dd authored Nov 12, 2024
1 parent d200f4e commit 5649071
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 22 deletions.
8 changes: 6 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,15 @@ concurrency:

jobs:
test:
runs-on: ubuntu-latest

strategy:
matrix:
os: [ubuntu-latest]
node_version: [18, 20, 22]
include:
- os: windows-latest
node_version: 22

runs-on: ${{ matrix.os }}

steps:
- name: Checkout
Expand Down
35 changes: 15 additions & 20 deletions rollup.config.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,17 @@
import * as fs from 'node:fs/promises'
import { builtinModules, createRequire } from 'node:module'
import { resolve } from 'node:path'
import { fileURLToPath } from 'node:url'
import { type RollupOptions, defineConfig } from 'rollup'
import { nodeResolve } from '@rollup/plugin-node-resolve'
import alias from '@rollup/plugin-alias'
import commonjs from '@rollup/plugin-commonjs'
import esbuild from 'rollup-plugin-esbuild'
import json from '@rollup/plugin-json'
import { nodeResolve } from '@rollup/plugin-node-resolve'
import replace from '@rollup/plugin-replace'
import alias from '@rollup/plugin-alias'
import { type RollupOptions, defineConfig } from 'rollup'
import dts from 'rollup-plugin-dts'
import esbuild from 'rollup-plugin-esbuild'
import { globSync } from 'tinyglobby'

const ROOT = fileURLToPath(import.meta.url)
const r = (p: string) => resolve(ROOT, '..', p)

const require = createRequire(import.meta.url)
const pkg = require(r('package.json'))
const pkg = require('./package.json')

const DEV = !!process.env.DEV
const PROD = !DEV
Expand Down Expand Up @@ -45,15 +40,15 @@ const plugins = [

const esmBuild: RollupOptions = {
input: [
r('src/node/index.ts'),
r('src/node/cli.ts'),
...globSync(r('src/node/worker_*.ts'))
'src/node/index.ts',
'src/node/cli.ts',
...globSync('src/node/worker_*.ts')
],
output: {
format: 'esm',
entryFileNames: `[name].js`,
chunkFileNames: 'chunk-[hash].js',
dir: r('dist/node'),
dir: 'dist/node',
sourcemap: DEV
},
external,
Expand All @@ -72,7 +67,7 @@ const typesExternal = [

const dtsNode = dts({
respectExternal: true,
tsconfig: r('src/node/tsconfig.json')
tsconfig: 'src/node/tsconfig.json'
})

const originalResolveId = dtsNode.resolveId
Expand All @@ -84,20 +79,20 @@ dtsNode.resolveId = async function (source, importer) {
}

const nodeTypes: RollupOptions = {
input: r('src/node/index.ts'),
input: 'src/node/index.ts',
output: {
format: 'esm',
file: r('dist/node/index.d.ts')
file: 'dist/node/index.d.ts'
},
external: typesExternal,
plugins: [dtsNode]
}

const clientTypes: RollupOptions = {
input: r('dist/client-types/index.d.ts'),
input: 'dist/client-types/index.d.ts',
output: {
format: 'esm',
file: r('dist/client/index.d.ts')
file: 'dist/client/index.d.ts'
},
external: typesExternal,
plugins: [
Expand All @@ -106,7 +101,7 @@ const clientTypes: RollupOptions = {
name: 'cleanup',
async closeBundle() {
if (PROD) {
await fs.rm(r('dist/client-types'), { recursive: true })
await fs.rm('dist/client-types', { recursive: true })
}
}
}
Expand Down

0 comments on commit 5649071

Please sign in to comment.