-
Notifications
You must be signed in to change notification settings - Fork 916
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
[BUG] Source maps not found in dev server for third party packages #3381
Comments
I can confirm this is still an issue as of 3.6.2, using the blank template along with Node 14.17.1 and npm 7.19.0, on MacOS 11.4. I'm getting This is my /** @type {import("snowpack").SnowpackUserConfig } */
export default {
mount: {
public: { url: '/', static: true },
src: { url: '/dist' },
},
plugins: [
[
'@snowpack/plugin-babel',
{
transformOptions: {
sourceMaps: "inline"
},
}
],
[
'@snowpack/plugin-webpack',
{
sourceMap: true,
outputPattern: { html: './build/' },
},
],
],
routes: [
/* Enable an SPA Fallback in development: */
// {"match": "routes", "src": ".*", "dest": "/index.html"},
],
optimize: {
/* Example: Bundle your final build: */
"bundle": true,
},
packageOptions: {
/* ... */
},
devOptions: {
/* ... */
"open": "chrome",
},
buildOptions: {
/* ... */
sourcemap: true,
},
}; and this is my import '@ungap/custom-elements'; Imo snowpack shouldn't try to generate or load sourcemaps for any third party packages in the first place. As it is now, this leaves snowpack in an unusable state, as it keeps reporting these errors in every watch step. Imagine having 50+ external dependencies and snowpack dev reporting this in the console for each of those 50 packages every time you make a change. Edit: Diving deeper into the matter, I found that by the looks of it only certain external dependencies cause this problem. E.g. importing |
I was running into this problem with web-test-runner coverage mode looking up these broken sourcemaps and causing logspam. The way the dev server works is by building the files in memory when they get requested so this problem means the internal mapping isn't working for some reason. The problem with external deps was introduced with a refactor that happened earlier this year: You can see here that for some reason instead of properly serving a sourcemap the code removes the I didn't debug deeply why those files sometimes also 404 (since 404s are ignored during coverage) but it's probably a proximate cause. A workaround/fix is to realize that One warning: even though the sourcemap option changes these external packages, the cache is not invalidated and thus you won't see any change if you don't also run |
It seems like when the lateset sourcemap changes were made it was expected that snowpack would treat If I change that line to end with For consistency, it seems that we should use I think long term though there's no reason why URL based sourcemaps shouldn't work if we fix the issues in dev.ts I mentioned above. |
Bug Report Quick Checklist
Describe the bug
Enabling
buildOptions.sourcemap: true
causes the dev server to throw "file not found" errors for third party packages.map
files. First-party modules don't have the problemTo Reproduce
We can't fix bugs that we can't see for ourselves. Issues often need to be closed if this section is skipped.
npx create-snowpack-app snowpack_sourcemap_test --template @snowpack/app-template-lit-element-typescript
cd snowpack_sourcemap_test
snowpack.config.mjs
, addbuildOptions.sourcemap: true
npm run start
http://localhost:8080/_snowpack/pkg/lit-html.js.map
et al.Expected behavior
No source map errors during development.
Anything else?
The source maps are properly being generated when doing
npm run build
, just not during dev.The text was updated successfully, but these errors were encountered: