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

Feat/exports-maps for consistent behaviour of esm imports in node and browser environments #1528

Closed
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
3 changes: 2 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ module.exports = {
{
files: ['docs/*.md', 'docs/**/*.md'],
rules: {
'no-console': 'off'
'no-console': 'off',
'import/extensions': 'off'
}
},
{
Expand Down
6 changes: 3 additions & 3 deletions docs/cdn.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Unminified CommonJS:
https://unpkg.com/jss/dist/jss.cjs.js

Unminified ESM:
https://unpkg.com/jss/dist/jss.esm.js
https://unpkg.com/jss/dist/jss.esm.mjs

Minified UMD:
https://unpkg.com/jss/dist/jss.min.js
Expand All @@ -27,7 +27,7 @@ Unminified CommonJS:
https://unpkg.com/jss-preset-default/dist/jss-preset-default.cjs.js

Unminified ESM:
https://unpkg.com/jss-preset-default/dist/jss-preset-default.esm.js
https://unpkg.com/jss-preset-default/dist/jss-preset-default.esm.mjs

Minified UMD:
https://unpkg.com/jss-preset-default/dist/jss-preset-default.min.js
Expand All @@ -41,7 +41,7 @@ Unminified CommonJS:
https://unpkg.com/react-jss/dist/react-jss.cjs.js

Unminified ESM:
https://unpkg.com/react-jss/dist/react-jss.esm.js
https://unpkg.com/react-jss/dist/react-jss.esm.mjs

Minified UMD:
https://unpkg.com/react-jss/dist/react-jss.min.js
25 changes: 20 additions & 5 deletions karma.conf.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const webpack = require('./webpack.config')
const browsers = require('./browsers')
const webpackConfig = require('./webpack.config')
const browsers = require('./browsers.json')

const isBench = process.env.BENCHMARK === 'true'
const useCloud = process.env.USE_CLOUD === 'true'
Expand All @@ -10,24 +10,39 @@ const travisBuildNumber = process.env.TRAVIS_BUILD_NUMBER
const travisBuildId = process.env.TRAVIS_BUILD_ID
const travisJobNumber = process.env.TRAVIS_JOB_NUMBER

const getWepackConfig = () => {
delete webpackConfig.entry
delete webpackConfig.output
return webpackConfig
}

module.exports = config => {
config.set({
customLaunchers: browsers,
browsers: ['Chrome'],
frameworks: ['mocha'],
frameworks: ['mocha', 'webpack'],
files: [
'./polyfills.js',
'./packages/*/tests/*.js',
'./packages/*/tests/**/*.js',
'./packages/*/src/**/*.test.js'
],
plugins: [
'karma-webpack',
'karma-mocha',
'karma-sourcemap-loader',
'karma-mocha-reporter',
'karma-coverage',
'karma-chrome-launcher'
],
preprocessors: {
'./polyfills.js': ['webpack', 'sourcemap'],
'./packages/**/*.js': ['webpack', 'sourcemap']
},
webpack,
webpack: getWepackConfig(),
webpackMiddleware: {
stats: 'errors-only'
stats: 'errors-only',
noInfo: true
},
reporters: ['mocha', 'coverage'],
coverageReporter: {
Expand Down
40 changes: 20 additions & 20 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,22 +43,22 @@
"yarn": ">=1.13"
},
"devDependencies": {
"@babel/core": "^7.2.2",
"@babel/plugin-proposal-class-properties": "^7.3.0",
"@babel/plugin-proposal-object-rest-spread": "^7.3.2",
"@babel/plugin-transform-runtime": "^7.2.0",
"@babel/preset-env": "^7.3.1",
"@babel/preset-flow": "^7.0.0",
"@babel/preset-react": "^7.0.0",
"@babel/core": "^7.14.6",
"@babel/plugin-proposal-class-properties": "^7.14.5",
"@babel/plugin-proposal-object-rest-spread": "^7.14.7",
"@babel/plugin-transform-runtime": "^7.14.5",
"@babel/preset-env": "^7.14.7",
"@babel/preset-flow": "^7.14.5",
"@babel/preset-react": "^7.14.5",
"@lerna/prompt": "^3.6.0",
"@rollup/plugin-babel": "^5.2.1",
"@rollup/plugin-commonjs": "^16.0.0",
"@rollup/plugin-node-resolve": "^10.0.0",
"@rollup/plugin-replace": "^2.3.4",
"@types/node": "^14.0.9",
"axios": "^0.18.0",
"babel-loader": "^8.0.4",
"babel-plugin-dev-expression": "^0.2.1",
"babel-loader": "^8.2.2",
"babel-plugin-dev-expression": "^0.2.2",
"camelcase": "^5.0.0",
"chalk": "^2.4.1",
"codecov": "^3.6.5",
Expand All @@ -74,19 +74,19 @@
"expect.js": "^0.3.1",
"flow-bin": "^0.138.0",
"json-loader": "^0.5.4",
"karma": "^1.3.0",
"karma-benchmark": "^0.6.0",
"karma": "^6.3.4",
"karma-benchmark": "^1.0.4",
"karma-benchmark-reporter": "^0.1.1",
"karma-browserstack-launcher": "^1.4.0",
"karma-chrome-launcher": "^2.0.0",
"karma-coverage": "^1.1.1",
"karma-mocha": "^1.3.0",
"karma-mocha-reporter": "^2.2.1",
"karma-sourcemap-loader": "^0.3.7",
"karma-webpack": "^4.0.0-rc.5",
"karma-browserstack-launcher": "^1.6.0",
"karma-chrome-launcher": "^3.1.0",
"karma-coverage": "^2.0.3",
"karma-mocha": "^2.0.1",
"karma-mocha-reporter": "^2.2.5",
"karma-sourcemap-loader": "^0.3.8",
"karma-webpack": "^5.0.0",
"lerna": "^3.8.0",
"lint-staged": "^3.2.2",
"mocha": "^3.2.0",
"mocha": "^9.0.2",
"npmlog": "^4.1.2",
"pre-commit": "^1.1.3",
"prettier": "^1.13.5",
Expand All @@ -100,7 +100,7 @@
"shelljs": "^0.8.2",
"sinon": "4.5.0",
"typescript": "^3.7.0",
"webpack": "^4.28.3",
"webpack": "^5.45.1",
"zen-observable": "^0.6.0"
}
}
14 changes: 7 additions & 7 deletions packages/css-jss/.size-snapshot.json
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
{
"css-jss.js": {
"bundled": 61186,
"minified": 21939,
"gzipped": 7380
"bundled": 61140,
"minified": 21958,
"gzipped": 7389
},
"css-jss.min.js": {
"bundled": 60111,
"minified": 21316,
"gzipped": 7100
"bundled": 60077,
"minified": 21335,
"gzipped": 7109
},
"css-jss.cjs.js": {
"bundled": 3034,
"minified": 1189,
"gzipped": 667
},
"css-jss.esm.js": {
"css-jss.esm.mjs": {
"bundled": 2750,
"minified": 967,
"gzipped": 576,
Expand Down
10 changes: 8 additions & 2 deletions packages/css-jss/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,14 @@
"license": "MIT",
"homepage": "https://cssinjs.org/",
"main": "dist/css-jss.cjs.js",
"module": "dist/css-jss.esm.js",
"module": "dist/css-jss.esm.mjs",
"unpkg": "dist/css-jss.bundle.js",
"exports": {
".": {
"require": "./dist/css-jss.cjs.js",
"import": "./dist/css-jss.esm.mjs"
}
},
"sideEffects": false,
"typings": "./src/index.d.ts",
"author": "JSS Team",
Expand Down Expand Up @@ -38,7 +44,7 @@
"check-snapshot": "node ../../scripts/match-snapshot.js"
},
"dependencies": {
"@babel/runtime": "^7.3.1",
"@babel/runtime": "^7.12.0",
"jss": "10.7.1",
"jss-preset-default": "10.7.1"
}
Expand Down
2 changes: 1 addition & 1 deletion packages/jss-plugin-cache/.size-snapshot.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"minified": 371,
"gzipped": 261
},
"jss-plugin-cache.esm.js": {
"jss-plugin-cache.esm.mjs": {
"bundled": 666,
"minified": 302,
"gzipped": 217,
Expand Down
10 changes: 8 additions & 2 deletions packages/jss-plugin-cache/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,14 @@
"license": "MIT",
"homepage": "https://cssinjs.org/jss-plugin-cache",
"main": "dist/jss-plugin-cache.cjs.js",
"module": "dist/jss-plugin-cache.esm.js",
"module": "dist/jss-plugin-cache.esm.mjs",
"unpkg": "dist/jss-plugin-cache.bundle.js",
"exports": {
".": {
"require": "./dist/jss-plugin-cache.cjs.js",
"import": "./dist/jss-plugin-cache.esm.mjs"
}
},
"sideEffects": false,
"typings": "./src/index.d.ts",
"author": "JSS Team",
Expand Down Expand Up @@ -36,7 +42,7 @@
"check-snapshot": "node ../../scripts/match-snapshot.js"
},
"dependencies": {
"@babel/runtime": "^7.3.1",
"@babel/runtime": "^7.12.0",
"jss": "10.7.1"
}
}
2 changes: 1 addition & 1 deletion packages/jss-plugin-camel-case/.size-snapshot.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"minified": 818,
"gzipped": 420
},
"jss-plugin-camel-case.esm.js": {
"jss-plugin-camel-case.esm.mjs": {
"bundled": 1491,
"minified": 565,
"gzipped": 309,
Expand Down
10 changes: 8 additions & 2 deletions packages/jss-plugin-camel-case/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,14 @@
"license": "MIT",
"homepage": "https://cssinjs.org/jss-camel-case",
"main": "dist/jss-plugin-camel-case.cjs.js",
"module": "dist/jss-plugin-camel-case.esm.js",
"module": "dist/jss-plugin-camel-case.esm.mjs",
"unpkg": "dist/jss-plugin-camel-case.bundle.js",
"exports": {
".": {
"require": "./dist/jss-plugin-camel-case.cjs.js",
"import": "./dist/jss-plugin-camel-case.esm.mjs"
}
},
"sideEffects": false,
"typings": "./src/index.d.ts",
"author": "JSS Team",
Expand Down Expand Up @@ -38,7 +44,7 @@
"jss-plugin-rule-value-function": "10.7.1"
},
"dependencies": {
"@babel/runtime": "^7.3.1",
"@babel/runtime": "^7.12.0",
"hyphenate-style-name": "^1.0.3",
"jss": "10.7.1"
}
Expand Down
4 changes: 2 additions & 2 deletions packages/jss-plugin-compose/.size-snapshot.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"jss-plugin-compose.js": {
"bundled": 2612,
"bundled": 2610,
"minified": 988,
"gzipped": 561
},
Expand All @@ -14,7 +14,7 @@
"minified": 1013,
"gzipped": 528
},
"jss-plugin-compose.esm.js": {
"jss-plugin-compose.esm.mjs": {
"bundled": 1913,
"minified": 764,
"gzipped": 426,
Expand Down
10 changes: 8 additions & 2 deletions packages/jss-plugin-compose/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,14 @@
"license": "MIT",
"homepage": "https://cssinjs.org/jss-compose",
"main": "dist/jss-plugin-compose.cjs.js",
"module": "dist/jss-plugin-compose.esm.js",
"module": "dist/jss-plugin-compose.esm.mjs",
"unpkg": "dist/jss-plugin-compose.bundle.js",
"exports": {
".": {
"require": "./dist/jss-plugin-compose.cjs.js",
"import": "./dist/jss-plugin-compose.esm.mjs"
}
},
"sideEffects": false,
"typings": "./src/index.d.ts",
"author": "JSS Team",
Expand Down Expand Up @@ -36,7 +42,7 @@
"check-snapshot": "node ../../scripts/match-snapshot.js"
},
"dependencies": {
"@babel/runtime": "^7.3.1",
"@babel/runtime": "^7.12.0",
"jss": "10.7.1",
"tiny-warning": "^1.0.2"
}
Expand Down
2 changes: 1 addition & 1 deletion packages/jss-plugin-default-unit/.size-snapshot.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"minified": 3718,
"gzipped": 1194
},
"jss-plugin-default-unit.esm.js": {
"jss-plugin-default-unit.esm.mjs": {
"bundled": 6070,
"minified": 3652,
"gzipped": 1137,
Expand Down
10 changes: 8 additions & 2 deletions packages/jss-plugin-default-unit/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,14 @@
"license": "MIT",
"homepage": "https://cssinjs.org/jss-default-unit",
"main": "dist/jss-plugin-default-unit.cjs.js",
"module": "dist/jss-plugin-default-unit.esm.js",
"module": "dist/jss-plugin-default-unit.esm.mjs",
"unpkg": "dist/jss-plugin-default-unit.bundle.js",
"exports": {
".": {
"require": "./dist/jss-plugin-default-unit.cjs.js",
"import": "./dist/jss-plugin-default-unit.esm.mjs"
}
},
"sideEffects": false,
"typings": "./src/index.d.ts",
"author": "JSS Team",
Expand Down Expand Up @@ -42,7 +48,7 @@
"jss-plugin-rule-value-observable": "10.7.1"
},
"dependencies": {
"@babel/runtime": "^7.3.1",
"@babel/runtime": "^7.12.0",
"jss": "10.7.1"
}
}
10 changes: 5 additions & 5 deletions packages/jss-plugin-expand/.size-snapshot.json
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
{
"jss-plugin-expand.js": {
"bundled": 10520,
"bundled": 10498,
"minified": 4546,
"gzipped": 1528
},
"jss-plugin-expand.min.js": {
"bundled": 10520,
"bundled": 10498,
"minified": 4546,
"gzipped": 1528
},
"jss-plugin-expand.cjs.js": {
"bundled": 9489,
"bundled": 9467,
"minified": 4669,
"gzipped": 1510
},
"jss-plugin-expand.esm.js": {
"bundled": 9407,
"jss-plugin-expand.esm.mjs": {
"bundled": 9385,
"minified": 4600,
"gzipped": 1465,
"treeshaked": {
Expand Down
Loading