I use Parcel for its speed but I have a little problem. The Glob resolver just ignores the folder content.
I need import all content from folder /documents
which contains PDF & HTML files. So I tried:
import * Docs from "url:/documents/*.{html,pdf}"
But it does not work and in source map, there is a file /documents/*.js
:
module.exports = {}
.parcelrc
{
"extends": "@parcel/config-default",
"resolvers": [
"@parcel/resolver-glob",
"..."
]
}
The real problem why parcel returned {}
was Scope Hoisting. I wanted to access dynamically:
import * as Docs from "url:./documents/*.{html,pdf}";
const embeds = Object.values(Docs).map(src => (
<iframe src={src} className="document" />
));
So the solution is turn off scope hoisting via --no-scope-hoist