Why parcel v2 generates wrong content for source map files when using "serve"?

Viewed 288

I have this package.json (minimalist project here):

{
  "name": "new-es6-project",
  "version": "1.0.0",
  "description": "A JavaScript project",
  "scripts": {
    "start": "npx parcel serve --log-level verbose ./src/index.html",
    "build": "npx parcel build ./src/index.html",
    "lint": "node ./node_modules/eslint/bin/eslint . --ext .js --fix"
  },
  "targets": {
    "default": {
      "engines": {
        "browsers": "> 0.5%"
      },
      "distDir": "dist",
      "publicUrl": "."
    }
  },
  "repository": {
    "type": "git",
    "url": ""
  },
  "keywords": [],
  "author": "",
  "license": "MIT",
  "devDependencies": {
    "eslint": "^7.2.0",
    "eslint-config-airbnb-base": "^14.2.1",
    "eslint-plugin-import": "^2.22.1",
    "parcel": "^2.0.0-beta.2"
  }
}

and when running the command:

npx parcel serve --log-level verbose ./src/index.html

I get:

ℹ️ Server running at http://localhost:1234
✨ Built in 112ms
@parcel/reporter-dev-server: Request: localhost:1234/
@parcel/reporter-dev-server: Request: localhost:1234/index.de60a1d7.css
@parcel/reporter-dev-server: Request: localhost:1234/index.bd78eeec.js
@parcel/reporter-dev-server: Request: localhost:1234/index.de60a1d7.css.map
@parcel/reporter-dev-server: Request: localhost:1234/favicon.ico
@parcel/reporter-dev-server: Request: localhost:1234/index.bd78eeec.js.map

I download each source map file, e.g.:

wget localhost:1234/index.bd78eeec.js.map

then:

cat index.bd78eeec.js.map

and the result is:

<!DOCTYPE html>
<html lang="en">
<head>
  <title>A JavaScript project</title>
  <link rel="stylesheet" href="/index.de60a1d7.css">
  <meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
  <h1>A JavaScript project</h1>
  <div id="app"></div>
  <script src="/index.bd78eeec.js" type="module"></script>
</body>
</html>

The same is for index.de60a1d7.css.map.

When running:

npx parcel build ./src/index.html
ls -l dist
-rw-rw-r-- 1 adr adr  15K Mar 25 21:36 index.bd78eeec.js
-rw-rw-r-- 1 adr adr 6.1K Mar 25 21:36 index.bd78eeec.js.map
-rw-rw-r-- 1 adr adr 2.0K Mar 25 21:36 index.de60a1d7.css
-rw-rw-r-- 1 adr adr  751 Mar 25 21:36 index.de60a1d7.css.map
-rw-rw-r-- 1 adr adr  184 Mar 25 21:43 index.e428b182.js
-rw-rw-r-- 1 adr adr  482 Mar 25 21:43 index.e428b182.js.map
-rw-rw-r-- 1 adr adr  324 Mar 25 21:43 index.html
-rw-rw-r-- 1 adr adr 1.5K Mar 25 21:43 index.69541315.css
-rw-rw-r-- 1 adr adr 2.7K Mar 25 21:43 index.69541315.css.map

the source map files are generated correctly (*.map content is json).

Why the source map files are wrongly generated and how should I fix that?

0 Answers
Related