Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: fix Windows build #4358

Merged
merged 2 commits into from
Nov 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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