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
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,9 @@ The browserlist we are currently using is available in the [rollup.config.mjs](.

### On build outputs

We only output ESM modules.
We only output ESM modules. Please [read this](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c).

Compiled modules supports Node > 14, the last two versions of any browsers and any browsers with more than 1% of marketshare at the time of release.

### On commits

Expand Down
4 changes: 4 additions & 0 deletions packages/jest-helpers/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
"version": "2.0.25",
"description": "A package for utilities jest functions",
"type": "module",
"engines": {
"node": ">=14.x"
},
"sideEffects": false,
"main": "dist/index.js",
"module": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down
6 changes: 3 additions & 3 deletions packages/outdated-browser/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
"version": "1.2.1",
"description": "A small web script to display outdated banner",
"type": "module",
"engines": {
"node": ">=14.x"
},
"main": "dist/index.js",
"module": "dist/index.js",
"types": "dist/index.d.ts",
"browser": {
"dist/index.js": "./dist/index.browser.js"
},
"publishConfig": {
"access": "public"
},
Expand Down
8 changes: 4 additions & 4 deletions packages/random-name/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
"version": "3.0.3",
"description": "A small utility to generate a random name",
"type": "module",
"engines": {
"node": ">=14.x"
},
"sideEffects": false,
"main": "dist/index.js",
"module": "dist/index.js",
"types": "dist/index.d.ts",
"sideEffects": false,
"browser": {
"dist/index.js": "./dist/index.browser.js"
},
"publishConfig": {
"access": "public"
},
Expand Down
8 changes: 4 additions & 4 deletions packages/regex/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
"version": "2.9.1",
"description": "A small utility to use regex",
"type": "module",
"engines": {
"node": ">=14.x"
},
"sideEffects": false,
"main": "dist/index.js",
"module": "dist/index.js",
"types": "dist/index.d.ts",
"sideEffects": false,
"browser": {
"dist/index.js": "./dist/index.browser.js"
},
"publishConfig": {
"access": "public"
},
Expand Down
8 changes: 4 additions & 4 deletions packages/use-dataloader/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
"dataloader"
],
"type": "module",
"engines": {
"node": ">=14.x"
},
"sideEffects": false,
"main": "dist/index.js",
"module": "dist/index.js",
"types": "dist/index.d.ts",
"sideEffects": false,
"browser": {
"dist/index.js": "./dist/index.browser.js"
},
"publishConfig": {
"access": "public"
},
Expand Down
8 changes: 4 additions & 4 deletions packages/use-gtm/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@
"gtm"
],
"type": "module",
"engines": {
"node": ">=14.x"
},
"sideEffects": false,
"main": "dist/index.js",
"module": "dist/index.js",
"types": "dist/index.d.ts",
"sideEffects": false,
"browser": {
"dist/index.js": "./dist/index.browser.js"
},
"publishConfig": {
"access": "public"
},
Expand Down
8 changes: 4 additions & 4 deletions packages/use-i18n/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@
"react-intl"
],
"type": "module",
"engines": {
"node": ">=14.x"
},
"sideEffects": false,
"main": "dist/index.js",
"module": "dist/index.js",
"types": "dist/index.d.ts",
"sideEffects": false,
"browser": {
"dist/index.js": "./dist/index.browser.js"
},
"publishConfig": {
"access": "public"
},
Expand Down
8 changes: 4 additions & 4 deletions packages/use-media/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
"media queries"
],
"type": "module",
"engines": {
"node": ">=14.x"
},
"sideEffects": false,
"main": "dist/index.js",
"module": "dist/index.js",
"types": "dist/index.d.ts",
"sideEffects": false,
"browser": {
"dist/index.js": "./dist/index.browser.js"
},
"publishConfig": {
"access": "public"
},
Expand Down
8 changes: 4 additions & 4 deletions packages/use-query-params/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@
"query-params"
],
"type": "module",
"engines": {
"node": ">=14.x"
},
"sideEffects": false,
"main": "dist/index.js",
"module": "dist/index.js",
"types": "dist/index.d.ts",
"sideEffects": false,
"browser": {
"dist/index.js": "./dist/index.browser.js"
},
"publishConfig": {
"access": "public"
},
Expand Down
8 changes: 4 additions & 4 deletions packages/use-random-name/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
"version": "0.2.6",
"description": "A small react utility to generate a random name",
"type": "module",
"engines": {
"node": ">=14.x"
},
"sideEffects": false,
"main": "dist/index.js",
"module": "dist/index.js",
"types": "dist/index.d.ts",
"sideEffects": false,
"browser": {
"dist/index.js": "./dist/index.browser.js"
},
"publishConfig": {
"access": "public"
},
Expand Down
5 changes: 1 addition & 4 deletions packages/use-segment/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,10 @@
"segment"
],
"type": "module",
"sideEffects": false,
"main": "dist/index.js",
"module": "dist/index.js",
"types": "dist/index.d.ts",
"sideEffects": false,
"browser": {
"dist/index.js": "./dist/index.browser.js"
},
"publishConfig": {
"access": "public"
},
Expand Down
8 changes: 4 additions & 4 deletions packages/use-storage/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
"version": "1.1.3",
"description": "A React hook to interact with local/session storage in reactive way",
"type": "module",
"engines": {
"node": ">=14.x"
},
"sideEffects": false,
"main": "dist/index.js",
"module": "dist/index.js",
"types": "dist/index.d.ts",
"sideEffects": false,
"browser": {
"dist/index.js": "./dist/index.browser.js"
},
"publishConfig": {
"access": "public"
},
Expand Down
3 changes: 3 additions & 0 deletions packages/validate-icu-locales/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
"cli"
],
"type": "module",
"engines": {
"node": ">=14.x"
},
"bin": {
"validate-icu": "dist/index.js"
},
Expand Down
63 changes: 26 additions & 37 deletions rollup.config.mjs
Original file line number Diff line number Diff line change
@@ -1,36 +1,37 @@
import { babel } from '@rollup/plugin-babel'
import { nodeResolve } from '@rollup/plugin-node-resolve'
import builtins from 'builtin-modules'
import { readPackage } from 'read-pkg'
import dts from 'rollup-plugin-dts'
import { preserveShebangs } from 'rollup-plugin-preserve-shebangs'
import { visualizer } from 'rollup-plugin-visualizer'

const PROFILE = !!process.env.PROFILE

const getConfig = (pkg, isBrowser = false) => {
const targets = isBrowser
? `
> 1%,
last 2 versions,
not IE > 0,
not IE_Mob > 0
`
: { node: 'current' }
const pkg = await readPackage()

const external = id =>
[
...Object.keys(pkg.dependencies || {}),
...Object.keys(pkg.peerDependencies || {}),
...(isBrowser ? [] : builtins),
].find(dep => new RegExp(`^${dep}`).test(id))
const targets = `
> 1%,
last 2 versions,
not IE > 0,
not IE_Mob > 0
node > 14
`

return {
const external = id =>
[
...Object.keys(pkg.dependencies || {}),
...Object.keys(pkg.peerDependencies || {}),
...[],
].find(dep => new RegExp(`^${dep}`).test(id))

export default [
{
external,
input: './src/index.ts',
output: {
file: isBrowser ? 'dist/index.browser.js' : 'dist/index.js',
dir: 'dist',
format: 'es',
preserveModules: true
},
plugins: [
babel({
Expand All @@ -52,7 +53,6 @@ const getConfig = (pkg, isBrowser = false) => {
],
}),
nodeResolve({
browser: isBrowser,
extensions: ['.mjs', '.js', '.json', '.ts', '.tsx'],
preferBuiltins: true,
}),
Expand All @@ -65,21 +65,10 @@ const getConfig = (pkg, isBrowser = false) => {
open: true,
}),
].filter(Boolean),
}
}

export default async () => {
const pkg = await readPackage()

const doesAlsoTargetBrowser = 'browser' in pkg

return [
getConfig(pkg),
doesAlsoTargetBrowser && getConfig(pkg, true),
{
input: './src/index.ts',
output: [{ file: 'dist/index.d.ts', format: 'es' }],
plugins: [dts()],
},
].filter(Boolean)
}
},
{
input: './src/index.ts',
output: [{ file: 'dist/index.d.ts', format: 'es' }],
plugins: [dts()],
},
]