File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ import * as path from "@std/path";
1010import * as babel from "@babel/core" ;
1111import babelReact from "@babel/preset-react" ;
1212import { httpAbsolute } from "./patches/http_absolute.ts" ;
13+ import { JS_REG } from "../utils.ts" ;
1314
1415interface DenoState {
1516 type : RequestedModuleType ;
@@ -180,7 +181,7 @@ export function deno(): Plugin {
180181 // Skip for non-js files like `.css`
181182 if (
182183 meta . type === RequestedModuleType . Default &&
183- ! / \. ( [ t j ] s x ? | [ m c ] ? [ t j ] s ) $ / . test ( id )
184+ ! JS_REG . test ( id )
184185 ) {
185186 return ;
186187 }
Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ import { jsxComments } from "./patches/jsx_comment.ts";
55import babelReact from "@babel/preset-react" ;
66import { inlineEnvVarsPlugin } from "./patches/inline_env_vars.ts" ;
77import { removePolyfills } from "./patches/remove_polyfills.ts" ;
8+ import { JS_REG , JSX_REG } from "../utils.ts" ;
89
910export function patches ( ) : Plugin {
1011 let isDev = false ;
@@ -18,10 +19,10 @@ export function patches(): Plugin {
1819 return true ;
1920 } ,
2021 transform ( code , id , options ) {
21- if ( ! / \. ( [ t j ] s x ? | [ m c ] [ t j ] s ) $ / . test ( id ) ) return ;
22+ if ( ! JS_REG . test ( id ) ) return ;
2223
2324 const presets = [ ] ;
24- if ( ! options ?. ssr && / \. ( t s x ? | m [ j t ] s ) $ / . test ( id ) ) {
25+ if ( ! options ?. ssr && JSX_REG . test ( id ) ) {
2526 presets . push ( [ babelReact , {
2627 runtime : "automatic" ,
2728 importSource : "preact" ,
Original file line number Diff line number Diff line change 11import * as path from "@std/path" ;
22import type { FsRouteFileNoMod , UniqueNamer } from "fresh/internal-dev" ;
33
4+ export const JS_REG = / \. ( [ t j ] s x ? | [ m c ] ? [ t j ] s ) ( \? .* ) ? $ / ;
5+ export const JSX_REG = / \. [ t j ] s x ? ( \? .* ) ? $ / ;
6+
47export function pathWithRoot ( fileOrDir : string , root ?: string ) : string {
58 if ( path . isAbsolute ( fileOrDir ) ) return fileOrDir ;
69
You can’t perform that action at this time.
0 commit comments