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
20 changes: 9 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,35 +1,33 @@
# autopublish-template
# react-is

[![npm version](https://img.shields.io/npm/v/@esm-bundle/autopublish-template.svg?style=flat)](https://www.npmjs.com/package/@esm-bundle/autopublish-template) [![build status](https://travis-ci.com/esm-bundle/autopublish-template.svg?branch=master)](https://travis-ci.com/esm-bundle/autopublish-template) [![](https://data.jsdelivr.com/v1/package/npm/@esm-bundle/autopublish-template/badge)](https://www.jsdelivr.com/package/npm/@esm-bundle/autopublish-template)
[![npm version](https://img.shields.io/npm/v/@esm-bundle/react-is.svg?style=flat)](https://www.npmjs.com/package/@esm-bundle/react-is) [![build status](https://travis-ci.com/esm-bundle/react-is.svg?branch=master)](https://travis-ci.com/esm-bundle/react-is) [![](https://data.jsdelivr.com/v1/package/npm/@esm-bundle/react-is/badge)](https://www.jsdelivr.com/package/npm/@esm-bundle/react-is)

["What is this" blog post](https://medium.com/@joeldenning/an-esm-bundle-for-any-npm-package-5f850db0e04d)

[Instructions for creating a new esm-bundle repo](https://github.com/esm-bundle/new-repo-instructions)

A repo that tests automatic detection of upstream publishes and the publishing of `@esm-bundle` versions of them.

Upstream repo at https://github.com/joeldenning/autopublish-template.
Upstream repo at https://www.npmjs.com/package/react-is

## JS Delivr

https://cdn.jsdelivr.net/npm/@esm-bundle/autopublish-template/esm/index.js
https://cdn.jsdelivr.net/npm/@esm-bundle/react-is/esm/index.js

https://cdn.jsdelivr.net/npm/@esm-bundle/autopublish-template/system/index.js
https://cdn.jsdelivr.net/npm/@esm-bundle/react-is/system/index.js

## Unpkg

https://unpkg.com/@esm-bundle/autopublish-template/esm/index.js
https://unpkg.com/@esm-bundle/react-is/esm/index.js

https://unpkg.com/@esm-bundle/autopublish-template/system/index.js
https://unpkg.com/@esm-bundle/react-is/system/index.js

## Npm

```sh
npm install --save autopublish-template@npm:@esm-bundle/autopublish-template
npm install --save react-is@npm:@esm-bundle/react-is
```

## Yarn

```sh
yarn add autopublish-template@npm:@esm-bundle/autopublish-template
yarn add react-is@npm:@esm-bundle/react-is
```
42 changes: 37 additions & 5 deletions browser-test/test.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,41 @@
describe("@esm-bundle/autopublish-template", () => {
it("can load the ESM bundle", () => {
return import("/base/esm/index.js");
describe("@esm-bundle/react-is", () => {
it("can load the production ESM bundle", () => {
return import("/base/esm/react-is.production.min.js");
});

it("can load the System.register bundle", () => {
return System.import("/base/system/index.js");
it("can load the development ESM bundle", () => {
return import("/base/esm/react-is.development.js");
});

it("can load the production System.register bundle", () => {
return System.import("/base/system/react-is.production.min.js").then(
(module) => {
expect(module.default).toBeDefined();
expect(module.__esModule).toBeDefined();
// Named export
expect(typeof module.isValidElementType).toBe("function");
// Default export
expect(typeof module.default.isValidElementType).toBe("function");
// Non function export
expect(module.default.Element).toBeDefined();
expect(module.Element).toBeDefined();
}
);
});

it("can load the development System.register bundle", () => {
return System.import("/base/system/react-is.development.js").then(
(module) => {
expect(module.default).toBeDefined();
expect(module.__esModule).toBeDefined();
// Named export
expect(typeof module.isValidElementType).toBe("function");
// Default export
expect(typeof module.default.isValidElementType).toBe("function");
// Non function export
expect(module.default.Element).toBeDefined();
expect(module.Element).toBeDefined();
}
);
});
});
30 changes: 27 additions & 3 deletions node-test/main.test.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,29 @@
describe("@esm-bundle/autopublish-template", () => {
it("can load the esm bundle without dying", () => {
return import("../esm/index.js");
describe("@esm-bundle/react-is", () => {
it("can load the production esm bundle without dying", () => {
return import("../esm/react-is.production.min.js");
});

it("can load the development esm bundle without dying", () => {
return import("../esm/react-is.development.js");
});

it(`API exports are defined in production bundle`, async () => {
const { default: ReactIs, isValidElementType, Element } = await import(
"../esm/react-is.production.min.js"
);
expect(ReactIs.isValidElementType).not.to.equal(undefined);
expect(isValidElementType).not.to.equal(undefined);
expect(ReactIs.Element).not.to.equal(undefined);
expect(Element).not.to.equal(undefined);
});

it(`API exports are defined in development bundle`, async () => {
const { default: ReactIs, isValidElementType, Element } = await import(
"../esm/react-is.development.js"
);
expect(ReactIs.isValidElementType).not.to.equal(undefined);
expect(isValidElementType).not.to.equal(undefined);
expect(ReactIs.Element).not.to.equal(undefined);
expect(Element).not.to.equal(undefined);
});
});
18 changes: 10 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@esm-bundle/autopublish-template",
"version": "20.0.0",
"description": "Repo to test esm-bundle's automatic publishing",
"name": "@esm-bundle/react-is",
"version": "16.13.1",
"description": "Repo to auto-esm-bundle react-is",
"main": "index.js",
"module": "esm/index.js",
"type": "module",
Expand All @@ -27,16 +27,18 @@
],
"repository": {
"type": "git",
"url": "git+https://github.com/esm-bundle/autopublish-template.git"
"url": "git+https://github.com/esm-bundle/react-is.git"
},
"author": "",
"license": "MIT",
"bugs": {
"url": "https://github.com/esm-bundle/autopublish-template/issues"
"url": "https://github.com/esm-bundle/react-is/issues"
},
"homepage": "https://github.com/esm-bundle/autopublish-template#readme",
"homepage": "https://github.com/esm-bundle/react-is#readme",
"devDependencies": {
"autopublish-template": "20.0.0",
"esm-bundle-scripts": "1.2.0"
"@rollup/plugin-node-resolve": "^8.4.0",
"@rollup/plugin-replace": "^2.3.3",
"esm-bundle-scripts": "1.2.0",
"react-is": "^16.13.1"
}
}
29 changes: 24 additions & 5 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,36 @@
import resolve from "@rollup/plugin-node-resolve";
import commonjs from "@rollup/plugin-commonjs";
import replace from "@rollup/plugin-replace";
import { terser } from "rollup-plugin-terser";

function createConfig(format) {
function createConfig(format, env) {
const dir = format === "module" ? "esm" : format;
const isProd = env === "production";
const suffix = isProd ? ".production.min" : ".development";
return {
input: require.resolve("autopublish-template"),
input: `src/index.js`,
output: {
file: `${dir}/index.js`,
file: `${dir}/react-is${suffix}.js`,
sourcemap: true,
format,
exports: "named",
},
plugins: [commonjs(), terser()],
plugins: [
resolve(),
commonjs(),
replace({
values: {
"process.env.NODE_ENV": JSON.stringify(env),
},
}),
isProd && terser(),
].filter(Boolean),

Choose a reason for hiding this comment

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

I think this is actually unnecessary - rollup will automatically filter out falsy plugin values. See https://rollupjs.org/guide/en/#plugins

};
}

export default [createConfig("module"), createConfig("system")];
export default [
createConfig("module", "development"),
createConfig("module", "production"),
createConfig("system", "development"),
createConfig("system", "production"),
];
5 changes: 5 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import ReactIs from "react-is";

export default ReactIs;
export * from "react-is/cjs/react-is.production.min.js";
export const __esModule = true;
60 changes: 52 additions & 8 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -591,6 +591,27 @@
is-module "^1.0.0"
resolve "^1.14.2"

"@rollup/plugin-node-resolve@^8.4.0":
version "8.4.0"
resolved "https://registry.yarnpkg.com/@rollup/plugin-node-resolve/-/plugin-node-resolve-8.4.0.tgz#261d79a680e9dc3d86761c14462f24126ba83575"
integrity sha512-LFqKdRLn0ShtQyf6SBYO69bGE1upV6wUhBX0vFOUnLAyzx5cwp8svA0eHUnu8+YU57XOkrMtfG63QOpQx25pHQ==
dependencies:
"@rollup/pluginutils" "^3.1.0"
"@types/resolve" "1.17.1"
builtin-modules "^3.1.0"
deep-freeze "^0.0.1"
deepmerge "^4.2.2"
is-module "^1.0.0"
resolve "^1.17.0"

"@rollup/plugin-replace@^2.3.3":
version "2.3.3"
resolved "https://registry.yarnpkg.com/@rollup/plugin-replace/-/plugin-replace-2.3.3.tgz#cd6bae39444de119f5d905322b91ebd4078562e7"
integrity sha512-XPmVXZ7IlaoWaJLkSCDaa0Y6uVo5XQYHhiMFzOd5qSv5rE+t/UJToPIOE56flKIxBFQI27ONsxb7dqHnwSsjKQ==
dependencies:
"@rollup/pluginutils" "^3.0.8"
magic-string "^0.25.5"

"@rollup/pluginutils@^3.0.8":
version "3.0.9"
resolved "https://registry.yarnpkg.com/@rollup/pluginutils/-/pluginutils-3.0.9.tgz#aa6adca2c45e5a1b950103a999e3cddfe49fd775"
Expand All @@ -600,6 +621,15 @@
estree-walker "^1.0.1"
micromatch "^4.0.2"

"@rollup/pluginutils@^3.1.0":
version "3.1.0"
resolved "https://registry.yarnpkg.com/@rollup/pluginutils/-/pluginutils-3.1.0.tgz#706b4524ee6dc8b103b3c995533e5ad680c02b9b"
integrity sha512-GksZ6pr6TpIjHm8h9lSQ8pi8BE9VeubNT0OMJ3B5uZJ8pz73NPiqOtCog/x2/QzM1ENChPKxMDhiQuRHsqc+lg==
dependencies:
"@types/estree" "0.0.39"
estree-walker "^1.0.1"
picomatch "^2.2.2"

"@sindresorhus/is@^0.14.0":
version "0.14.0"
resolved "https://registry.yarnpkg.com/@sindresorhus/is/-/is-0.14.0.tgz#9fb3a3cf3132328151f353de4632e01e52102bea"
Expand Down Expand Up @@ -748,6 +778,13 @@
dependencies:
"@types/node" "*"

"@types/resolve@1.17.1":
version "1.17.1"
resolved "https://registry.yarnpkg.com/@types/resolve/-/resolve-1.17.1.tgz#3afd6ad8967c77e4376c598a82ddd58f46ec45d6"
integrity sha512-yy7HuzQhj0dhGpD8RLXSZWEkLsV9ibvxvi6EiJ3bkqLAO1RGo0WbkWQiwpRlSFymTJRz0d3k5LM3kkx8ArDbLw==
dependencies:
"@types/node" "*"

"@types/responselike@*":
version "1.0.0"
resolved "https://registry.yarnpkg.com/@types/responselike/-/responselike-1.0.0.tgz#251f4fe7d154d2bad125abe1b429b23afd262e29"
Expand Down Expand Up @@ -996,11 +1033,6 @@ atob@^2.1.2:
resolved "https://registry.yarnpkg.com/atob/-/atob-2.1.2.tgz#6d9517eb9e030d2436666651e86bd9f6f13533c9"
integrity sha512-Wm6ukoaOGJi/73p/cl2GvLjTI5JM1k/O14isD73YML8StrH/7/lRFgmg8nICZgD3bZZvjwCGxtMOD3wWNAu8cg==

autopublish-template@20.0.0:
version "20.0.0"
resolved "https://registry.yarnpkg.com/autopublish-template/-/autopublish-template-20.0.0.tgz#aec377281398793f38a553e0c9277b0e65edba2a"
integrity sha512-OXzSKHdY8zu1VxGm3ibWtiX2FcQYi2mge9pECwnLN0MJAWfy60UNZfAosvJZ35CxV2V6cjcdqgVYzUIVHtFypA==

aws-sign2@~0.7.0:
version "0.7.0"
resolved "https://registry.yarnpkg.com/aws-sign2/-/aws-sign2-0.7.0.tgz#b46e890934a9591f2d2f6f86d7e6a9f1b3fe76a8"
Expand Down Expand Up @@ -1759,6 +1791,11 @@ deep-extend@^0.6.0:
resolved "https://registry.yarnpkg.com/deep-extend/-/deep-extend-0.6.0.tgz#c4fa7c95404a17a9c3e8ca7e1537312b736330ac"
integrity sha512-LOHxIOaPYdHlJRtCQfDIVZtfw/ufM8+rVj649RIHzcm/vGwQRXFt6OPqIFWsm2XEMrNIEtWR64sY1LEKD2vAOA==

deep-freeze@^0.0.1:
version "0.0.1"
resolved "https://registry.yarnpkg.com/deep-freeze/-/deep-freeze-0.0.1.tgz#3a0b0005de18672819dfd38cd31f91179c893e84"
integrity sha1-OgsABd4YZygZ39OM0x+RF5yJPoQ=

deep-is@~0.1.3:
version "0.1.3"
resolved "https://registry.yarnpkg.com/deep-is/-/deep-is-0.1.3.tgz#b369d6fb5dbc13eecf524f91b070feedc357cf34"
Expand Down Expand Up @@ -3841,7 +3878,7 @@ macos-release@^2.2.0:
resolved "https://registry.yarnpkg.com/macos-release/-/macos-release-2.3.0.tgz#eb1930b036c0800adebccd5f17bc4c12de8bb71f"
integrity sha512-OHhSbtcviqMPt7yfw5ef5aghS2jzFVKEFyCJndQt2YpSQ9qRVSEv2axSJI1paVThEu+FFGs584h/1YhxjVqajA==

magic-string@^0.25.2:
magic-string@^0.25.2, magic-string@^0.25.5:
version "0.25.7"
resolved "https://registry.yarnpkg.com/magic-string/-/magic-string-0.25.7.tgz#3f497d6fd34c669c6798dcb821f2ef31f5445051"
integrity sha512-4CrMT5DOHTDk4HYDlzmwu4FVCcIYI8gauveasrdCu2IKIFOJ3f0v/8MDGJCDL9oD2ppz/Av1b0Nj345H9M+XIA==
Expand Down Expand Up @@ -4483,7 +4520,7 @@ performance-now@^2.1.0:
resolved "https://registry.yarnpkg.com/performance-now/-/performance-now-2.1.0.tgz#6309f4e0e5fa913ec1c69307ae364b4b377c9e7b"
integrity sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns=

picomatch@^2.0.4, picomatch@^2.0.5, picomatch@^2.0.7, picomatch@^2.2.1:
picomatch@^2.0.4, picomatch@^2.0.5, picomatch@^2.0.7, picomatch@^2.2.1, picomatch@^2.2.2:
version "2.2.2"
resolved "https://registry.yarnpkg.com/picomatch/-/picomatch-2.2.2.tgz#21f333e9b6b8eaff02468f5146ea406d345f4dad"
integrity sha512-q0M/9eZHzmr0AulXyPwNfZjtwZ/RBZlbN3K3CErVrk50T2ASYI7Bye0EvekFY3IP1Nt2DHu0re+V2ZHIpMkuWg==
Expand Down Expand Up @@ -4644,7 +4681,7 @@ rc@^1.2.8:
minimist "^1.2.0"
strip-json-comments "~2.0.1"

react-is@^16.12.0:
react-is@^16.12.0, react-is@^16.13.1:
version "16.13.1"
resolved "https://registry.yarnpkg.com/react-is/-/react-is-16.13.1.tgz#789729a4dc36de2999dc156dd6c1d9c18cea56a4"
integrity sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==
Expand Down Expand Up @@ -4878,6 +4915,13 @@ resolve@^1.1.6, resolve@^1.10.0, resolve@^1.11.0, resolve@^1.14.2, resolve@^1.15
dependencies:
path-parse "^1.0.6"

resolve@^1.17.0:
version "1.17.0"
resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.17.0.tgz#b25941b54968231cc2d1bb76a79cb7f2c0bf8444"
integrity sha512-ic+7JYiV8Vi2yzQGFWOkiZD5Z9z7O2Zhm9XMaTxdJExKasieFCr+yXZ/WmXsckHiKl12ar0y6XiXDx3m4RHn1w==
dependencies:
path-parse "^1.0.6"

responselike@^1.0.2:
version "1.0.2"
resolved "https://registry.yarnpkg.com/responselike/-/responselike-1.0.2.tgz#918720ef3b631c5642be068f15ade5a46f4ba1e7"
Expand Down