Skip to content
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

Use mui like global ponyfill #1153

Merged
merged 3 commits into from
Jul 7, 2019
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: 4 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ Since you are interested in what happens next, in case, you work for a for-profi

---

### Improvements

- [jss] Improve treeshaking for webpack by not using `global`. ([#1153](https://github.com/cssinjs/jss/pull/1153))

## 10.0.0-alpha.22 (2019-7-2)

### Breaking Changes
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@
"rollup": "^1.1.2",
"rollup-plugin-babel": "^4.3.2",
"rollup-plugin-commonjs": "^9.2.0",
"rollup-plugin-node-globals": "^1.4.0",
"rollup-plugin-node-resolve": "^4.0.0",
"rollup-plugin-replace": "^2.1.0",
"rollup-plugin-size-snapshot": "^0.8.0",
Expand Down
12 changes: 6 additions & 6 deletions packages/css-jss/.size-snapshot.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"dist/css-jss.js": {
"bundled": 57623,
"minified": 20360,
"gzipped": 6833
"bundled": 57471,
"minified": 20270,
"gzipped": 6819
},
"dist/css-jss.min.js": {
"bundled": 56869,
"minified": 19901,
"gzipped": 6617
"bundled": 56717,
"minified": 19812,
"gzipped": 6608
},
"dist/css-jss.cjs.js": {
"bundled": 2919,
Expand Down
12 changes: 6 additions & 6 deletions packages/jss-plugin-rule-value-observable/.size-snapshot.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"dist/jss-plugin-rule-value-observable.js": {
"bundled": 3554,
"minified": 1111,
"gzipped": 538
"bundled": 2579,
"minified": 1025,
"gzipped": 517
},
"dist/jss-plugin-rule-value-observable.min.js": {
"bundled": 3554,
"minified": 1111,
"gzipped": 538
"bundled": 2579,
"minified": 1025,
"gzipped": 517
},
"dist/jss-plugin-rule-value-observable.cjs.js": {
"bundled": 1709,
Expand Down
12 changes: 6 additions & 6 deletions packages/jss-preset-default/.size-snapshot.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"dist/jss-preset-default.js": {
"bundled": 54867,
"minified": 19594,
"gzipped": 6478
"bundled": 54715,
"minified": 19504,
"gzipped": 6471
},
"dist/jss-preset-default.min.js": {
"bundled": 54113,
"minified": 19135,
"gzipped": 6265
"bundled": 53961,
"minified": 19046,
"gzipped": 6262
},
"dist/jss-preset-default.cjs.js": {
"bundled": 1329,
Expand Down
12 changes: 6 additions & 6 deletions packages/jss-starter-kit/.size-snapshot.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"dist/jss-starter-kit.js": {
"bundled": 70409,
"minified": 29633,
"gzipped": 9110
"bundled": 70257,
"minified": 29544,
"gzipped": 9093
},
"dist/jss-starter-kit.min.js": {
"bundled": 69655,
"minified": 29175,
"gzipped": 8905
"bundled": 69503,
"minified": 29086,
"gzipped": 8883
},
"dist/jss-starter-kit.cjs.js": {
"bundled": 2592,
Expand Down
28 changes: 14 additions & 14 deletions packages/jss/.size-snapshot.json
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
{
"dist/jss.js": {
"bundled": 60547,
"minified": 22448,
"gzipped": 6767
"bundled": 60646,
"minified": 22473,
"gzipped": 6782
},
"dist/jss.min.js": {
"bundled": 59170,
"minified": 21679,
"gzipped": 6409
"bundled": 59269,
"minified": 21704,
"gzipped": 6422
},
"dist/jss.cjs.js": {
"bundled": 55336,
"minified": 24340,
"gzipped": 6756
"bundled": 55435,
"minified": 24373,
"gzipped": 6775
},
"dist/jss.esm.js": {
"bundled": 54804,
"minified": 23905,
"gzipped": 6667,
"bundled": 54903,
"minified": 23938,
"gzipped": 6686,
"treeshaked": {
"rollup": {
"code": 19676,
"code": 19701,
"import_statements": 352
},
"webpack": {
"code": 21143
"code": 21168
}
}
}
Expand Down
7 changes: 7 additions & 0 deletions packages/jss/src/utils/globalThis.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/* eslint-disable */
// https://github.com/zloirock/core-js/issues/86#issuecomment-115759028
export default (typeof window != 'undefined' && window.Math == Math
? window
: typeof self != 'undefined' && self.Math == Math
? self
: Function('return this')())
6 changes: 4 additions & 2 deletions packages/jss/src/utils/moduleId.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import globalThis from './globalThis'

const ns = '2f1acc6c3a606b082e5eef5e54414ffb'
if (global[ns] == null) global[ns] = 0
if (globalThis[ns] == null) globalThis[ns] = 0

// Bundle may contain multiple JSS versions at the same time. In order to identify
// the current version with just one short number and use it for classes generation
// we use a counter. Also it is more accurate, because user can manually reevaluate
// the module.
export default global[ns]++
export default globalThis[ns]++
12 changes: 6 additions & 6 deletions packages/react-jss/.size-snapshot.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"dist/react-jss.js": {
"bundled": 168524,
"minified": 58221,
"gzipped": 19011
"bundled": 168372,
"minified": 58132,
"gzipped": 18988
},
"dist/react-jss.min.js": {
"bundled": 111856,
"minified": 41611,
"gzipped": 14104
"bundled": 111704,
"minified": 41522,
"gzipped": 14086
},
"dist/react-jss.cjs.js": {
"bundled": 26415,
Expand Down
6 changes: 0 additions & 6 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import fs from 'fs'
import path from 'path'
import nodeResolve from 'rollup-plugin-node-resolve'
import nodeGlobals from 'rollup-plugin-node-globals'
import commonjs from 'rollup-plugin-commonjs'
import babel from 'rollup-plugin-babel'
import replace from 'rollup-plugin-replace'
Expand Down Expand Up @@ -93,7 +92,6 @@ export default [
nodeResolve(),
babel(getBabelOptions({useESModules: true})),
commonjs(commonjsOptions),
nodeGlobals({process: false}),
replace({
'process.env.NODE_ENV': JSON.stringify('development'),
'process.env.VERSION': JSON.stringify(pkg.version)
Expand All @@ -116,7 +114,6 @@ export default [
nodeResolve(),
babel(getBabelOptions({useESModules: true})),
commonjs(commonjsOptions),
nodeGlobals({process: false}),
replace({
'process.env.NODE_ENV': JSON.stringify('production'),
'process.env.VERSION': JSON.stringify(pkg.version)
Expand All @@ -133,7 +130,6 @@ export default [
plugins: [
createFlowBundlePlugin,
babel(getBabelOptions({useESModules: false})),
nodeGlobals({process: false}),
replace({'process.env.VERSION': JSON.stringify(pkg.version)}),
sizeSnapshot(snapshotOptions)
]
Expand All @@ -145,7 +141,6 @@ export default [
external,
plugins: [
babel(getBabelOptions({useESModules: true})),
nodeGlobals({process: false}),
replace({'process.env.VERSION': JSON.stringify(pkg.version)}),
sizeSnapshot(snapshotOptions)
]
Expand All @@ -158,7 +153,6 @@ export default [
nodeResolve(),
babel(getBabelOptions({useESModules: true})),
commonjs(commonjsOptions),
nodeGlobals({process: false}),
replace({
'process.env.NODE_ENV': JSON.stringify('development'),
'process.env.VERSION': JSON.stringify(pkg.version)
Expand Down
38 changes: 2 additions & 36 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1642,7 +1642,7 @@ acorn-jsx@^4.1.1:
dependencies:
acorn "^5.0.3"

acorn@^5.0.0, acorn@^5.0.3, acorn@^5.6.0, acorn@^5.6.2, acorn@^5.7.3:
acorn@^5.0.0, acorn@^5.0.3, acorn@^5.6.0, acorn@^5.6.2:
version "5.7.3"
resolved "https://registry.yarnpkg.com/acorn/-/acorn-5.7.3.tgz#67aa231bf8812974b85235a96771eb6bd07ea279"
integrity sha512-T/zvzYRfbVojPWahDsE5evJdHb3oJoQfFbsrKM7w5Zcs++Tr257tia3BmMP8XYVjp1S9RZXQMh7gao96BlqZOw==
Expand Down Expand Up @@ -2328,11 +2328,6 @@ buffer-alloc@^1.2.0:
buffer-alloc-unsafe "^1.1.0"
buffer-fill "^1.0.0"

buffer-es6@^4.9.3:
version "4.9.3"
resolved "https://registry.yarnpkg.com/buffer-es6/-/buffer-es6-4.9.3.tgz#f26347b82df76fd37e18bcb5288c4970cfd5c404"
integrity sha1-8mNHuC33b9N+GLy1KIxJcM/VxAQ=

buffer-fill@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/buffer-fill/-/buffer-fill-1.0.0.tgz#f8f78b76789888ef39f205cd637f68e702122b2c"
Expand Down Expand Up @@ -6246,13 +6241,6 @@ lru-cache@^5.1.1:
dependencies:
yallist "^3.0.2"

magic-string@^0.22.5:
version "0.22.5"
resolved "https://registry.yarnpkg.com/magic-string/-/magic-string-0.22.5.tgz#8e9cf5afddf44385c1da5bc2a6a0dbd10b03657e"
integrity sha512-oreip9rJZkzvA8Qzk9HFs8fZGF/u7H/gtrE8EN6RjKJ9kh2HlC+yQ2QezifqTZfGyiuAV0dRv5a+y/8gBb1m9w==
dependencies:
vlq "^0.2.2"

magic-string@^0.25.1:
version "0.25.2"
resolved "https://registry.yarnpkg.com/magic-string/-/magic-string-0.25.2.tgz#139c3a729515ec55e96e69e82a11fe890a293ad9"
Expand Down Expand Up @@ -7531,11 +7519,6 @@ private@^0.1.6:
resolved "https://registry.yarnpkg.com/private/-/private-0.1.8.tgz#2381edb3689f7a53d653190060fcf822d2f368ff"
integrity sha512-VvivMrbvd2nKkiG38qjULzlc+4Vx4wm/whI9pQD35YrARNnhxeiRktSOhSukRLFNlzg6Br/cJPet5J/u19r/mg==

process-es6@^0.11.6:
version "0.11.6"
resolved "https://registry.yarnpkg.com/process-es6/-/process-es6-0.11.6.tgz#c6bb389f9a951f82bd4eb169600105bd2ff9c778"
integrity sha1-xrs4n5qVH4K9TrFpYAEFvS/5x3g=

process-nextick-args@~2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/process-nextick-args/-/process-nextick-args-2.0.0.tgz#a37d732f4271b4ab1ad070d35508e8290788ffaa"
Expand Down Expand Up @@ -8260,18 +8243,6 @@ rollup-plugin-commonjs@^9.2.0:
resolve "^1.8.1"
rollup-pluginutils "^2.3.3"

rollup-plugin-node-globals@^1.4.0:
version "1.4.0"
resolved "https://registry.yarnpkg.com/rollup-plugin-node-globals/-/rollup-plugin-node-globals-1.4.0.tgz#5e1f24a9bb97c0ef51249f625e16c7e61b7c020b"
integrity sha512-xRkB+W/m1KLIzPUmG0ofvR+CPNcvuCuNdjVBVS7ALKSxr3EDhnzNceGkGi1m8MToSli13AzKFYH4ie9w3I5L3g==
dependencies:
acorn "^5.7.3"
buffer-es6 "^4.9.3"
estree-walker "^0.5.2"
magic-string "^0.22.5"
process-es6 "^0.11.6"
rollup-pluginutils "^2.3.1"

rollup-plugin-node-resolve@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/rollup-plugin-node-resolve/-/rollup-plugin-node-resolve-4.0.0.tgz#9bc6b8205e9936cc0e26bba2415f1ecf1e64d9b2"
Expand Down Expand Up @@ -8323,7 +8294,7 @@ rollup-pluginutils@^2.0.1, rollup-pluginutils@^2.3.0:
estree-walker "^0.5.2"
micromatch "^2.3.11"

rollup-pluginutils@^2.3.1, rollup-pluginutils@^2.3.3:
rollup-pluginutils@^2.3.3:
version "2.3.3"
resolved "https://registry.yarnpkg.com/rollup-pluginutils/-/rollup-pluginutils-2.3.3.tgz#3aad9b1eb3e7fe8262820818840bf091e5ae6794"
integrity sha512-2XZwja7b6P5q4RZ5FhyX1+f46xi1Z3qBKigLRZ6VTZjwbN0K1IFGMlwm06Uu0Emcre2Z63l77nq/pzn+KxIEoA==
Expand Down Expand Up @@ -9656,11 +9627,6 @@ vfile@^2.0.0:
unist-util-stringify-position "^1.0.0"
vfile-message "^1.0.0"

vlq@^0.2.2:
version "0.2.3"
resolved "https://registry.yarnpkg.com/vlq/-/vlq-0.2.3.tgz#8f3e4328cf63b1540c0d67e1b2778386f8975b26"
integrity sha512-DRibZL6DsNhIgYQ+wNdWDL2SL3bKPlVrRiBqV5yuMm++op8W4kGFtaQfCs4KEJn0wBZcHVHJ3eoywX8983k1ow==

vm-browserify@0.0.4:
version "0.0.4"
resolved "https://registry.yarnpkg.com/vm-browserify/-/vm-browserify-0.0.4.tgz#5d7ea45bbef9e4a6ff65f95438e0a87c357d5a73"
Expand Down