Skip to content

Commit

Permalink
Tone done refactors
Browse files Browse the repository at this point in the history
  • Loading branch information
bluwy committed Sep 2, 2022
1 parent f9fb5b3 commit 4c0b581
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
4 changes: 2 additions & 2 deletions packages/astro/src/core/build/vite-plugin-analyzer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export function vitePluginAnalyzer(internals: BuildInternals): VitePlugin {
const astro = info.meta.astro as AstroPluginMetadata['astro'];

for (const c of astro.hydratedComponents) {
const rid = c.resolvedPath ?? c.specifier;
const rid = c.resolvedPath ? decodeURI(c.resolvedPath) : c.specifier;
internals.discoveredHydratedComponents.add(rid);
}

Expand All @@ -92,7 +92,7 @@ export function vitePluginAnalyzer(internals: BuildInternals): VitePlugin {
const clientOnlys: string[] = [];

for (const c of astro.clientOnlyComponents) {
const cid = c.resolvedPath ?? c.specifier;
const cid = c.resolvedPath ? decodeURI(c.resolvedPath) : c.specifier;
internals.discoveredClientOnlyComponents.add(cid);
clientOnlys.push(cid);
}
Expand Down
10 changes: 5 additions & 5 deletions packages/astro/src/jsx/babel.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { PluginObj } from '@babel/core';
import * as t from '@babel/types';
import { resolve } from 'node:path';
import { pathToFileURL } from 'node:url';
import { resolveClientDevPath } from '../core/render/dev/resolve.js';
import { HydrationDirectiveProps } from '../runtime/server/hydration.js';
import type { PluginMetadata } from '../vite-plugin-astro/types';
Expand Down Expand Up @@ -217,8 +217,8 @@ export default function astroJSX(): PluginObj {
if (meta) {
let resolvedPath: string;
if (meta.path.startsWith('.')) {
resolvedPath = resolve(meta.path, state.filename!);
resolvedPath = resolveClientDevPath(resolvedPath);
const fileURL = pathToFileURL(state.filename!);
resolvedPath = resolveClientDevPath(`/@fs${new URL(meta.path, fileURL).pathname}`);
} else {
resolvedPath = meta.path;
}
Expand Down Expand Up @@ -297,8 +297,8 @@ export default function astroJSX(): PluginObj {
}
let resolvedPath: string;
if (meta.path.startsWith('.')) {
resolvedPath = resolve(meta.path, state.filename!);
resolvedPath = resolveClientDevPath(resolvedPath);
const fileURL = pathToFileURL(state.filename!);
resolvedPath = resolveClientDevPath(`/@fs${new URL(meta.path, fileURL).pathname}`);
} else {
resolvedPath = meta.path;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ import RoundBracketCounter from '../components/with-(round-brackets)/Counter';
import SquareBracketCounter from '../components/with-[square-brackets]/Counter';
---
<html>
<head>
<meta charset="utf-8" />
</head>
<body>
<h1>Special chars in component import paths from an .astro file</h1>
<CaretCounter id="caret" client:visible />
Expand Down

0 comments on commit 4c0b581

Please sign in to comment.