Skip to content

Commit 6bce2cc

Browse files
author
sw-yx
committed
use collapse_vars
1 parent ecf273c commit 6bce2cc

File tree

4 files changed

+334
-20
lines changed

4 files changed

+334
-20
lines changed

.size-snapshot.json

+15-15
Original file line numberDiff line numberDiff line change
@@ -34,29 +34,29 @@
3434
}
3535
},
3636
"/Users/swyx/Netlify/react-netlify-identity-widget/dist/react-netlify-identity-widget.cjs.development.js": {
37-
"bundled": 13125,
38-
"minified": 8429,
39-
"gzipped": 2290
37+
"bundled": 13158,
38+
"minified": 8459,
39+
"gzipped": 2294
4040
},
4141
"/Users/swyx/Netlify/react-netlify-identity-widget/dist/react-netlify-identity-widget.cjs.production.js": {
42-
"bundled": 13125,
43-
"minified": 8429,
44-
"gzipped": 2290
42+
"bundled": 13158,
43+
"minified": 8459,
44+
"gzipped": 2294
4545
},
4646
"/Users/swyx/Netlify/react-netlify-identity-widget/dist/react-netlify-identity-widget.umd.development.js": {
47-
"bundled": 14129,
48-
"minified": 7374,
49-
"gzipped": 2241
47+
"bundled": 14164,
48+
"minified": 7389,
49+
"gzipped": 2249
5050
},
5151
"/Users/swyx/Netlify/react-netlify-identity-widget/dist/react-netlify-identity-widget.umd.production.js": {
52-
"bundled": 14129,
53-
"minified": 7374,
54-
"gzipped": 2241
52+
"bundled": 14164,
53+
"minified": 7389,
54+
"gzipped": 2249
5555
},
5656
"/Users/swyx/Netlify/react-netlify-identity-widget/dist/react-netlify-identity-widget.es.production.js": {
57-
"bundled": 12890,
58-
"minified": 8197,
59-
"gzipped": 2236,
57+
"bundled": 12920,
58+
"minified": 8226,
59+
"gzipped": 2244,
6060
"treeshaked": {
6161
"rollup": {
6262
"code": 722,

README.md

+7-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# React Netlify Identity Widget
22

3-
This is a React port of https://github.com/netlify/netlify-identity-widget (48kb) taking the lightweight functionality https://github.com/sw-yx/react-netlify-identity (4kb) and adding back the nicer UI with a focus on accessibility (with @reach UI) and bundle size.
3+
This is a React port of https://github.com/netlify/netlify-identity-widget (48kb), taking the lightweight functionality of https://github.com/sw-yx/react-netlify-identity (4kb) and adding back the nicer UI with a focus on accessibility (with @reach UI) and bundle size (only 6kb as of writing).
44

55
# demo
66

@@ -21,9 +21,11 @@ and the styles are optional but provided. here's how to use `IdentityModal, useN
2121
```tsx
2222
import React from "react"
2323
import "./App.css"
24-
import { IdentityModal, useNetlifyIdentity, IdentityContextProvider } from "react-netlify-identity-widget"
24+
import { useNetlifyIdentity, IdentityContextProvider } from "react-netlify-identity-widget"
2525
import "react-netlify-identity-widget/styles.css"
2626

27+
const IdentityModal = React.lazy(() => import("react-netlify-identity-widget"))
28+
2729
function App() {
2830
const [dialog, setDialog] = React.useState(false)
2931
const identity = useNetlifyIdentity("https://netlify-gotrue-in-react.netlify.com")
@@ -38,17 +40,18 @@ function App() {
3840
<button className="btn" onClick={() => setDialog(true)}>
3941
LOG OUT
4042
</button>
41-
<IdentityModal showDialog={dialog} onCloseDialog={() => setDialog(false)} />
4243
</header>
4344
) : (
4445
<header className="App-header">
4546
<h1> hello! try logging in! </h1>
4647
<button className="btn" onClick={() => setDialog(true)}>
4748
LOG IN
4849
</button>
49-
<IdentityModal showDialog={dialog} onCloseDialog={() => setDialog(false)} />
5050
</header>
5151
)}
52+
<React.Suspense fallback="loading...">
53+
<IdentityModal showDialog={dialog} onCloseDialog={() => setDialog(false)} />
54+
</React.Suspense>
5255
</div>
5356
</IdentityContextProvider>
5457
)

patches/tsdx+0.5.1.patch

+310
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,310 @@
1+
diff --git a/node_modules/tsdx/dist/.progress-estimator/5e1a1bc72a1c85f144986cb7aa3d91e6fd42e1c4 b/node_modules/tsdx/dist/.progress-estimator/5e1a1bc72a1c85f144986cb7aa3d91e6fd42e1c4
2+
index e42ad0b..4d6c613 100644
3+
--- a/node_modules/tsdx/dist/.progress-estimator/5e1a1bc72a1c85f144986cb7aa3d91e6fd42e1c4
4+
+++ b/node_modules/tsdx/dist/.progress-estimator/5e1a1bc72a1c85f144986cb7aa3d91e6fd42e1c4
5+
@@ -1,10 +1,10 @@
6+
-1536
7+
-1364
8+
-1387
9+
-1319
10+
-1381
11+
-1586
12+
1337
13+
1720
14+
2034
15+
1734
16+
+18255
17+
+3347
18+
+5822
19+
+5980
20+
+5152
21+
+3961
22+
\ No newline at end of file
23+
diff --git a/node_modules/tsdx/dist/.progress-estimator/9a3492e73be0eb3875889eb84075f018f90b4f72 b/node_modules/tsdx/dist/.progress-estimator/9a3492e73be0eb3875889eb84075f018f90b4f72
24+
index 01545b4..b836627 100644
25+
--- a/node_modules/tsdx/dist/.progress-estimator/9a3492e73be0eb3875889eb84075f018f90b4f72
26+
+++ b/node_modules/tsdx/dist/.progress-estimator/9a3492e73be0eb3875889eb84075f018f90b4f72
27+
@@ -1,10 +1,10 @@
28+
-2474
29+
-2440
30+
-2823
31+
-3006
32+
-3154
33+
-3046
34+
-2805
35+
3105
36+
4198
37+
3417
38+
+5431
39+
+3435
40+
+3721
41+
+3920
42+
+4273
43+
+5397
44+
+3853
45+
\ No newline at end of file
46+
diff --git a/node_modules/tsdx/dist/createRollupConfig.js b/node_modules/tsdx/dist/createRollupConfig.js
47+
index 07ee4e4..4a391a5 100644
48+
--- a/node_modules/tsdx/dist/createRollupConfig.js
49+
+++ b/node_modules/tsdx/dist/createRollupConfig.js
50+
@@ -1,124 +1,143 @@
51+
-"use strict";
52+
-Object.defineProperty(exports, "__esModule", { value: true });
53+
-const tslib_1 = require("tslib");
54+
-const utils_1 = require("./utils");
55+
-const constants_1 = require("./constants");
56+
-const rollup_plugin_size_snapshot_1 = require("rollup-plugin-size-snapshot");
57+
-const rollup_plugin_terser_1 = require("rollup-plugin-terser");
58+
-const rollup_plugin_babel_1 = tslib_1.__importDefault(require("rollup-plugin-babel"));
59+
-const rollup_plugin_commonjs_1 = tslib_1.__importDefault(require("rollup-plugin-commonjs"));
60+
-const rollup_plugin_json_1 = tslib_1.__importDefault(require("rollup-plugin-json"));
61+
-const rollup_plugin_replace_1 = tslib_1.__importDefault(require("rollup-plugin-replace"));
62+
-const rollup_plugin_node_resolve_1 = tslib_1.__importDefault(require("rollup-plugin-node-resolve"));
63+
-const rollup_plugin_sourcemaps_1 = tslib_1.__importDefault(require("rollup-plugin-sourcemaps"));
64+
-const rollup_plugin_typescript2_1 = tslib_1.__importDefault(require("rollup-plugin-typescript2"));
65+
-const rollup_plugin_preserve_shebang_1 = tslib_1.__importDefault(require("@jaredpalmer/rollup-plugin-preserve-shebang"));
66+
+'use strict';
67+
+Object.defineProperty(exports, '__esModule', { value: true });
68+
+const tslib_1 = require('tslib');
69+
+const utils_1 = require('./utils');
70+
+const constants_1 = require('./constants');
71+
+const rollup_plugin_size_snapshot_1 = require('rollup-plugin-size-snapshot');
72+
+const rollup_plugin_terser_1 = require('rollup-plugin-terser');
73+
+const rollup_plugin_babel_1 = tslib_1.__importDefault(
74+
+ require('rollup-plugin-babel')
75+
+);
76+
+const rollup_plugin_commonjs_1 = tslib_1.__importDefault(
77+
+ require('rollup-plugin-commonjs')
78+
+);
79+
+const rollup_plugin_json_1 = tslib_1.__importDefault(
80+
+ require('rollup-plugin-json')
81+
+);
82+
+const rollup_plugin_replace_1 = tslib_1.__importDefault(
83+
+ require('rollup-plugin-replace')
84+
+);
85+
+const rollup_plugin_node_resolve_1 = tslib_1.__importDefault(
86+
+ require('rollup-plugin-node-resolve')
87+
+);
88+
+const rollup_plugin_sourcemaps_1 = tslib_1.__importDefault(
89+
+ require('rollup-plugin-sourcemaps')
90+
+);
91+
+const rollup_plugin_typescript2_1 = tslib_1.__importDefault(
92+
+ require('rollup-plugin-typescript2')
93+
+);
94+
+const rollup_plugin_preserve_shebang_1 = tslib_1.__importDefault(
95+
+ require('@jaredpalmer/rollup-plugin-preserve-shebang')
96+
+);
97+
const replacements = [{ original: 'lodash', replacement: 'lodash-es' }];
98+
const babelOptions = {
99+
- exclude: /node_modules/,
100+
- plugins: [
101+
- 'annotate-pure-calls',
102+
- 'dev-expression',
103+
- ['transform-rename-import', { replacements }],
104+
- ],
105+
+ exclude: /node_modules/,
106+
+ plugins: [
107+
+ 'annotate-pure-calls',
108+
+ 'dev-expression',
109+
+ ['transform-rename-import', { replacements }],
110+
+ ],
111+
};
112+
function createRollupConfig(format, env, opts) {
113+
- let shebang;
114+
- return {
115+
- // Tell Rollup the entry point to the package
116+
- input: opts.input,
117+
- // Tell Rollup which packages to ignore
118+
- external: utils_1.external,
119+
- // Establish Rollup output
120+
- output: {
121+
- // Set filenames of the consumer's package
122+
- file: `${constants_1.paths.appDist}/${utils_1.safePackageName(opts.name)}.${format}.${env}.js`,
123+
- // Pass through the file format
124+
- format,
125+
- // Do not let Rollup call Object.freeze() on namespace import objects
126+
- // (i.e. import * as namespaceImportObject from...) that are accessed dynamically.
127+
- freeze: false,
128+
- // Do not let Rollup add a `__esModule: true` property when generating exports for non-ESM formats.
129+
- esModule: false,
130+
- // Rollup has treeshaking by default, but we can optimize it further...
131+
- treeshake: {
132+
- // We assume reading a property of an object never has side-effects.
133+
- // This means tsdx WILL remove getters and setters on objects.
134+
- //
135+
- // @example
136+
- //
137+
- // const foo = {
138+
- // get bar() {
139+
- // console.log('effect');
140+
- // return 'bar';
141+
- // }
142+
- // }
143+
- //
144+
- // const result = foo.bar;
145+
- // const illegalAccess = foo.quux.tooDeep;
146+
- //
147+
- // Punchline....Don't use getters and setters
148+
- propertyReadSideEffects: false,
149+
- },
150+
- name: opts.name || utils_1.safeVariableName(opts.name),
151+
- sourcemap: true,
152+
- globals: { react: 'React', 'react-native': 'ReactNative' },
153+
- exports: 'named',
154+
+ let shebang;
155+
+ return {
156+
+ // Tell Rollup the entry point to the package
157+
+ input: opts.input,
158+
+ // Tell Rollup which packages to ignore
159+
+ external: utils_1.external,
160+
+ // Establish Rollup output
161+
+ output: {
162+
+ // Set filenames of the consumer's package
163+
+ file: `${constants_1.paths.appDist}/${utils_1.safePackageName(
164+
+ opts.name
165+
+ )}.${format}.${env}.js`,
166+
+ // Pass through the file format
167+
+ format,
168+
+ // Do not let Rollup call Object.freeze() on namespace import objects
169+
+ // (i.e. import * as namespaceImportObject from...) that are accessed dynamically.
170+
+ freeze: false,
171+
+ // Do not let Rollup add a `__esModule: true` property when generating exports for non-ESM formats.
172+
+ esModule: false,
173+
+ // Rollup has treeshaking by default, but we can optimize it further...
174+
+ treeshake: {
175+
+ // We assume reading a property of an object never has side-effects.
176+
+ // This means tsdx WILL remove getters and setters on objects.
177+
+ //
178+
+ // @example
179+
+ //
180+
+ // const foo = {
181+
+ // get bar() {
182+
+ // console.log('effect');
183+
+ // return 'bar';
184+
+ // }
185+
+ // }
186+
+ //
187+
+ // const result = foo.bar;
188+
+ // const illegalAccess = foo.quux.tooDeep;
189+
+ //
190+
+ // Punchline....Don't use getters and setters
191+
+ propertyReadSideEffects: false,
192+
+ },
193+
+ name: opts.name || utils_1.safeVariableName(opts.name),
194+
+ sourcemap: true,
195+
+ globals: { react: 'React', 'react-native': 'ReactNative' },
196+
+ exports: 'named',
197+
+ },
198+
+ plugins: [
199+
+ rollup_plugin_node_resolve_1.default({
200+
+ mainFields: [
201+
+ 'module',
202+
+ 'main',
203+
+ opts.target !== 'node' ? 'browser' : undefined,
204+
+ ].filter(Boolean),
205+
+ }),
206+
+ format === 'umd' &&
207+
+ rollup_plugin_commonjs_1.default({
208+
+ // use a regex to make sure to include eventual hoisted packages
209+
+ include: /\/node_modules\//,
210+
+ }),
211+
+ rollup_plugin_json_1.default(),
212+
+ rollup_plugin_typescript2_1.default({
213+
+ typescript: require('typescript'),
214+
+ cacheRoot: `./.rts2_cache_${format}`,
215+
+ tsconfigDefaults: {
216+
+ compilerOptions: {
217+
+ sourceMap: true,
218+
+ declaration: true,
219+
+ jsx: 'react',
220+
+ },
221+
},
222+
- plugins: [
223+
- rollup_plugin_node_resolve_1.default({
224+
- mainFields: [
225+
- 'module',
226+
- 'main',
227+
- opts.target !== 'node' ? 'browser' : undefined,
228+
- ].filter(Boolean),
229+
- }),
230+
- format === 'umd' &&
231+
- rollup_plugin_commonjs_1.default({
232+
- // use a regex to make sure to include eventual hoisted packages
233+
- include: /\/node_modules\//,
234+
- }),
235+
- rollup_plugin_json_1.default(),
236+
- rollup_plugin_typescript2_1.default({
237+
- typescript: require('typescript'),
238+
- cacheRoot: `./.rts2_cache_${format}`,
239+
- tsconfigDefaults: {
240+
- compilerOptions: {
241+
- sourceMap: true,
242+
- declaration: true,
243+
- jsx: 'react',
244+
- },
245+
- },
246+
- tsconfigOverride: {
247+
- compilerOptions: {
248+
- target: 'esnext',
249+
- },
250+
- },
251+
- }),
252+
- rollup_plugin_babel_1.default(babelOptions),
253+
- rollup_plugin_replace_1.default({
254+
- 'process.env.NODE_ENV': JSON.stringify(env),
255+
- }),
256+
- rollup_plugin_sourcemaps_1.default(),
257+
- rollup_plugin_size_snapshot_1.sizeSnapshot({
258+
- printInfo: false,
259+
- }),
260+
- env === 'production' &&
261+
- rollup_plugin_terser_1.terser({
262+
- sourcemap: true,
263+
- output: { comments: false },
264+
- compress: {
265+
- keep_infinity: true,
266+
- pure_getters: true,
267+
- },
268+
- ecma: 5,
269+
- toplevel: format === 'es' || format === 'cjs',
270+
- warnings: true,
271+
- }),
272+
- rollup_plugin_preserve_shebang_1.default({
273+
- shebang,
274+
- }),
275+
- ],
276+
- };
277+
+ tsconfigOverride: {
278+
+ compilerOptions: {
279+
+ target: 'esnext',
280+
+ },
281+
+ },
282+
+ }),
283+
+ rollup_plugin_babel_1.default(babelOptions),
284+
+ rollup_plugin_replace_1.default({
285+
+ 'process.env.NODE_ENV': JSON.stringify(env),
286+
+ }),
287+
+ rollup_plugin_sourcemaps_1.default(),
288+
+ rollup_plugin_size_snapshot_1.sizeSnapshot({
289+
+ printInfo: false,
290+
+ }),
291+
+ env === 'production' &&
292+
+ rollup_plugin_terser_1.terser({
293+
+ sourcemap: true,
294+
+ output: { comments: false },
295+
+ compress: {
296+
+ keep_infinity: true,
297+
+ pure_getters: true,
298+
+ collapse_vars: false,
299+
+ },
300+
+ ecma: 5,
301+
+ toplevel: format === 'es' || format === 'cjs',
302+
+ warnings: true,
303+
+ }),
304+
+ rollup_plugin_preserve_shebang_1.default({
305+
+ shebang,
306+
+ }),
307+
+ ],
308+
+ };
309+
}
310+
exports.createRollupConfig = createRollupConfig;

0 commit comments

Comments
 (0)