test: npm plugins are found through import.meta.resolve; changeset for the Windows plugin index fix

This commit is contained in:
saberzero1 committed 2026-11-09 18:01:48 +01:00
1 parent 0f294f7139
commit 28581e8e54
2 files changed
+19

No files matched your search

+5
View File
@@ -0,0 +1,5 @@
---
"@jackyzha0/quartz": patch
---
On Windows, regenerating `.quartz/plugins/index.ts` (`npm run install-plugins`, which also runs before every `npm run build`) no longer skips npm plugins with "dist/index.d.ts could not be found", which left exports such as `ExternalPlugin.Explorer` undefined. The package's location was read from a `file:` URL's pathname (`/C:/…`), which is not a Windows path.
+14
View File
@@ -46,6 +46,20 @@ function fakeSite() {
}
describe("plugin index", () => {
// npm plugins are found through import.meta.resolve, which returns a file: URL. Its pathname
// is not a path on Windows (`/C:/…`), so every npm plugin was skipped there (#2616).
test("npm plugins are found through their package.json", () => {
const pluginsDir = fs.mkdtempSync(path.join(os.tmpdir(), "quartz-plugin-index-npm-"))
const entry = collectPluginExports({
pluginsDir,
npmPackages: ["@quartz-community/explorer"],
}).get("quartz-community__explorer")
assert.ok(entry, "@quartz-community/explorer was skipped")
assert.ok(entry.overridable.includes("Explorer"))
assert.strictEqual(entry.importPath, "@quartz-community/explorer")
fs.rmSync(pluginsDir, { recursive: true, force: true })
})
test("component constructors re-exported from a sub-module are wrapped (#2565)", () => {
const { root, pluginsDir } = fakeSite()
const entry = collectPluginExports({ pluginsDir }).get("my-widget")!