Skip to content
This repository was archived by the owner on Nov 23, 2021. It is now read-only.

Commit 2da44ae

Browse files
committed
Chore: Upgrade dev dependencies to fix CJS build.
1 parent 8366dc5 commit 2da44ae

File tree

6 files changed

+139
-101
lines changed

6 files changed

+139
-101
lines changed

package-lock.json

Lines changed: 74 additions & 48 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "mini-create-react-context",
3-
"version": "0.3.0",
3+
"version": "0.3.1",
44
"description": "Smaller Polyfill for the proposed React context API",
55
"main": "dist/cjs/index.js",
66
"module": "dist/esm/index.js",
@@ -40,8 +40,8 @@
4040
"@babel/preset-typescript": "^7.3.3",
4141
"@types/enzyme": "^3.9.1",
4242
"@types/jest": "^24.0.11",
43-
"@types/react": "^16.8.12",
44-
"@wessberg/rollup-plugin-ts": "^1.1.45",
43+
"@types/react": "^16.8.13",
44+
"@wessberg/rollup-plugin-ts": "^1.1.46",
4545
"babel-jest": "^24.7.1",
4646
"enzyme": "^3.9.0",
4747
"enzyme-adapter-react-16": "^1.11.2",
@@ -51,8 +51,9 @@
5151
"raf": "^3.4.1",
5252
"react": "^16.2.0",
5353
"react-dom": "^16.2.0",
54-
"rollup": "^1.9.0",
55-
"rollup-plugin-node-resolve": "^4.1.0",
54+
"rollup": "^1.10.0",
55+
"rollup-plugin-commonjs": "^9.3.4",
56+
"rollup-plugin-node-resolve": "^4.2.3",
5657
"rollup-plugin-uglify": "^6.0.2"
5758
},
5859
"jest": {

rollup.config.js

Lines changed: 55 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,60 @@
1-
const nodeResolve = require("rollup-plugin-node-resolve");
2-
const { uglify } = require("rollup-plugin-uglify");
3-
const ts = require("@wessberg/rollup-plugin-ts");
4-
5-
const externalModules = ["react", "gud", "tiny-warning", "prop-types"];
1+
import ts from "@wessberg/rollup-plugin-ts";
2+
import path from "path";
3+
import commonjs from "rollup-plugin-commonjs";
4+
import nodeResolve from "rollup-plugin-node-resolve";
5+
import { uglify } from "rollup-plugin-uglify";
66
const extensions = [".ts", ".tsx"];
77

8-
const cjs = [
9-
{
10-
input: "src/index.ts",
11-
output: { file: `dist/cjs/index.js`, format: "cjs", compact: true, },
12-
external: externalModules,
13-
plugins: [
14-
nodeResolve({ extensions }),
15-
ts({
16-
transpiler: "babel",
17-
}),
18-
]
19-
},
20-
{
21-
input: "src/index.ts",
22-
output: { file: `dist/cjs/index.min.js`, format: "cjs", compact: true, },
23-
external: externalModules,
24-
plugins: [
25-
nodeResolve({ extensions }),
26-
ts({
27-
transpiler: "babel",
28-
}),
29-
uglify(),
30-
]
8+
function isBareModuleId(id) {
9+
if (id.startsWith(".")) {
10+
return false;
3111
}
32-
];
33-
34-
const esm = [
35-
{
36-
input: "src/index.ts",
37-
output: { file: `dist/esm/index.js`, format: "esm" },
38-
external: externalModules,
39-
plugins: [
40-
nodeResolve({ extensions }),
41-
ts({
42-
transpiler: "babel",
43-
}),
44-
]
12+
if (id.startsWith("src")) {
13+
return false;
4514
}
46-
];
15+
return !id.includes(path.join(process.cwd(), "src"));
16+
}
4717

48-
module.exports = cjs.concat(esm);
18+
export default function configureRollup() {
19+
return [
20+
// CJS:
21+
{
22+
input: "src/index.ts",
23+
output: { file: `dist/cjs/index.js`, format: "cjs", compact: true },
24+
external: isBareModuleId,
25+
plugins: [
26+
nodeResolve({ extensions }),
27+
ts({
28+
transpiler: "babel",
29+
}),
30+
commonjs(),
31+
],
32+
},
33+
{
34+
input: "src/index.ts",
35+
output: { file: `dist/cjs/index.min.js`, format: "cjs", compact: true },
36+
external: isBareModuleId,
37+
plugins: [
38+
nodeResolve({ extensions }),
39+
ts({
40+
transpiler: "babel",
41+
}),
42+
commonjs(),
43+
uglify(),
44+
],
45+
},
46+
// ESM:
47+
{
48+
input: "src/index.ts",
49+
output: { file: `dist/esm/index.js`, format: "esm" },
50+
external: isBareModuleId,
51+
plugins: [
52+
nodeResolve({ extensions }),
53+
ts({
54+
transpiler: "babel",
55+
}),
56+
commonjs(),
57+
],
58+
},
59+
];
60+
}

src/__tests__/createReactContext.test.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,7 @@ test('can skip consumers with bitmask', () => {
9393

9494
function Provider(props) {
9595
return (
96-
<Context.Provider value={{ foo: props.foo, bar: props.bar }
97-
}>
96+
<Context.Provider value={{ foo: props.foo, bar: props.bar }}>
9897
{props.children}
9998
</Context.Provider>
10099
);

src/implementation.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export type Context<T> = {
3030
export type ProviderProps<T> = {
3131
value: T;
3232
children?: React.ReactNode;
33-
observedBits: any,
33+
observedBits?: any,
3434
};
3535

3636
export type ConsumerProps<T> = {

src/index.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ export type Context<T> = {
1414

1515
export type ProviderProps<T> = {
1616
value: T;
17-
children: React.ReactNode;
18-
observedBits: any,
17+
children?: React.ReactNode;
18+
observedBits?: any,
1919
};
2020

2121
export type ConsumerProps<T> = {

0 commit comments

Comments
 (0)