parcel-plugin-svelte icon indicating copy to clipboard operation
parcel-plugin-svelte copied to clipboard

Build silently failing (ERR_PACKAGE_PATH_NOT_EXPORTED)

Open fregante opened this issue 4 years ago • 5 comments

🐛 Bug Report

The bug specifically is in https://github.com/sveltejs/svelte/issues/5659, which is strictly not due to this plugin, but parcel build failed without changing the exit code, so this caused my CI to deploy a broken built file.

I don't know if this is a problem with Parcel not setting the exit code or this plugin reporting it as a warning.

🎛 Configuration (.svelterc, package.json, cli command)

parcel build --public-url ./ demo/index.html

⚠️  Parser "parcel-plugin-svelte/lib/svelte-asset.js" failed to initialize when processing asset "demo/App.svelte". Threw the following error:
Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './compiler.js' is not defined by "exports" in /home/runner/work/github-url-detection/github-url-detection/node_modules/svelte/package.json
    at throwExportsNotFound (internal/modules/esm/resolve.js:290:9)
    at packageExportsResolve (internal/modules/esm/resolve.js:513:3)
    at resolveExports (internal/modules/cjs/loader.js:432:36)
    at Function.Module._findPath (internal/modules/cjs/loader.js:472:31)
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:867:27)
    at Function.Module._load (internal/modules/cjs/loader.js:725:27)
    at Module.require (internal/modules/cjs/loader.js:952:19)
    at require (/home/runner/work/github-url-detection/github-url-detection/node_modules/v8-compile-cache/v8-compile-cache.js:159:20)
    at Object.<anonymous> (/home/runner/work/github-url-detection/github-url-detection/node_modules/parcel-plugin-svelte/lib/svelte-asset.js:2:33)
    at Module._compile (/home/runner/work/github-url-detection/github-url-detection/node_modules/v8-compile-cache/v8-compile-cache.js:192:30) falling back to RawAsset
⚠️  Parser "parcel-plugin-svelte/lib/svelte-asset.js" failed to initialize when processing asset "demo/App.svelte". Threw the following error:
Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './compiler.js' is not defined by "exports" in /home/runner/work/github-url-detection/github-url-detection/node_modules/svelte/package.json
    at throwExportsNotFound (internal/modules/esm/resolve.js:290:9)
    at packageExportsResolve (internal/modules/esm/resolve.js:513:3)
    at resolveExports (internal/modules/cjs/loader.js:432:36)
    at Function.Module._findPath (internal/modules/cjs/loader.js:472:31)
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:867:27)
    at Function.Module._load (internal/modules/cjs/loader.js:725:27)
    at Module.require (internal/modules/cjs/loader.js:952:19)
    at require (/home/runner/work/github-url-detection/github-url-detection/node_modules/v8-compile-cache/v8-compile-cache.js:159:20)
    at Object.<anonymous> (/home/runner/work/github-url-detection/github-url-detection/node_modules/parcel-plugin-svelte/lib/svelte-asset.js:2:33)
    at Module._compile (/home/runner/work/github-url-detection/github-url-detection/node_modules/v8-compile-cache/v8-compile-cache.js:192:30) falling back to RawAsset
✨  Built in 1.98s.

dist/App.0a75e0c7.svelte        1.93 KB    509ms
dist/main.127a4158.js           1.47 KB    772ms
dist/global.8961bae3.css.map      847 B      4ms
dist/index.html                   714 B    1.09s
dist/main.127a4158.js.map         554 B      1ms
dist/global.8961bae3.css          388 B    778ms

💻 Code Sample

Every build is affected, but in my case the issue was on https://github.com/fregante/github-url-detection (but was avoided by forcing an older version of Svelte)

🌍 Your Environment

Node 14.4.0

{
	"parcel-bundler": "^1.12.4",
	"parcel-plugin-svelte": "^4.0.6",
	"svelte": "3.29.6" // This version is broken
}

fregante avatar Nov 10 '20 16:11 fregante

Changing the imports to const { compile, preprocess } = require('svelte/compiler'); appears to resolve the issue. However, I don't know if the import will work for older Svelte versions too.

jojonas avatar Nov 10 '20 22:11 jojonas

Hey there, I'm having the same issue with my project. @jojonas could you expand on how to fix this? Where should I add const { compile, preprocess } = require('svelte/compiler');? Thanks!

loristewis avatar Nov 24 '20 11:11 loristewis

@loristewis See this commit: https://github.com/DeMoorJasper/parcel-plugin-svelte/commit/bd8207ccea11ad2a367f5318f0818eba674c9d3b and #153

jojonas avatar Nov 25 '20 18:11 jojonas

is this plugin completely broken? since there are no updates for nearly a year ?

ta3pks avatar Jun 07 '21 02:06 ta3pks

@NikosEfthias there hasn't been any new issues reported so there's no new releases...

There's also a Parcel 2 plugin now, so this plugin will probably get deprecated once Parcel 2 reaches stable...

DeMoorJasper avatar Jun 07 '21 07:06 DeMoorJasper