generated from esm-bundle/autopublish-template
-
-
Notifications
You must be signed in to change notification settings - Fork 1
Feat/implement #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
1b4a309
Replace with react-is
filoxo ece876b
Add dependencies
filoxo ddd176f
Move single-run to karma.conf.js
filoxo 21191fe
Build react-is
filoxo edcfc7a
Update tests
filoxo 69ecf80
Revert "Move single-run to karma.conf.js"
filoxo 939cbb3
Build for both production and development
filoxo 4946e43
Update tests for production
filoxo 65355a7
Add tests for development bundle
filoxo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,35 +1,33 @@ | ||
| # autopublish-template | ||
| # react-is | ||
|
|
||
| [](https://www.npmjs.com/package/@esm-bundle/autopublish-template) [](https://travis-ci.com/esm-bundle/autopublish-template) [](https://www.jsdelivr.com/package/npm/@esm-bundle/autopublish-template) | ||
| [](https://www.npmjs.com/package/@esm-bundle/react-is) [](https://travis-ci.com/esm-bundle/react-is) [](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 | ||
| ``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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(); | ||
| } | ||
| ); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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), | ||
| }; | ||
| } | ||
|
|
||
| export default [createConfig("module"), createConfig("system")]; | ||
| export default [ | ||
| createConfig("module", "development"), | ||
| createConfig("module", "production"), | ||
| createConfig("system", "development"), | ||
| createConfig("system", "production"), | ||
| ]; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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