npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@nebula.js/cli-build

v5.0.1

Published

Build nebula.js visualization.

Downloads

1,993

Readme

@nebula.js/cli-build

Build nebula.js visualization.

Install

npm install @nebula.js/cli @nebula.js/cli-build -g

Usage

nebula build

Build nebula.js visualization

Options:
  --version                 Show version number                                 [boolean]
  --config, -c              Path to a JavaScript config file
                                                   [string] [default: "nebula.config.js"]
  --watch, -w               Watch source files
                                            [choices: "umd", "systemjs"] [default: "umd"]
  --sourcemap, -m           Generate source map                 [boolean] [default: true]
  --mode                    Explicitly set mode
                                          [string] [choices: "production", "development"]
  --core                    Set a core build target            [string] [default: "core"]
  --typescript              Enable typescript bundling         [boolean] [default: false]
  --preferBuiltins          Specify whether to use Node.js built-in modules.
                                                                [boolean] [default: true]
  --browser                 Use the browser module resolutions in package.json and adds
                            'browser' to exportConditions if it is not present so browser
                            conditionals in exports are applied.
                                                               [boolean] [default: false]

Example

Configuration file

Build the bundle with a nebula configuration json file in a new path

nebula build --config config/my-nebula-config.js

In the config file, build properties:

  • Version
  • Sourcemap
  • Mode
  • Core
  • Typescript

The following code in a config file demonstrates an example to set the nebula build configuration.

const path = require('path');
const defaultTheme = require('yourThemeProject/theme.json');
const targetPkg = require(path.resolve(process.cwd(), 'package.json'));
const replacementStrings = {
  'process.env.PACKAGE_VERSION': JSON.stringify(targetPkg.version),
};
const mode = process.env.NODE_ENV === 'production' ? 'production' : 'development';
const sourcemap = mode !== 'production';

module.exports = {
  build: {
    replacementStrings,
    sourcemap,
    mode,
    core: 'core',
    typescript: true,
  },
};

Watch files

Rebuild the bundle when files in /src folder have been change on the disk

nebula build --watch

Source map

Build the bundle without a source map file - .js.map file

nebula build --sourcemap false

A source map is a file that maps from the bundled source file to the original source files, enabling the browser to reconstruct and present the original source code in the debugger. So if there is an error in a file in the /dist directory, the source map can tell you the original source file location.

Basically, source map is helpful for debugging and should be removed for production.

Mode

Bundle is not minified in the development mode

nebula build --mode development

And minified in the production mode

nebula build --mode production

Core build

You can export only the esm bundle by adding --core parameter.

To achieve that, you need to add a package.json file in the /core directory. In the package.json file, a module field which specifies the output file from the build is required:

"module": "dist/hello.esm.js",

The package.json can also have a different list of peerDependencies changing what dependencies are included in the output file.

Then run the following command:

nebula build --core

The code is exported into /core directory

When you want to specify your directory instead of the default one, you can move that package.json file into your directory and run the following command:

nebula build --core minimal/target

The code is exported into /minimal/target directory

Tips: In the package.json file, the main field makes sure that Node users using require can be served the umd version. The module field is a common convention to designate how to import an esm version of your code.

SystemJS build

You can build a bundle using the SystemJS format by adding a systemjs field in the package.json which specifies the output file from the build:

"systemjs": "dist/hello.systemjs.js"

Typescript

With this option you can enable typescript bundling of your code. Add a tsconfig.json file to configure typescript to your own preferences.

nebula build --typescript