Comments (4)
@maxbeatty looks like there is a little bit of talk about supporting multiple entry points in #113. As of now, I believe the only way to support multiple bundles right now would either be:
ncc build a.js -o dist
ncc build b.js -o dist
or with a custom build script using the ncc Node API:
const path = require('path')
const ncc = require('@zeit/ncc')
// Whatever options you want. This is an example.
const options = {
minify: true,
sourceMap: true,
watch: false,
}
Promise.all([
ncc(path.resolve('./a.js'), options),
ncc(path.resolve('./b.js'), options),
])
.then(([a, b]) => {
// Builds succeeded!
// You can write the code and sourcemaps to disk or whatever you'd like to do here.
console.log(a.code)
console.log(a.assets)
console.log(a.map)
})
.catch((err) => {
// There was an error in one of the builds.
console.error(err)
})
(where a.js
and b.js
live in the folder you are running the script from. Those sorts of file paths would need to be updated to suit your needs.)
I think examples for programmatic use (both for one entry point and multiple entry points) would be welcome additions to this repo to help guide people in understanding what options are available / best practices are around multiple bundles + programmatic use. π
from ncc.
Would also be good to add examples for programmatic use and TypeScript support π
Can get started on a PR for these
from ncc.
What's the optimal way to do multiple bundles? Programmatic?
Would there ever be a day where ncc
takes a glob to build? (e.g. ncc build *.js
or ncc build {cli,main}.js
)
from ncc.
Examples were added in c813b07.
We can reopen if we need to add any new examples.
from ncc.
Related Issues (20)
- Cannot bundle `@npmcli/arborist` HOT 3
- ESM mode still uses "require" within an ESM module HOT 6
- Java
- Confusing error message "Package path . is not exported from package" HOT 2
- Are there multiple js files in the directory packaged by NCC? HOT 2
- vercel/ncc
- Advantages over other bundlers HOT 4
- more documentation about `--v8-cache`
- ncc and prebuildify HOT 3
- TypeError when resolving symlinked module paths in a Lerna workspace
- ζε δΉεε¨linuxη³»η»δΈζ ζ³θΏθ‘ HOT 2
- AssetBuilds repeatedly packages the same resources
- Why i got multiple js file, and Cannot find module './indexes' ? HOT 4
- Does ncc support dynamic required(path) of fs.readdir ?
- Outdated Terser causes a syntax issue when minify-ing code
- Unclear instructions to build ncc from source. HOT 1
- ncc randomly copies folders from repository to dist (path.join + process.cwd) HOT 2
- Error possibily related to bundling of import.meta.url
- ncc build error: see the description
- ncc pack and then pkg pack,got some error about node.path
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ncc.