aboutsummaryrefslogtreecommitdiff
path: root/packages/markdown/remark/src
diff options
context:
space:
mode:
authorGravatar Bjorn Lu <bjornlu.dev@gmail.com> 2024-01-19 22:38:33 +0800
committerGravatar GitHub <noreply@github.com> 2024-01-19 22:38:33 +0800
commit53c69dcc82cdf4000aff13a6c11fffe19096cf45 (patch)
tree2af38402915734c9077cb08efdf83221372636cc /packages/markdown/remark/src
parent8d2e5db096f1e7b098511b4fe9357434a6ff0703 (diff)
downloadastro-53c69dcc82cdf4000aff13a6c11fffe19096cf45.tar.gz
astro-53c69dcc82cdf4000aff13a6c11fffe19096cf45.tar.zst
astro-53c69dcc82cdf4000aff13a6c11fffe19096cf45.zip
Fix `@astrojs/markdown-remark` bundling for non-node runtimes (#9736)
Diffstat (limited to 'packages/markdown/remark/src')
-rw-r--r--packages/markdown/remark/src/load-plugins.ts3
1 files changed, 2 insertions, 1 deletions
diff --git a/packages/markdown/remark/src/load-plugins.ts b/packages/markdown/remark/src/load-plugins.ts
index 8229ddff2..e1bad94a1 100644
--- a/packages/markdown/remark/src/load-plugins.ts
+++ b/packages/markdown/remark/src/load-plugins.ts
@@ -3,7 +3,7 @@ import path from 'node:path';
import { pathToFileURL } from 'node:url';
import type * as unified from 'unified';
-const cwdUrlStr = pathToFileURL(path.join(process.cwd(), 'package.json')).toString();
+let cwdUrlStr: string | undefined;
async function importPlugin(p: string | unified.Plugin): Promise<unified.Plugin> {
if (typeof p === 'string') {
@@ -14,6 +14,7 @@ async function importPlugin(p: string | unified.Plugin): Promise<unified.Plugin>
} catch {}
// Try import from user project
+ cwdUrlStr ??= pathToFileURL(path.join(process.cwd(), 'package.json')).toString();
const resolved = importMetaResolve(p, cwdUrlStr);
const importResult = await import(resolved);
return importResult.default;