Giter Site home page Giter Site logo

Add examples folder about ncc HOT 4 CLOSED

vercel avatar vercel commented on August 15, 2024 4
Add examples folder

from ncc.

Comments (4)

macklinu avatar macklinu commented on August 15, 2024 1

@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.

macklinu avatar macklinu commented on August 15, 2024

Would also be good to add examples for programmatic use and TypeScript support 😎

Can get started on a PR for these

from ncc.

maxbeatty avatar maxbeatty commented on August 15, 2024

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.

guybedford avatar guybedford commented on August 15, 2024

Examples were added in c813b07.

We can reopen if we need to add any new examples.

from ncc.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.