I'm working on a webextension for Firefox. The code is written in Typescript.
But parcel generates sourcemap paths that are not parsed correctly by Firefox.
The paths look like this:
//# sourceMappingURL=/content2.map
without the slash in from of content2.map, the path can be read by Firefox.
This problem occurs only for sourcefiles within folders.
My configuration is minimal, just Typescript and Parcel. To let you reproduce the problem, I set up a git repository, see below.
Parcel shouldn't generate that slash.
Well, currently it generates it :P
Here is a repository that can reproduce the problem:
https://github.com/lhk/nested_sourcemaps
This sample contains two scripts. One is in src/, the other is in src/content. Both scripts print something to the console, which makes them easy to find.
The master branch contains no parcel and shows you how the code works correctly:
git clone https://github.com/lhk/nested_sourcemaps
cd nested_sourcemaps
npm install
tsc
Now you can load src/manifest.json into Firefox. Open any website, open the developer console, reload the website, you will see two logs from the two scripts. Firefox automatically recognizes them as typescript :)
Now you switch to the parcel branch
git reset --hard
git clean -xdf
git checkout parcel_branch
npm install
parcel build src/manifest.json
Same procedure as above, load the plugin into Firefox. Now you have to use the manifest from dist/manifest.json.
Again, you can see two console logs. But for the script in src/content, the sourcemap can't be parsed.
If I edit this file manually and change the last line from:
//# sourceMappingURL=/content2.map
to
//# sourceMappingURL=content2.map
Then it works as expected.
| Software | Version(s) |
| ---------------- | ---------- |
| Parcel | 1.10.3
| Node | v8.12.0
| npm/Yarn | npm 6.4.1
| Operating System | ubuntu 18.04.01 64bit
| Firefox | 63
This is very similar to #1753
Curiously, in the other case the / is missing, while I want to get rid of it.
@lhk use 鈥攑ublic-url ./
Sent with GitHawk
Thanks, that solves it.
Most helpful comment
@lhk use
鈥攑ublic-url ./Sent with GitHawk