Open Jezternz opened 3 years ago
Sourcemaps were disabled for inline bundles (<script>.....</script>
) on purpose: https://github.com/parcel-bundler/parcel/pull/4859
@DeMoorJasper @mischnic Is there anyway I can convince you to reconsider retaining the functionality even though it does add some complexity, possibly behind a flag in the sourcemaps config object.
The best arguments I can think of are:
I realise this is not the main use case for parcel, but have found parcel uniquely good at solving problems around bundling so would like to keep using it. (My use case is basically the need to be able to have a single all contained html file that can be generated and sent out, at least for my purposes even having an external sourcemap for inline js would be better then none)
I understand this is an OS project so you have to choose where you spend your limited time - thanks for parcel it is awesome.
external sourcemap for inline js
Not sure how complicated that would be, but that is the only solution that doesn't have the massive downsides of inline sourcemaps in inline bundles.
Just to make sure I understand correctly the downsides are primarily focused around performance? (Extra time to generate when parcel runs and extra bytes to download and parse when the browser runs?)
Extra time to generate when parcel runs
It doesn't make a difference for the build time
extra bytes to download and parse when the browser runs
Exactly
And I guess the primary obstacle to putting this behind a flag is the added complexity / maintenance etc?
The general problem is that inline bundles (= what becomes the content of the <script>
tag) themselves don't have a file path (because they aren't written to disk). So the usual method of "create a file *.map next to the bundle" doesn't work in this case.
I had thought that because Parcel 1 handled it well there was a good chance Parcel 2 would - though I understand there are other considerations. At least for my unusual case I may need to revert to Parcel 1 until I work out how to refactor around these considerations - thanks for the replies.
π bug report
It appears that even with explicit sourceMaps true or {inlineSources: true, inline: true}, no inline sourcemap is generated.
π Configuration (.babelrc, package.json, cli command)
packages.json
index.htm
a.js
output index.html (see js is correctly minified, but incorrectly no sourcemap is provided)
π€ Expected Behavior
Expect to see an inline sourcemap appended to the
<script type="module">
.π― Current Behavior
No inline sourcemap there.
π¦ Context
Developing a small app, that should be a single html file, but also needs to be debuggable so requires inline sourcemaps. Used example here as base.
π» Code Sample
Also attached parcelv2-sourcemap-example.zip containing the same code as above, you can extract and run "npm start on".
π Your Environment