Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

regression: build fails with SK 2.0 and svelte-highlight >=7.4.3 #315

Closed
wbhob opened this issue Jan 4, 2024 · 5 comments · Fixed by #316
Closed

regression: build fails with SK 2.0 and svelte-highlight >=7.4.3 #315

wbhob opened this issue Jan 4, 2024 · 5 comments · Fixed by #316
Assignees

Comments

@wbhob
Copy link

wbhob commented Jan 4, 2024

When attempting to build my app using SvelteKit 2.0 and Vite 5.0, the following error occurs. The last version that builds successfully is 7.4.2.

[commonjs--resolver] Missing "./styles" specifier in "svelte-highlight" package
error during build:
Error: Missing "./styles" specifier in "svelte-highlight" package
    at e (file:///Users/wilson/GitHub/Lobby/ai-www-svelte/node_modules/.pnpm/[email protected]/node_modules/vite/dist/node/chunks/dep-R0I0XnyH.js:21914:25)
    at n (file:///Users/wilson/GitHub/Lobby/ai-www-svelte/node_modules/.pnpm/[email protected]/node_modules/vite/dist/node/chunks/dep-R0I0XnyH.js:21914:627)
    at o (file:///Users/wilson/GitHub/Lobby/ai-www-svelte/node_modules/.pnpm/[email protected]/node_modules/vite/dist/node/chunks/dep-R0I0XnyH.js:21914:1297)
    at resolveExportsOrImports (file:///Users/wilson/GitHub/Lobby/ai-www-svelte/node_modules/.pnpm/[email protected]/node_modules/vite/dist/node/chunks/dep-R0I0XnyH.js:29473:20)
    at resolveDeepImport (file:///Users/wilson/GitHub/Lobby/ai-www-svelte/node_modules/.pnpm/[email protected]/node_modules/vite/dist/node/chunks/dep-R0I0XnyH.js:29492:31)
    at tryNodeResolve (file:///Users/wilson/GitHub/Lobby/ai-www-svelte/node_modules/.pnpm/[email protected]/node_modules/vite/dist/node/chunks/dep-R0I0XnyH.js:29217:20)
    at Object.resolveId (file:///Users/wilson/GitHub/Lobby/ai-www-svelte/node_modules/.pnpm/[email protected]/node_modules/vite/dist/node/chunks/dep-R0I0XnyH.js:28985:28)
    at Object.handler (file:///Users/wilson/GitHub/Lobby/ai-www-svelte/node_modules/.pnpm/[email protected]/node_modules/vite/dist/node/chunks/dep-R0I0XnyH.js:67017:19)
    at file:///Users/wilson/GitHub/Lobby/ai-www-svelte/node_modules/.pnpm/[email protected]/node_modules/rollup/dist/es/shared/node-entry.js:18639:40
    at async PluginDriver.hookFirstAndGetPlugin (file:///Users/wilson/GitHub/Lobby/ai-www-svelte/node_modules/.pnpm/[email protected]/node_modules/rollup/dist/es/shared/node-entry.js:18539:28)
 ELIFECYCLE  Command failed with exit code 1.

CleanShot 2024-01-04 at 09 38 37@2x

@wbhob wbhob changed the title regression: build fails with SK 2.0 and svelte-highlight >=2.4.3 regression: build fails with SK 2.0 and svelte-highlight >=7.4.3 Jan 4, 2024
@metonym
Copy link
Owner

metonym commented Jan 4, 2024

Can you ensure this is the latest patch version v7.4.7?

@metonym
Copy link
Owner

metonym commented Jan 4, 2024

The sveltekit example works for me – both dev and building using the node adapter. It's using SvelteKit v2.

@wbhob
Copy link
Author

wbhob commented Jan 5, 2024

it appears that at one point, 'svelte-highlight/styles' was a valid import, but now it is not, so that was a major breaking change labeled as a patch release. I've updated the code to import the specific stylesheet and it's now working

@metonym
Copy link
Owner

metonym commented Jan 5, 2024

I'll take a look.

@metonym
Copy link
Owner

metonym commented Jan 5, 2024

@wbhob Thank you for flagging this.

Technically, it wasn't a breaking change as the barrel export files still exist (e.g., svelte-highlight/styles/index.js). The bug was that the exports map did not account for these entry points.

I published a fix in v7.4.8, which supports additional import methods:

// Base import for styles/languages
import { _default } from "svelte-highlight/styles";
import { _1c } from "svelte-highlight/languages";

// Explicit index
import { _default } from "svelte-highlight/styles/index";
import { typescript } from "svelte-highlight/languages/index";

// Explicit extension
import lang from "svelte-highlight/languages/1c.js"
import style from "svelte-highlight/styles/3024.js";

No TS errors in my IDE; Vite was able to resolve these imports in vite dev and vite build.

Screenshot 2024-01-04 at 9 19 18 PM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants