diff --git a/README.md b/README.md index 847c4f6..5920b9a 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/package-lock.json b/package-lock.json index f09631a..e59c4b6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@bikeindex/time-localizer", - "version": "0.3.0", + "version": "0.4.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@bikeindex/time-localizer", - "version": "0.3.0", + "version": "0.4.0", "license": "MIT", "devDependencies": { "esbuild": "^0.28.0", diff --git a/package.json b/package.json index 76871b2..7bb5c49 100644 --- a/package.json +++ b/package.json @@ -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" },