I tried running Parcel 2 alpha in my project to see how it goes, and I was presented with an error "Cannot find module...".
// .babelrc
{
"presets": [
["@babel/preset-env", {
"modules": false,
"useBuiltIns": "usage",
"corejs": 3
}],
"@babel/preset-react"
],
"plugins": [
"@babel/plugin-proposal-export-default-from",
"@babel/plugin-proposal-optional-chaining"
],
}
CLI command:
"start": "parcel src/index.html --cache-dir ./.cache/dev",
Parcel to successfully resolve paths and build the application like in 1.x
Server running at http://localhost:1234
๐จ Cannot find module '../components/pages/form/step_context' from '/Users/wojciech.maj/P
rojekty/cfola/src/hooks'
at ResolverRunner.resolve (/Users/wojciech.maj/Projekty/cfola/node_modules/@parcel/co
re/lib/ResolverRunner.js:71:15)
at async RequestGraph.resolvePath (/Users/wojciech.maj/Projekty/cfola/node_modules/@p
arcel/core/lib/RequestGraph.js:400:24)
at async PromiseQueue._runFn (/Users/wojciech.maj/Projekty/cfola/node_modules/@parcel
/utils/lib/PromiseQueue.js:94:7)
at async PromiseQueue._next (/Users/wojciech.maj/Projekty/cfola/node_modules/@parcel/
utils/lib/PromiseQueue.js:81:5)
And below the spinner is just stuck, rotating on:
โ Building checkmark.svg...
Obviously, this path (/Users/wojciech.maj/P
rojekty/cfola/src/components/pages/form/step_context) is very much there so I don't know why this problem occurred.
| Software | Version(s) |
| ---------------- | ---------- |
| Parcel | 2.0.0-alpha.2.1
| Node | 12.4.0
| npm/Yarn | 1.19.1
| Operating System | MacOS Catalina
Could you share a code sample or reproduction repo?
Ha! I stripped my repo down to several files and I figured it out.
So I ended up with this simple tree of dependencies:
index.html
index.jsx
useHello.js
hello.jsx
and ended up with the same error:
Cannot find module './hello' from '/Users/wojciech.maj/Projekty/cfola/src'
Turns out that while html and jsx files are perfectly able to resolve jsx files, js files cannot. When I changed hello.jsx into hello.jsit started building.
...until the next place in which I had the same situation.
Just ran into this as well ๐
The reason is that jsx is missing in this array:
https://github.com/parcel-bundler/parcel/blob/96c25fa775395f005d6b483020d6b522d29d3dfe/packages/resolvers/default/src/DefaultResolver.js#L33
But the goal is to get rid of this hardcoded list anyway....
Can we get it on this hardcoded list just for now, for me to be able to continue testing Parcel 2 Alpha?