Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,18 @@ end

## npm package

This repo also publishes `@bikeindex/time-localizer`, an npm package for localizing time elements in the browser. Luxon is bundled into the published package, so consumers don't need to install it separately.
This repo also publishes `@bikeindex/time-localizer`, an npm package for localizing time elements in the browser. It ships two builds of the same source:

To publish a new version: update the version in `package.json`, then run `npm publish` from the repo root (requires npm login with access to the `@bikeindex` scope). The `prepublishOnly` script automatically builds `dist/index.js` before publishing.
| Build | Luxon | Use when |
| --- | --- | --- |
| `dist/index.js` (default) | external — install it yourself | You have a bundler. Luxon stays deduped with your own copy, so `Settings.defaultLocale`, `Settings.now` etc. apply to both. |
| `dist/index.bundle.js` | bundled in | You have no bundler (e.g. importmap-rails). One request, nothing to resolve. |

Import the default as `@bikeindex/time-localizer` and the standalone as `@bikeindex/time-localizer/bundle`, or reference either file path directly over a CDN.

Don't use the bundled build alongside your own Luxon: you'd ship two copies, and because Luxon's `Settings` are module-scoped, your global config would silently apply to only one of them.

To publish a new version: update the version in `package.json`, then run `npm publish` from the repo root (requires npm login with access to the `@bikeindex` scope). The `prepublishOnly` script builds both artifacts before publishing.

## Releasing

Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 8 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
{
"name": "@bikeindex/time-localizer",
"version": "0.3.0",
"version": "0.4.0",
"description": "Localizes time elements to the user's timezone using Luxon",
"type": "module",
"main": "dist/index.js",
"exports": {
".": "./dist/index.js"
".": "./dist/index.js",
"./bundle": "./dist/index.bundle.js"
},
"files": [
"dist/index.js"
"dist/index.js",
"dist/index.bundle.js"
],
"scripts": {
"build": "esbuild index.js --bundle --format=esm --minify --external:luxon --outfile=dist/index.js",
"build": "npm run build:esm && npm run build:bundle",
"build:esm": "esbuild index.js --bundle --format=esm --minify --external:luxon --outfile=dist/index.js",
"build:bundle": "esbuild index.js --bundle --format=esm --minify --outfile=dist/index.bundle.js",
"prepublishOnly": "npm run build",
"test": "vitest run"
},
Expand Down
Loading