Parcel: bundle-text: causes inline source maps

Created on 7 Jul 2020  ยท  4Comments  ยท  Source: parcel-bundler/parcel

๐Ÿ› bug report

When using bundle-text: on a source type that supports source maps (such as CSS), the source is inlined into the bundled text. This produces larger files in production.

๐ŸŽ› Configuration (.babelrc, package.json, cli command)

https://github.com/GoogleChromeLabs/tooling.report/tree/parcel-updates/tests/non-js-resources/subtests/css/subtests/source/parcel

import css from 'bundle-text:./styles.css';

const style = document.createElement('style');
style.textContent = css;
document.head.append(style);
html {
  background: green;
}

h1 {
  color: white;
}

๐Ÿค” Expected Behavior

Either the sourcemap is removed, or becomes external.

!function(){var e,t=document.createElement("style"),n=(e="html{background:green}h1{color:#fff}")&&e.__esModule?e.default:e;t.textContent=n,document.head.append(t)}();
//# sourceMappingURL=index.a3f3179f.js.map

๐Ÿ˜ฏ Current Behavior

!function(){var e,t=document.createElement("style"),c=(e="html{background:green}h1{color:#fff}\n/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJtYXBwaW5ncyI6IkFBQUEsS0FDQSxnQkFDQSxDQUVBLEdBQ0EsVUFDQSIsInNvdXJjZXMiOlsiLi9zcmMvc3R5bGVzLmNzcyJdLCJzb3VyY2VzQ29udGVudCI6WyJodG1sIHtcbiAgYmFja2dyb3VuZDogZ3JlZW47XG59XG5cbmgxIHtcbiAgY29sb3I6IHdoaXRlO1xufVxuIl0sIm5hbWVzIjpbXSwidmVyc2lvbiI6MywiZmlsZSI6ImluZGV4LkhBU0hfUkVGXzMxMjE0Y2I4ODM1NzdlNDYxMjVmMTg4ZWI5NGMzMTUwLmNzcy5tYXAifQ== */\n")&&e.__esModule?e.default:e;t.textContent=c,document.head.append(t)}();
//# sourceMappingURL=index.a3f3179f.js.map

๐Ÿ’ Possible Solution

Either the sourcemap is removed, or becomes external.

๐Ÿ”ฆ Context

The idea is to create an optimal build for production.

๐Ÿ’ป Code Sample

https://github.com/GoogleChromeLabs/tooling.report/tree/parcel-updates/tests/non-js-resources/subtests/css/subtests/source/parcel

๐ŸŒ Your Environment

| Software | Version(s) |
| ---------------- | ---------- |
| Parcel | 2.0.0-beta.1
| Node | v12.16.1
| npm/Yarn | npm 6.14.4
| Operating System | OSX 10.15.5

Bug Source Maps โœจ Parcel 2

Most helpful comment

It's not on Github (I noticed this issue a few days ago when preparing the list we reported to the tooling report ๐Ÿ˜‰ )

All 4 comments

This is already kind of tracked internally in height with T-596 (probably also has an issue here on Github already)

Will fix this tomorrow or later today, seems like a fairly simple fix

I guess sourcemaps should never be inlined? Inlining them somewhat defies their purpose of being able to debug a build that was deployed to production

This also happens with inline script tags

<script>
   import {add} from "lodash";
   console.log(add(1,2));
</script>

Ah, sorry, I did search, but didn't find anything.

It's not on Github (I noticed this issue a few days ago when preparing the list we reported to the tooling report ๐Ÿ˜‰ )

Was this page helpful?
0 / 5 - 0 ratings