Skip to content

feat: add stable react-refresh transform #16

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

Merged
merged 1 commit into from
Nov 7, 2020
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
10 changes: 4 additions & 6 deletions tsc/compile.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import ts from 'https://esm.sh/typescript'
import reactRefreshTS from 'https://esm.sh/[email protected]'
import ts from 'https://esm.sh/[email protected]'
import transformImportPathRewrite from './transform-import-path-rewrite.ts'
import transformReactJsx from './transform-react-jsx.ts'
import transformReactRefresh from './transform-react-refresh.ts'
import transformReactUseDenoHook from './transform-react-use-deno-hook.ts'

export interface CompileOptions {
Expand All @@ -25,11 +25,9 @@ const allowTargets = [
export function compile(fileName: string, source: string, { mode, target: targetName, rewriteImportPath, reactRefresh, signUseDeno }: CompileOptions) {
const target = allowTargets.indexOf(targetName.toLowerCase())
const transformers: ts.CustomTransformers = { before: [], after: [] }
if (reactRefresh) transformers.before!.push(reactRefreshTS())
transformers.before!.push(createPlainTransformer(transformReactUseDenoHook, { index: 0, signUseDeno }))
transformers.before!.push(createPlainTransformer(transformReactJsx, { mode, rewriteImportPath }))
transformers.before!.push(createTransformer(transformReactUseDenoHook, signUseDeno))
if (reactRefresh) {
transformers.before!.push(createTransformer(transformReactRefresh))
}
transformers.after!.push(createPlainTransformer(transformImportPathRewrite, rewriteImportPath))

return ts.transpileModule(source, {
Expand Down
2 changes: 1 addition & 1 deletion tsc/transform-import-path-rewrite.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import ts from 'https://esm.sh/typescript'
import ts from 'https://esm.sh/typescript@4.0.5'

/**
* TS AST transformer to rewrite import path.
Expand Down
2 changes: 1 addition & 1 deletion tsc/transform-react-jsx.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import ts from 'https://esm.sh/typescript'
import ts from 'https://esm.sh/typescript@4.0.5'
import { path } from '../std.ts'

export default function transformReactJsx(sf: ts.SourceFile, node: ts.Node, options: { mode: 'development' | 'production', rewriteImportPath: (importPath: string) => string }): ts.VisitResult<ts.Node> {
Expand Down
358 changes: 0 additions & 358 deletions tsc/transform-react-refresh.ts

This file was deleted.

Loading