fix(vite): account for query params in module ids (#3257)
This commit is contained in:
@@ -10,6 +10,7 @@ import * as path from "@std/path";
|
||||
import * as babel from "@babel/core";
|
||||
import babelReact from "@babel/preset-react";
|
||||
import { httpAbsolute } from "./patches/http_absolute.ts";
|
||||
import { JS_REG } from "../utils.ts";
|
||||
|
||||
interface DenoState {
|
||||
type: RequestedModuleType;
|
||||
@@ -180,7 +181,7 @@ export function deno(): Plugin {
|
||||
// Skip for non-js files like `.css`
|
||||
if (
|
||||
meta.type === RequestedModuleType.Default &&
|
||||
!/\.([tj]sx?|[mc]?[tj]s)$/.test(id)
|
||||
!JS_REG.test(id)
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import { jsxComments } from "./patches/jsx_comment.ts";
|
||||
import babelReact from "@babel/preset-react";
|
||||
import { inlineEnvVarsPlugin } from "./patches/inline_env_vars.ts";
|
||||
import { removePolyfills } from "./patches/remove_polyfills.ts";
|
||||
import { JS_REG, JSX_REG } from "../utils.ts";
|
||||
|
||||
export function patches(): Plugin {
|
||||
let isDev = false;
|
||||
@@ -18,10 +19,10 @@ export function patches(): Plugin {
|
||||
return true;
|
||||
},
|
||||
transform(code, id, options) {
|
||||
if (!/\.([tj]sx?|[mc][tj]s)$/.test(id)) return;
|
||||
if (!JS_REG.test(id)) return;
|
||||
|
||||
const presets = [];
|
||||
if (!options?.ssr && /\.(tsx?|m[jt]s)$/.test(id)) {
|
||||
if (!options?.ssr && JSX_REG.test(id)) {
|
||||
presets.push([babelReact, {
|
||||
runtime: "automatic",
|
||||
importSource: "preact",
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
import * as path from "@std/path";
|
||||
import type { FsRouteFileNoMod, UniqueNamer } from "fresh/internal-dev";
|
||||
|
||||
export const JS_REG = /\.([tj]sx?|[mc]?[tj]s)(\?.*)?$/;
|
||||
export const JSX_REG = /\.[tj]sx?(\?.*)?$/;
|
||||
|
||||
export function pathWithRoot(fileOrDir: string, root?: string): string {
|
||||
if (path.isAbsolute(fileOrDir)) return fileOrDir;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user