Skip to content
Open
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
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
pull_request:
branches: [main]
jobs:
format:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
Expand Down
15 changes: 3 additions & 12 deletions esbuild.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const { mkdir, readFile } = require('fs/promises')
const { dirname } = require('path')
const { resolveTsConfig } = require('./lib/typescript')
const { defu } = require('defu')
const { transform, build: esbuildBuilder } = require('esbuild')
const { simpleOmit } = require('./lib/omit')

exports = module.exports = esbuildPlugin
Expand Down Expand Up @@ -58,14 +59,11 @@ function esbuildPlugin(options = defaultOptions) {
['loader', 'jsx']
)

const jsCode = await esbuild.transform(sourceCode, {
const jsCode = await transform(sourceCode, {
loader: 'tsx',
platform: 'node',
target: 'node16',
jsx: 'preserve',
tsconfigRaw: {
...userTsConfigRaw,
},
...esbuildTransformOptions,
})

Expand All @@ -89,18 +87,11 @@ function esbuildPlugin(options = defaultOptions) {
if (paths.client) {
await mkdir(dirname(paths.client), { recursive: true })
writeFileSync(paths.client, code.client, 'utf8')
await esbuild.build({
await esbuildBuilder({
entryPoints: [paths.client],
bundle: true,
allowOverwrite: true,
outfile: paths.client,
tsconfig: userTsConfig,
tsconfigRaw: {
...userTsConfigRaw,
...(await resolveTsConfig(
options.client && options.client.tsconfig
)),
},
platform: 'browser',
jsx: 'automatic',
jsxImportSource: 'preact',
Expand Down
16 changes: 4 additions & 12 deletions lib/types.d.ts
Original file line number Diff line number Diff line change
@@ -1,25 +1,17 @@
import type { TransformOptions } from 'esbuild'
import type { CompilerOptions, TypeAcquisition } from 'typescript'

export interface TSConfig {
compilerOptions?: CompilerOptions
exclude?: string[]
compileOnSave?: boolean
extends?: string
files?: string[]
include?: string[]
typeAcquisition?: TypeAcquisition
}

export interface Options {
rootDir: string
baseURL: string
atomic?: boolean
hash?: boolean
tsconfig: string | TSConfig
/**@deprecated client will be built based on your default `tsconfig.json` path*/
tsconfig: string
client: {
replaceParentNode: boolean
tsconfig?: string | TSConfig
/**@deprecated client will be built based on your default `tsconfig.json` path*/
tsconfig: string
output: string
}
}
Expand Down
16 changes: 1 addition & 15 deletions playground/rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
const { nodeResolve } = require('@rollup/plugin-node-resolve')
const { babel } = require('@rollup/plugin-babel')
const preactPlugin = require('@barelyhuman/preact-island-plugins/rollup')
const { DEFAULT_EXTENSIONS } = require('@babel/core')
const typescript = require('@rollup/plugin-typescript').default

/**
Expand All @@ -16,20 +13,9 @@ module.exports = {
plugins: [
typescript({
compilerOptions: {
jsx: 'react-jsx',
jsxImportSource: 'preact',
jsx: 'preserve',
},
}),
preactPlugin(),
babel({
plugins: [
[
'@babel/plugin-transform-react-jsx',
{ runtime: 'automatic', importSource: 'preact' },
],
],
babelHelpers: 'bundled',
extensions: [...DEFAULT_EXTENSIONS, '.ts', '.tsx'],
}),
],
}
Loading