Parcel 2: multi entry/target builds
See original GitHub issueSplit out of #2574.
For SSR, it would be useful to support multiple targets with different entries simultaneously.
Three options came up in the previous issue:
Explicit entries per target
const parcel = new Parcel({
entries: {
browserEntry_page1: '/path/to/browser/entry/of/page1.js',
browserEntry_page2: '/path/to/browser/entry/of/page2.js',
serverEntry: '/path/to/server.js',
},
targets: {
browserEntry_page1: {
"browsers": ["> 1%", "not dead"]
},
browserEntry_page2: {
"browsers": ["> 1%", "not dead"]
},
serverEntry: {
"node": ["^8.0.0"]
},
}
});
An array of parcel options
const parcel = new Parcel([
{
entries: ['page1.js', 'page2.js']
targets: {
browser: {
browser: ['>1%', 'not dead']
}
}
},
{
entries: ['server.js']
targets: {
node: {
node: ['^8.0.0']
}
}
}
});
Multiple Parcel instances, sharing a worker farm
We were thinking of making the worker farm an option anyway, so this might work for free. By sharing a worker farm instance, multiple Parcel instances could run in parallel.
const workerFarm = new WorkerFarm();
const browserParcel = new Parcel({
workerFarm,
entries: ['page1.js', 'page2.js']
targets: {
browser: {
browser: ['>1%', 'not dead']
}
}
});
const serverParcel = new Parcel({
workerFarm,
entries: ['server.js']
targets: {
node: {
node: ['^8.0.0']
}
}
});
Thoughts?
Issue Analytics
- State:
- Created 4 years ago
- Reactions:23
- Comments:50 (27 by maintainers)
Top Results From Across the Web
Targets - Parcel
Parcel can compile your source code in multiple different ways simultaneously. These are called targets. For example, you could have a “modern” target...
Read more >Devon Govett Twitterissä: "Parcel 2 supports multi-target ...
Parcel 2 supports multi-target builds. Just set them up in your package.json, and Parcel will build multiple versions of your app in parallel....
Read more >package.json - Parcel
To create your own target (without any of the semantics of the common target described previously), add a top-level field with your target's...
Read more >Bundling and Building with Parcel - Beginner JavaScript
However, for longer projects that span multiple days, it is best you install Parcel to ... (Note: if you see Parcel 2 as...
Read more >deploying problem with multiple html files. Parcel
when I deploy a website( with multiple entry points, many HTML files ) and the host uses the build command: parcel build index.html ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
It is all possible to override, I’m just not sure we should encourage it:
@brillout I’m sorry but that’s a big no for me, this is just unnecessarily complex,
Would serve the same purpose, while being more explicit and straightforward.
I don’t like the fact that you can reference targets, from targets, this makes you have to look back everytime you see a definition that use a reference. Configurations should be explicit and simple, sure, if you have a lot of different needs, it’ll get complex, but for a simple configuration like this, it shouldn’t be and look complex for nothing.
Edit 1: BTW, about your
isomorphic
target, if parcel supports ESM outputs and the top level await proposal(which is getting shipped in v8 and webpack as an experiment), we could have multi-target bundles since node will, at its next version, support ESM modules as a stable featureEdit 2: While we’re at it, we could even remove some config duplication by allowing entries as array, but then i’m not sure that
entries
/entry
/target
should be the name of the properties