パッケージの詳細

@alwatr/nano-build

Alwatr2.2kMPL-2.06.3.5

Build/bundle tools for ECMAScript, TypeScript, and JavaScript libraries. It's easy to use, doesn't require any setup, and adheres to best practices. It has no dependencies and uses esbuild for enhanced performance.

alwatr, browser, build, bundle

readme

Nano build

Build/bundle tools for ECMAScript, TypeScript, and JavaScript libraries. It's easy to use, doesn't require any setup, and adheres to best practices. It has no dependencies and uses esbuild for enhanced performance.

Installation

First, install @alwatr/nano-build as a development dependency:

yarn add -D @alwatr/nano-build

Usage

Add the following scripts to your package.json to use @alwatr/nano-build:

{
  "scripts": {
    "build": "nano-build --preset=module",
    "watch": "yarn run build --watch"
  }
}

Then run the following command to build your project:

yarn run build

Configuration

TypeScript

To use @alwatr/nano-build in your TypeScript project, you need to configure your tsconfig.json file. Below is an example configuration:

{
  "extends": "@alwatr/tsconfig-base/tsconfig.json",
  "compilerOptions": {
    "rootDir": "src",
    "outDir": "dist",
    "emitDeclarationOnly": true,
    "composite": true,
    "types": ["@alwatr/nano-build"],
  },
  "include": ["src/**/*.ts"],
}

This configuration ensures that your TypeScript project is set up to use @alwatr/nano-build effectively, providing a streamlined build process with best practices.

Overwriting configuration

Add 'nano-build' field to your package.json for overwriting configuration:

{
  "nano-build": {
    "bundle": true
  },
  "nano-build-development": {
    "minify": false,
    "sourcemap": true
  },
  "nano-build-production": {
    "minify": true,
    "sourcemap": false
  }
}

Presets

Presets are predefined configurations that can be used to build your project. You can use the --preset flag to specify a preset.

yarn run build --preset=module

default

{
  entryPoints: ['src/*.ts'],
  outdir: 'dist',
  logLevel: 'info',
  target: 'es2020',
  minify: true,
  minifyWhitespace: true,
  treeShaking: true,
  sourcemap: false,
  sourcesContent: false,
  bundle: true,
  charset: 'utf8',
  legalComments: 'linked',
  define: {
    __package_name__: packageJson.name,
    __package_version__: packageJson.version,
    __dev_mode__: process.env.NODE_ENV !== 'production',
  },
  banner: {
    js: "/* __package_name__ v__package_version__ */"
  },
}

--preset=module

Builds and bundle for single export module.

{
  ...defaultPreset,
  entryPoints: ['src/main.ts'],
  bundle: true,
  platform: 'node',
  format: 'esm',
  minify: false,
  cjs: true,
  packages: 'external',
  sourcemap: true,
  sourcesContent: true
}

Note: default production overwrite options not applied.

--preset=module2

Builds and bundles multiple entry points in root of src directory for multiple exports module.

{
  ...defaultPreset,
  entryPoints: ['src/*.ts'],
  bundle: true,
  platform: 'node',
  format: 'esm',
  minify: false,
  cjs: true,
  packages: 'external',
  sourcemap: true,
  sourcesContent: true
}

Note: default production overwrite options not applied.

--preset=module3

Builds multiple entry points in src directory for multiple exports module without bundling.

{
  ...defaultPreset,
  entryPoints: ['src/**/*.ts'],
  bundle: false,
  platform: 'node',
  format: 'esm',
  minify: false,
  cjs: true,
  packages: 'external',
  sourcemap: true,
  sourcesContent: true
}

Note: default production overwrite options not applied.

--preset=pwa

{
  ...defaultPreset,
  entryPoints: ['site/_ts/*.ts'],
  outdir: 'dist/es',
  platform: 'browser',
  format: 'iife',
  mangleProps: '_$',
  target: [
    'es2018',
    'chrome62',
    'edge79',
    'firefox78',
    'safari11',
  ],
  ...(devMode ? developmentOverwriteOptions : productionOverwriteOptions),
}

--preset=weaver

{
  ...defaultPreset,
  entryPoints: ['src/ts/*.ts'],
  outdir: 'dist/es',
  platform: 'browser',
  format: 'iife',
  mangleProps: '_$',
  target: [
    'es2018',
    'chrome62',
    'edge79',
    'firefox78',
    'safari11',
  ],
  ...(devMode ? developmentOverwriteOptions : productionOverwriteOptions),
}

--preset=microservice

{
  ...defaultPreset,
  entryPoints: ['src/ts/main.ts'],
  platform: 'node',
  format: 'esm',
  mangleProps: '_$',
  target: 'node20',
  ...(devMode ? developmentOverwriteOptions : productionOverwriteOptions),
}

--preset=pmpa

{
  ...defaultPreset,
  entryPoints: ['site/_ts/*.ts'],
  outdir: 'dist/es',
  platform: 'browser',
  format: 'iife',
  mangleProps: '_$',
  target: [
    'es2018',
    'chrome62',
    'edge79',
    'firefox78',
    'safari11',
  ],
  ...(devMode ? developmentOverwriteOptions : productionOverwriteOptions),
}

Development overwrite

This preset is used when NODE_ENV is not set to production. It overwrites all other presets.

{
  sourcemap: true,
  sourcesContent: true,
}

you can also add nano-build-development field to your package.json for overwriting configuration.

Production overwrite

This preset is used when NODE_ENV is set to production. It overwrites all other presets.

{
  dropLabels: ['__dev_mode__'];
}

you can also add nano-build-production field to your package.json for overwriting configuration.

Sponsors

The following companies, organizations, and individuals support Nanolib ongoing maintenance and development. Become a Sponsor to get your logo on our README and website.

Contributing

Contributions are welcome! Please read our contribution guidelines before submitting a pull request.

更新履歴

Change Log

All notable changes to this project will be documented in this file. See Conventional Commits for commit guidelines.

6.3.5 (2025-10-06)

🔗 Dependencies update

  • bump the npm-dependencies group with 4 updates (9825815)

6.3.4 (2025-09-27)

🧹 Miscellaneous Chores

  • exclude test files from package distribution (86f4f2f)

6.3.3 (2025-09-22)

Note: Version bump only for package @alwatr/nano-build

6.3.2 (2025-09-22)

Note: Version bump only for package @alwatr/nano-build

6.3.1 (2025-09-21)

🐛 Bug Fixes

  • change console.log to console.debug in banner for better logging (4aea838)
  • format banner string for better readability (2356fea)

6.3.0 (2025-09-20)

✨ Features

  • enhance banner message in default options with package info and logging (7121f21)

🐛 Bug Fixes

  • add sideEffects property to package.json files for better tree-shaking (c7b9e74)
  • add sideEffects property to package.json files for better tree-shaking (e8402c4)

🧹 Miscellaneous Chores

  • remove duplicate sideEffects property from multiple package.json files (b123f86)

6.2.1 (2025-09-19)

🐛 Bug Fixes

  • update esbuild to version 0.25.10 (3fcf5ba)

6.2.0 (2025-09-15)

✨ Features

  • enable minification of whitespace in default build options (8fc194f)

6.1.2 (2025-09-13)

🔗 Dependencies update

  • update @types/node version to ^22.18.3 in multiple package.json files (13db6fc)

6.1.1 (2025-09-09)

🧹 Miscellaneous Chores

  • remove trailing newlines from contributing sections in README files (e8ab1bc)

6.1.0 (2025-09-06)

✨ Features

  • nano-build: enhance logging with picocolors for better visibility (b7186ea)

🔨 Code Refactoring

  • remove types configuration for consistency with project standards (3028601)
  • update type definitions for BuildOptions for consistency and clarity (a8678b2)

6.0.3 (2025-09-05)

🐛 Bug Fixes

  • update target browsers in presetRecord to include Safari 15.6 (a448366)

🔗 Dependencies update

  • update jest to version 30.1.3 and @types/node to version 22.18.1 (754212b)

6.0.2 (2025-09-01)

🔗 Dependencies update

  • update lerna-lite dependencies to version 4.7.3 and jest to 30.1.2 (95d7870)

6.0.1 (2025-08-23)

Note: Version bump only for package @alwatr/nano-build

6.0.0 (2025-08-23)

⚠ BREAKING CHANGES

  • drop old browser supports in default configurations

✨ Features

  • update esbuild to v0.25.9 (3dccddd)
  • update target versions for default configurations (2d6463c)

🐛 Bug Fixes

  • update bin field in package.json and add shebang to nano-build.cjs (02dfbe7)
  • update bin field in package.json to a simpler format (6243f49)
  • update license from AGPL-3.0-only to MPL-2.0 (d20968e)
  • update package versions in multiple package.json files (7638b1c)

🔨 Code Refactoring

  • Updated all package.json files in the project to change dependency version specifiers from "workspace:^" to "workspace:*" for consistency and to allow for more flexible version resolution. (db6a4f7)

🧹 Miscellaneous Chores

  • reformat all package.json files (ceda45d)

🔗 Dependencies update

  • revert @types/node version to ^22.17.2 (LTS) (49f8101)

5.5.4 (2025-08-23)

Code Refactoring

  • Updated all package.json files in the project to change dependency version specifiers from "workspace:^" to "workspace:*" for consistency and to allow for more flexible version resolution. (db6a4f7) by @alimd

5.5.3 (2025-04-15)

Note: Version bump only for package @alwatr/nano-build

5.5.2 (2025-04-01)

Dependencies update

  • bump the development-dependencies group across 1 directory with 2 updates (c1320b4) by @dependabot[bot]

5.5.1 (2025-03-18)

Dependencies update

  • bump esbuild in the production-dependencies group (73b8002) by @dependabot[bot]
  • bump the development-dependencies group with 9 updates (7290aa3) by @dependabot[bot]

5.5.0 (2025-03-06)

Miscellaneous Chores

  • update username casing in changelog entries (9722ac9) by @

Dependencies update

  • bump the development-dependencies group across 1 directory with 11 updates (720c395) by @dependabot[bot]

5.4.0 (2025-02-18)

Dependencies update

  • bump @types/node from ^22.13.0 to ^22.13.4 and prettier from 3.4.2 to 3.5.1; update eslint-import-resolver-typescript to 3.8.2 (b9a8399) by @
  • bump esbuild from 0.24.2 to 0.25.0 (b9cdc08) by @dependabot[bot]

5.3.0 (2025-02-03)

Miscellaneous Chores

Dependencies update

  • bump esbuild in the production-dependencies group (97b1ced) by @
  • bump the development-dependencies group across 1 directory with 11 updates (cb79d07) by @
  • update typescript and @types/node to version 5.7.3 and 22.13.0 respectively across multiple packages (ddab05b) by @

5.0.0 (2024-11-02)

⚠ BREAKING CHANGES

  • To simplify version management and ensure consistency, all nanolib packages now use the same version as @alwatr/nanolib. This may require updates to your project's dependencies.

Code Refactoring

  • use the same version as @alwatr/nanolib (60eb860) by @

5.3.0 (2025-02-03)

Miscellaneous Chores

  • edit README (3860b3d) by @ArmanAsadian

Dependencies update

  • bump esbuild in the production-dependencies group (97b1ced) by @dependabot[bot]
  • bump the development-dependencies group across 1 directory with 11 updates (cb79d07) by @dependabot[bot]
  • update typescript and @types/node to version 5.7.3 and 22.13.0 respectively across multiple packages (ddab05b) by @alimd

5.0.0 (2024-11-02)

⚠ BREAKING CHANGES

  • To simplify version management and ensure consistency, all nanolib packages now use the same version as @alwatr/nanolib. This may require updates to your project's dependencies.
  • nano-build: heads up all presets options changed, please double check the readme and your build output.

Features

  • nano-build: package_version types (7894c4b) by @
  • nano-build: Add dev_mode global variable (a8f7e63) by @
  • nano-build: add weaver configs(--preset=weaver) (1bae458) by @
  • nano-build: Add presets for module bundling (158dfec) by @
  • nano-build: define __package_name__ (d071d0b) by @
  • nano-build: microservice preset (3b464d5) by @
  • nano-build: new package for esbuild (224a09e) by @
  • nano-build: Refactor build options and add presets (c24f0b7) by @
  • nano-lib: enhance console.log statements (92f9b2a) by @
  • prettier-config: new package for prettier share configs (a6fdee3) by @
  • Update nano-build options and presets (293598e) by @

Bug Fixes

  • nano-build: Add check for package.json existence (2a95315) by @
  • nano-build: entry point of microservice preset (e5e4826) by @
  • nano-build: error messages (e95b497) by @
  • nano-build: mangle with 2 underline in module (bb7b18d) by @
  • nano-build: remove mangleProps temporary (65d95cc) by @
  • nano-build: root fn name (adf7b8f) by @
  • nano-build: target versions in presets (b73cb26) by @
  • package.json include files (ec8c807) by @
  • package.json include files (053fc10) by @
  • refactor nano-build.cjs to include microservice preset and update all presets configs (3f662b8) by @

Code Refactoring

  • nano-build: Update all presets options (91bdf90) by @
  • use the same version as @alwatr/nanolib (60eb860) by @

Miscellaneous Chores

  • Add tsconfig.json for nano-build package (8b47c2d) by @
  • deps: bump the production-dependencies group with 1 update (8abc6ab) by @
  • deps: update (1a45030) by @
  • include LICENSE and LEGAL files to publish (09f366f) by @
  • nano-build: change the license to AGPL-3.0 (57e1d8f) by @
  • switch to alwatr prettier configuration (4426288) by @
  • update clean script to remove all .tsbuildinfo files (91f1ff2) by @
  • Update devDependencies in nano-build package.json (c900c09) by @
  • Update file patterns in package.json (1f478e7) by @
  • Update nano-build options and presets (8b2bc3a) by @
  • Update nano-build README.md (f641961) by @
  • Update nano-build script to display mode information (7a76f2a) by @
  • update package keywords (200afcf) by @

Dependencies update

  • bump esbuild (78d8552) by @
  • bump esbuild in the production-dependencies group (d829afb) by @
  • bump esbuild in the production-dependencies group (1dffb4f) by @
  • bump the development-dependencies group across 1 directory with 10 updates (9ed98ff) by @
  • bump the development-dependencies group across 1 directory with 2 updates (2dfda9e) by @
  • bump the development-dependencies group with 10 updates (fa4aaf0) by @
  • bump the development-dependencies group with 8 updates (16847ac) by @
  • bump the production-dependencies group with 1 update (85a0693) by @
  • upd (451d025) by @
  • update (4434ba6) by @
  • update all (53342f6) by @
  • update all dependencies (1e0c30e) by @
  • update all dependencies (0e908b4) by @

2.0.4 (2024-11-02)

Dependencies update

2.0.3 (2024-10-25)

Dependencies update

  • bump the development-dependencies group across 1 directory with 2 updates (2dfda9e) by @dependabot[bot]
  • bump the development-dependencies group with 8 updates (16847ac) by @dependabot[bot]

2.0.2 (2024-10-12)

Bug Fixes

  • nano-build: entry point of microservice preset (e5e4826) by @mohammadhonarvar

2.0.1 (2024-10-11)

Miscellaneous Chores

  • include LICENSE and LEGAL files to publish (09f366f) by @alimd

2.0.0 (2024-10-11)

⚠ BREAKING CHANGES

  • nano-build: heads up all presets options changed, please double check the readme and your build output.

Features

  • nano-build: Add presets for module bundling (158dfec) by @alimd

Code Refactoring

  • nano-build: Update all presets options (91bdf90) by @alimd

1.6.0 (2024-10-10)

Features

  • nano-build: Add dev_mode global variable (a8f7e63) by @alimd
  • Update nano-build options and presets (293598e) by @alimd

Miscellaneous Chores

  • Add tsconfig.json for nano-build package (8b47c2d) by @alimd
  • Update devDependencies in nano-build package.json (c900c09) by @alimd
  • Update nano-build options and presets (8b2bc3a) by @alimd
  • Update nano-build README.md (f641961) by @alimd
  • Update nano-build script to display mode information (7a76f2a) by @alimd

Dependencies update

  • bump the development-dependencies group with 10 updates (fa4aaf0) by @dependabot[bot]

1.5.0 (2024-10-08)

Features

  • nano-build: add weaver configs(--preset=weaver) (1bae458) by @mohammadhonarvar

1.4.0 (2024-09-29)

Features

  • nano-build: define __package_name__ (d071d0b) by @mohammadhonarvar

Miscellaneous Chores

  • nano-build: change the license to AGPL-3.0 (57e1d8f) by @ArmanAsadian

Dependencies update

  • bump esbuild in the production-dependencies group (d829afb) by @dependabot[bot]

1.3.10 (2024-09-21)

Bug Fixes

  • nano-build: remove mangleProps temporary (65d95cc) by @mohammadhonarvar

1.3.9 (2024-09-15)

Dependencies update

  • bump the development-dependencies group across 1 directory with 10 updates (9ed98ff) by @dependabot[bot]

1.3.8 (2024-08-31)

Dependencies update

  • update all dependencies (1e0c30e) by @alimd

1.3.7 (2024-07-04)

Dependencies update

  • bump esbuild (78d8552) by @dependabot[bot]
  • update all dependencies (0e908b4) by @

1.3.6 (2024-05-12)

Dependencies update

  • bump esbuild in the production-dependencies group (1dffb4f) by @dependabot[bot]

1.3.5 (2024-04-25)

Note: Version bump only for package @alwatr/nano-build

1.3.4 (2024-03-28)

Note: Version bump only for package @alwatr/nano-build

1.3.3 (2024-01-31)

Miscellaneous Chores

1.3.2 (2024-01-24)

Note: Version bump only for package @alwatr/nano-build

1.3.1 (2024-01-16)

Note: Version bump only for package @alwatr/nano-build

1.3.0 (2024-01-03)

Features

  • nano-build: __package_version__ types (7894c4b) by @njfamirm

1.2.3 (2024-01-03)

Note: Version bump only for package @alwatr/nano-build

1.2.2 (2023-12-26)

Bug Fixes

  • nano-build: mangle with 2 underline in module (bb7b18d) by @njfamirm

1.2.1 (2023-12-23)

Note: Version bump only for package @alwatr/nano-build

1.2.0 (2023-12-23)

Bug Fixes

  • refactor nano-build.cjs to include microservice preset and update all presets configs (3f662b8) by @alimd

Features

  • nano-build: microservice preset (3b464d5) by @njfamirm

1.1.1 (2023-12-23)

Bug Fixes

  • nano-build: target versions in presets (b73cb26) by @

1.1.0 (2023-12-23)

Bug Fixes

  • nano-build: Add check for package.json existence (2a95315) by @alimd
  • nano-build: error messages (e95b497) by @alimd
  • nano-build: root fn name (adf7b8f) by @alimd

Features

  • nano-build: Refactor build options and add presets (c24f0b7) by @alimd
  • nano-lib: enhance console.log statements (92f9b2a) by @alimd

1.0.4 (2023-12-22)

Note: Version bump only for package @alwatr/nano-build

1.0.3 (2023-12-22)

Bug Fixes

  • package.json include files (ec8c807) by @

1.0.2 (2023-12-22)

Bug Fixes

  • package.json include files (053fc10) by @alimd

1.0.1 (2023-12-21)

Features

  • prettier-config: new package for prettier share configs (a6fdee3) by @alimd

1.0.0 (2023-12-20)

Features

  • nano-build: new package for esbuild (224a09e) by @alimd