mirror of
https://github.com/withastro/astro.git
synced 2025-03-10 23:01:26 -05:00
Fix @astrojs/markdown-remark
bundling for non-node runtimes (#9736)
This commit is contained in:
parent
8d2e5db096
commit
53c69dcc82
2 changed files with 7 additions and 1 deletions
5
.changeset/lemon-carrots-cheer.md
Normal file
5
.changeset/lemon-carrots-cheer.md
Normal file
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
"@astrojs/markdown-remark": patch
|
||||
---
|
||||
|
||||
Initializes internal `cwdUrlStr` variable lazily for performance, and workaround Rollup side-effect detection bug when building for non-Node runtimes
|
|
@ -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;
|
||||
|
|
Loading…
Add table
Reference in a new issue