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

@dhi-gras/builder

v1.6.5

Published

`builder` is a shared [webpack](https://webpack.js.org/) configuration, and scripts for running a dev server and building/bundling application code.

Downloads

119

Readme

builder

builder is a shared webpack configuration, and scripts for running a dev server and building/bundling application code.

It currently resembles the start and build script functionality of the create-react-app package.

Installation and usage

  1. Install
yarn add -D @dhi-gras/builder
  1. Add & use scripts

Add to project package.json scripts

"build": "builder build",
"start": "builder start"
  1. Add hot reload Not required to use the builder. If omitted, hot module replacement will not work and the webpage will be fully refreshed on save.

Install hot reload packages

yarn add -D react-hot-loader

Modify application code (suggested syntax)

// App .tsx
import { hot } from 'react-hot-loader/root' // eslint-disable-line import/no-extraneous-dependencies

// ... App component ...

const isEnvDev = process.env.NODE_ENV === 'development'
export default isEnvDev ? hot(App) : App
  1. Run the scripts

Features / functionality

Only functionality that is specific to the builder will be covered here.

.env file integration

Environment variables specified in a .env file in the project root will be accessible to the application.

System environment variables

Only environment variables prefixed with APP_ (preffered) or REACT_APP will be accessible to the application.

Static files dir

Files placed in a directory named static in the project root will be copied to the output directory, named dist by default.

This can be useful for images and files that you don't wish to bundle in output JS files.

The files can be fetched via GET requests or used directly in a src attribute.
Specifying host is not required in most cases (when you're requesting the file from the same host name): /image.png
Otherwise, specify the full URL, and keep in mind that the url must be updated apropriately if the site is located in a subdirectory.

Sentry source map upload and release tagging

Note: This does not work out of the box! See setup below.

Source maps can be uploaded to Sentry projects. This allows sentry to display stack traces relevant to the source code.
This works in conjunction with specifiying releases - so you also see which release/build/commit the error occured.

Setup requirements

  • Add release: COMMIT_SHA in the Sentry.init object argument in your app source.
  • Ensure the COMMIT_SHA environment variable is accessible to builder. The azure-multi-deploy action does this out of the box.
  • Ensure the SENTRY_PROJECT, SENTRY_ORG, SENTRY_AUTH_TOKEN environment variables are accessible to the builder prior to building the app, either as system variables or in a .env file in the project root Alternatively, you can add these settings in a .sentryclirc file, but note the different syntax.

Note: it is recommended to use an organization wide Sentry auth token. To access it, go to Organization Settings > Developer Settings > Internal Integrations. Use the token from the integration.

Motivation

  • Minimal and customizable - we can adapt the bundler config to our project and development workflow needs
  • Module bundler agnostic - while we currently use only webpack, we can use any module bundler or use multiple
  • We decide what features to enable or try out - for example, if there's a new ES version we'd like to try out or support before general adoption
  • Valuable skill - understanding how JavaScript is bundled, transpiled, etc. is easier when you can easily see and change the configuration

Drawback

We have to maintain the build utility and keep it up to date ourselves.
This requires developers to be interested in maintaining and learning about the utility and module bundling and similar concepts.