Skip to content

Add multi-format build targets, conditional exports map, and automatic headless entry point for Node.js#26

Open
mvanderkamp with Copilot wants to merge 1 commit into
mainfrom
copilot/audit-release-configuration
Open

Add multi-format build targets, conditional exports map, and automatic headless entry point for Node.js#26
mvanderkamp with Copilot wants to merge 1 commit into
mainfrom
copilot/audit-release-configuration

Conversation

Copilot AI commented Apr 11, 2026

Copy link
Copy Markdown

The package previously shipped a single dist/index.js CJS bundle with no exports map, no ESM target, and no ergonomic headless support for server-side consumers.

Changes

package.json

  • Replaces "main": "dist/index.js" with four Parcel 2 targets:
    • "main"dist/westures.cjs.js (CJS, Node ≥12)
    • "module"dist/westures.esm.js (ESM, tree-shaking)
    • "browser"dist/westures.umd.js (IIFE global window.westures)
    • "nodeHeadless"dist/westures.node.cjs.js (headless CJS — required by Parcel as the output path for the custom target)
  • Adds "exports" conditional map; "node" condition is ordered first so all Node.js consumers (both require and import) receive the headless build automatically:
    "exports": {
      ".": {
        "node":    "./dist/westures.node.cjs.js",
        "import":  "./dist/westures.esm.js",
        "require": "./dist/westures.cjs.js",
        "browser": "./dist/westures.umd.js"
      }
    }
  • Adds "targets" block with outputFormat, isLibrary, optimize, and engines per target; the nodeHeadless target overrides "source" to point at index.headless.js.

index.headless.js (new)

Thin re-export of index.js with a Region subclass that defaults headless: true. Users can still opt out per-region with { headless: false }.

// Node.js — headless is automatic, no code change needed
const { Region, Pan } = require('westures');
const region = new Region(); // headless: true by default

// Override when a DOM is available
const domRegion = new Region(element, { headless: false });

README.md

Adds an "Installation & Import" section documenting all three consumption patterns: bundler (ESM), <script> tag (UMD), and Node.js headless (CJS).

CHANGELOG.md

Adds v1.2.0 entry.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR modernizes the published package interface by adding multiple Parcel build targets (CJS/ESM/UMD), introducing a conditional exports map, and adding a Node-oriented headless entry point that overrides Region defaults. It also updates documentation and the changelog to reflect the new consumption patterns.

Changes:

  • Add Parcel targets for CJS (main), ESM (module), global/UMD (browser), and a custom Node headless CJS target.
  • Add exports conditional mapping to select bundles by environment.
  • Add index.headless.js entry and document install/import patterns in README.md, with a new changelog entry.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 6 comments.

File Description
README.md Adds “Installation & Import” docs and Node headless usage guidance.
package.json Introduces multi-target outputs and a conditional exports map.
index.headless.js Adds a headless Node entry that re-exports everything and overrides Region default options.
CHANGELOG.md Adds a new 1.2.0 release entry describing these distribution changes.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread README.md
Comment thread package.json
Comment on lines +29 to +35
"exports": {
".": {
"node": "./dist/westures.node.cjs.js",
"import": "./dist/westures.esm.js",
"require": "./dist/westures.cjs.js",
"browser": "./dist/westures.umd.js"
}
Comment thread package.json
Comment on lines +25 to +28
"main": "dist/westures.cjs.js",
"module": "dist/westures.esm.js",
"browser": "dist/westures.umd.js",
"nodeHeadless": "dist/westures.node.cjs.js",
Comment thread index.headless.js
Comment on lines +15 to +23
const base = require('./index.js');

class Region extends base.Region {
constructor(element, options = {}) {
super(element, { headless: true, ...options });
}
}

module.exports = { ...base, Region };
Comment thread CHANGELOG.md
Comment thread README.md
Comment on lines +124 to +125
// ES module in Node.js — same headless default
import { Region, Pan } from 'westures';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants