-
-
Notifications
You must be signed in to change notification settings - Fork 402
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: svelte 4 module resolution (#650)
* fix: get svelte4 working * fix: svelte 4 module resolution
- Loading branch information
Showing
11 changed files
with
89 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// These are hack resolvers to get over some module resolution issues, with a PR to fix them upstream. | ||
|
||
import { dirname, join } from "path" | ||
|
||
import type { ResolverProps, ResolverResult } from "./shared" | ||
|
||
// Last resort resolver for weird packages: | ||
export async function handleHacks({ | ||
specifier, | ||
dependency | ||
}: ResolverProps): Promise<ResolverResult> { | ||
switch (specifier) { | ||
case "svelte/internal/disclose-version": { | ||
// https://github.com/sveltejs/svelte/pull/8874 | ||
const sveltePjPath = require.resolve("svelte/package.json", { | ||
paths: [dependency.resolveFrom] | ||
}) | ||
|
||
return { | ||
filePath: join( | ||
dirname(sveltePjPath), | ||
"src", | ||
"runtime", | ||
"internal", | ||
"disclose-version", | ||
"index.js" | ||
) | ||
} | ||
} | ||
|
||
default: | ||
return null | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,16 @@ | ||
import { Resolver } from "@parcel/plugin" | ||
|
||
import { handleHacks } from "./handle-hacks" | ||
import { handleModuleExport } from "./handle-module-exports" | ||
import { handleTsPath } from "./handle-ts-path" | ||
|
||
export default new Resolver({ | ||
async resolve(props) { | ||
return ( | ||
(await handleTsPath(props)) || (await handleModuleExport(props)) || null | ||
(await handleTsPath(props)) || | ||
(await handleModuleExport(props)) || | ||
(await handleHacks(props)) || | ||
null | ||
) | ||
} | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule examples
updated
3 files
+1 −1 | with-svelte/package.json | |
+0 −7 | with-svelte/svelte.config.js | |
+15 −0 | with-svelte/svelte.config.mjs |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.