Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build fails with multiple source globs #9713

Closed
rmmh opened this issue May 11, 2024 · 3 comments · Fixed by #9901
Closed

Build fails with multiple source globs #9713

rmmh opened this issue May 11, 2024 · 3 comments · Fixed by #9901

Comments

@rmmh
Copy link

rmmh commented May 11, 2024

🐛 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)
@TechQuery
Copy link

TechQuery commented Jun 28, 2024

@mischnic There's no error with parcel@2.12.0, but nothing outputs: #8896 (reply in thread)

Enabling @parcel/resolver-glob changes nothing: EasyWebApp/mark-wiki#1

@TechQuery
Copy link

TechQuery commented Aug 20, 2024

@mischnic There's no error with parcel@2.12.0, but nothing outputs: #8896 (reply in thread)

Enabling @parcel/resolver-glob changes nothing: EasyWebApp/mark-wiki#1

I find another way to resolve the building script:

{
    "devDependencies": {
        "glob": "^11.0.0",
        "parcel": "^2.12.0"
    },
    "scripts": {
        "build": "glob public/**/*.html -c \"parcel build\" -- --public-url=."
    }
}

but it's not a good idea for developing to run multiple watching servers at the same time.

@devongovett
Copy link
Member

I think this is fixed by #9901

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants