Parcel: Windows paths with brackets in them are recognised as glob pattern

Created on 3 Aug 2018  ยท  8Comments  ยท  Source: parcel-bundler/parcel

๐Ÿ› Bug report

Our windows build server suddenly stopped building the files after updating parcel to 1.9.7 even though parcel logs no errors. I discovered that this is due to the path O:\path\to\jenkins\Our software Name (Dev)\frontend\src\index.pug not being handled correctly.

๐Ÿค” Expected Behavior

O:\path\to\jenkins\Our software Name (Dev)\frontend\src\index.pug to be used as entry asset

๐Ÿ˜ฏ Current Behavior

__No Error given__, and no entry assset set!

๐Ÿ’ Possible Solution

Test if the given path is a path on the system, since we simply cannot know if the path given is meant as a abstract (glob) or real path.

https://github.com/parcel-bundler/parcel/blob/c334b2fe0890c800e9db38c156c2c8860fc1b31b/src/Bundler.js#L85-L89

Should be changed into:
(Sidenote parcel mainly used fs.exists which is marked as deprecated, so i sticked with that for this example)

    // Match files as globs
    return entryFiles
      .reduce((p, m) => {
        let mResult;

        // Check if the path exists, instead of treating certain non-alphabetic character 
        // as glob information
        if (fs.exists(m)) {
          mResult = m;
        } else {
          mResult = glob.sync(m);
        }

        return p.concat(mResult);
      }, [])      
      .map(f => Path.resolve(f));

๐ŸŒ Your Environment

| Software | Version(s) |
| ---------------- | ---------- |
| Parcel | 1.9.7
| Node | 8.9.3
| npm/Yarn | 1.5.1 yarn
| Operating System | Win 10

Bug Windows

Most helpful comment

I've tried Parcel v2 in docker, with same files, looks like it stucks in infinite loop:

root@330d0f9d1a64:/app# cat index.js
const m = require('./[id]')
console.log(m)

root@330d0f9d1a64:/app# cat \[id\].js
module.exports = 'test'

root@330d0f9d1a64:/app# node index.js
test

root@330d0f9d1a64:/app# npx parcel build index.js
โ ง Building [id]...
^C

root@330d0f9d1a64:/app# npx parcel --version
2.0.0-alpha.3.2

All 8 comments

Is this error has same roots?
I wanted to use square brackets in filenames, like Sapper does, but stuck with this :(

Screenshot 2020-01-22 at 16 06 04

@victordidenko what version are you using? v1 or v2?

I can probably add a unit test for it and fix it if it's a Parcel 2 bug

$ parcel --version
1.12.4

I've tried Parcel v2 in docker, with same files, looks like it stucks in infinite loop:

root@330d0f9d1a64:/app# cat index.js
const m = require('./[id]')
console.log(m)

root@330d0f9d1a64:/app# cat \[id\].js
module.exports = 'test'

root@330d0f9d1a64:/app# node index.js
test

root@330d0f9d1a64:/app# npx parcel build index.js
โ ง Building [id]...
^C

root@330d0f9d1a64:/app# npx parcel --version
2.0.0-alpha.3.2

No stale, please, dear bot

@victordidenko sorry for not coming back to you on this earlier, but can you create a small example with which I can reproduce this? Preferably in a github repo.

This is also the real purpose of the Stale bot, to ensure we don't forget about old issues :)

Hm. I tried with version 2.0.0-beta.1 and looks like my issue is resolved, there is no infinite loop no more.
I didn't try op @Hammster's case though.

@victordidenko awesome, than I'll close this for now, we can always re-open it or open a new issue

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Niggler picture Niggler  ยท  3Comments

davidnagli picture davidnagli  ยท  3Comments

adamreisnz picture adamreisnz  ยท  3Comments

davidnagli picture davidnagli  ยท  3Comments

donaldallen picture donaldallen  ยท  3Comments