parcel-bundler / parcel

The zero configuration build tool for the web. πŸ“¦πŸš€

Home Page:https://parceljs.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Build fails with multiple source globs

rmmh opened this issue Β· comments

πŸ› bug report

Building with the new (in canary) feature of package.json source glob patterns breaks in some conditions with custom file types.

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

parcel@2.0.0-canary.1591, see Code Sample for full repro script.

πŸ€” Expected Behavior

npx parcel build succeeds.

😯 Current Behavior

🚨 Build failed.

Error: Cannot use 'in' operator to search for 'key' in undefined

  TypeError: Cannot use 'in' operator to search for 'key' in undefined
      at getJSONHighlightLocation (/home/ryan/repro/node_modules/parcel/node_modules/@parcel/diagnostic/lib/diagnostic.js:165:19)
      at getJSONSourceLocation (/home/ryan/repro/node_modules/parcel/node_modules/@parcel/diagnostic/lib/diagnostic.js:207:11)
      at EntryResolver.resolveEntry (/home/ryan/repro/node_modules/parcel/node_modules/@parcel/core/lib/requests/EntryRequest.js:228:62)
      at async Object.run (/home/ryan/repro/node_modules/parcel/node_modules/@parcel/core/lib/requests/EntryRequest.js:57:16)
      at async RequestTracker.runRequest (/home/ryan/repro/node_modules/parcel/node_modules/@parcel/core/lib/RequestTracker.js:777:20)
      at async AssetGraphBuilder.runEntryRequest 
  (/home/ryan/repro/node_modules/parcel/node_modules/@parcel/core/lib/requests/AssetGraphRequest.js:344:18)
      at async $dad2a694f9c45026$export$2e2bcd8739ae039._runFn 
  (/home/ryan/repro/node_modules/parcel/node_modules/@parcel/utils/lib/index.js:34004:13)
      at async $dad2a694f9c45026$export$2e2bcd8739ae039._next 
  (/home/ryan/repro/node_modules/parcel/node_modules/@parcel/utils/lib/index.js:33997:9)

πŸ’ Possible Solution

It seems the multiple source logic from package.json is buggy.

  • npx parcel build *.html *.tmpl works.
  • package.json "source": ["*.{tmpl.html}"] works
  • removing b.tmpl works-- building one HTML and one TMPL file.

πŸ”¦ Context

I'm using parcel to process HTML templates for another tool to render.

πŸ’» Code Sample

tiny repro script:

#!/bin/bash
set -exu
mkdir repro
cd repro
cat > package.json <<EOF
{
  "name": "parcel-multi-repro",
  "source": [
    "*.tmpl",
    "*.html"
  ]
}
EOF
cat > .parcelrc <<EOF
{
  "extends": "@parcel/config-default",
  "transformers": {
    "*.tmpl": [
      "@parcel/transformer-posthtml",
      "@parcel/transformer-html",
    ],
  },
}
EOF
touch a.tmpl b.tmpl c.html
npm i parcel@2.0.0-canary.1591
npx parcel build

🌍 Your Environment

Software Version(s)
Parcel 2.0.0-canary.1591+fcc6b5963
Node v20.12.2
npm/Yarn 10.5.2
Operating System Ubuntu 22.04.4 LTS (x86_64)