diff --git a/changelog.md b/changelog.md index fcaa76001..b54fbafd7 100755 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,6 @@ -## Next / 2018-09-16 +## Next / 2018-12-18 +- [jss-starter-kit] Introduced `jss-starter-kit.bundle.js`, which packages all the other libraries into one import for playgrounds like Codepen. ([#936](https://github.com/cssinjs/jss/pull/936)) - [jss] Fix multiple cases where linking CSS rules didn't work ([#815](https://github.com/cssinjs/jss/pull/815), [#710](https://github.com/cssinjs/jss/pull/710), [#664](https://github.com/cssinjs/jss/pull/664)) - [jss] Added support for Typed CSSOM values ([#882](https://github.com/cssinjs/jss/pull/882)) - [jss] Added scoped keyframes support ([#346](https://github.com/cssinjs/jss/pull/346)) diff --git a/docs/setup.md b/docs/setup.md index ed4bbebff..cd13be716 100644 --- a/docs/setup.md +++ b/docs/setup.md @@ -10,6 +10,9 @@ yarn add jss For bower or direct script injection use [unpkg](https://unpkg.com): +Unminified, bundled ESM: +https://unpkg.com/jss-starter-kit/dist/jss-starter-kit.bundle.js + Unminified UMD: https://unpkg.com/jss/dist/jss.js diff --git a/packages/jss-starter-kit/.size-snapshot.json b/packages/jss-starter-kit/.size-snapshot.json new file mode 100644 index 000000000..08ed80687 --- /dev/null +++ b/packages/jss-starter-kit/.size-snapshot.json @@ -0,0 +1,31 @@ +{ + "dist/jss-starter-kit.js": { + "bundled": 82381, + "minified": 33203, + "gzipped": 9557 + }, + "dist/jss-starter-kit.min.js": { + "bundled": 81265, + "minified": 32683, + "gzipped": 9306 + }, + "dist/jss-starter-kit.cjs.js": { + "bundled": 2480, + "minified": 2273, + "gzipped": 682 + }, + "dist/jss-starter-kit.esm.js": { + "bundled": 1408, + "minified": 1302, + "gzipped": 452, + "treeshaked": { + "rollup": { + "code": 836, + "import_statements": 541 + }, + "webpack": { + "code": 2342 + } + } + } +} diff --git a/packages/jss-starter-kit/LICENSE b/packages/jss-starter-kit/LICENSE new file mode 100644 index 000000000..53d33c7b5 --- /dev/null +++ b/packages/jss-starter-kit/LICENSE @@ -0,0 +1,8 @@ +The MIT License (MIT) +Copyright (c) 2014-present Oleg Isonen/Slobodskoi & contributors + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/packages/jss-starter-kit/package.json b/packages/jss-starter-kit/package.json new file mode 100644 index 000000000..aa4a45e23 --- /dev/null +++ b/packages/jss-starter-kit/package.json @@ -0,0 +1,48 @@ +{ + "name": "jss-starter-kit", + "description": "A bundle to get you started playing with JSS. Not optimized for production deployment.", + "version": "9.8.4", + "license": "MIT", + "homepage": "https://cssinjs.org/", + "main": "dist/jss-starter-kit.cjs.js", + "module": "dist/jss-starter-kit.esm.js", + "unpkg": "dist/jss-starter-kit.bundle.js", + "typings": "./src/index.d.ts", + "author": { + "name": "Oleg Slobodskoi", + "email": "oleg008@gmail.com" + }, + "repository": { + "type": "git", + "url": "git@github.com:cssinjs/jss.git" + }, + "bugs": { + "url": "https://github.com/cssinjs/jss/issues/new" + }, + "files": [ + "dist", + "src", + "LICENSE" + ], + "keywords": [ + "jss", + "style", + "sheet", + "stylesheet", + "css", + "components", + "composable", + "css in js", + "css-in-js" + ], + "scripts": { + "build": "node ../../scripts/build.js", + "check-snapshot": "node ../../scripts/match-snapshot.js" + }, + "dependencies": { + "jss": "^9", + "jss-plugin-cache": "^3", + "jss-plugin-isolate": "^5", + "jss-preset-default": "^4" + } +} diff --git a/packages/jss-starter-kit/readme.md b/packages/jss-starter-kit/readme.md new file mode 100644 index 000000000..82ee304f4 --- /dev/null +++ b/packages/jss-starter-kit/readme.md @@ -0,0 +1,67 @@ +# jss-starter-kit:🚰 the whole kitchen sink + +[![Gitter](https://badges.gitter.im/JoinChat.svg)](https://gitter.im/cssinjs/lobby) + +The `jss-starter-kit` combines all of the other [packages](https://github.com/cssinjs/jss/tree/master/packages) into a single bundle, to make it easy to import directly into a playground like Codepen, or a local HTML file. + +:warning: This bundle includes every JSS package, unminified. It's great for experimenting, but not suitable for production deployment. + +## Quick start + +There's an instance of JSS already set up with all of the default plugins, exported as `jss`. + +```javascript +import {jss} from 'https://unpkg.com/jss-starter-kit' + +// Notice that you can use camel-cased style keys here, because +// the default preset include jss-plugin-syntax-camel-case. If you want to use +// jss in your production application, you'll need to manually install the +// plugins you need. +const {classes} = jss + .createStyleSheet({ + wrapper: { + padding: 40, + background: '#f7df1e', + textAlign: 'center' + }, + title: { + font: { + size: 40, + weight: 900 + }, + color: '#24292e' + }, + link: { + color: '#24292e', + '&:hover': { + opacity: 0.5 + } + } + }) + .attach() + +document.body.innerHTML = ` +
+

Hello JSS!

+ + See docs + +
+` +``` + +## Plugins + +[Every plugin shipped by JSS](https://github.com/cssinjs/jss/tree/master/packages) is included here. See [`index.js`](https://github.com/cssinjs/jss/blob/master/packages/jss-starter-kit/src/index.js) to see the names they are exported as. + +## Issues + +File a bug against [cssinjs/jss prefixed with \[jss-starter-kit\]](https://github.com/cssinjs/jss/issues/new?title=[jss-starter-kit]%20). + +## License + +MIT diff --git a/packages/jss-starter-kit/src/index.js b/packages/jss-starter-kit/src/index.js new file mode 100644 index 000000000..9b58897ad --- /dev/null +++ b/packages/jss-starter-kit/src/index.js @@ -0,0 +1,28 @@ +// @flow +import jss from 'jss' +import preset from 'jss-preset-default' + +console.warn(`The JSS Starter Kit is for learning and experimentation. It's not optimized for production deployment. + +If you'd like to JSS in production, try using the "jss" and "jss-preset-default" bundles directly. See an example at https://github.com/cssinjs/jss#example`) + +jss.setup(preset()) + +export {default as jss} from 'jss' +export {default as preset} from 'jss-preset-default' +export {default as functions} from 'jss-plugin-syntax-rule-value-function' +export {default as observable} from 'jss-plugin-syntax-rule-value-observable' +export {default as template} from 'jss-plugin-syntax-template' +export {default as global} from 'jss-plugin-syntax-global' +export {default as extend} from 'jss-plugin-syntax-extend' +export {default as nested} from 'jss-plugin-syntax-nested' +export {default as compose} from 'jss-plugin-syntax-compose' +export {default as camelCase} from 'jss-plugin-syntax-camel-case' +export {default as defaultUnit} from 'jss-plugin-syntax-default-unit' +export {default as expand} from 'jss-plugin-syntax-expand' +export {default as vendorPrefixer} from 'jss-plugin-vendor-prefixer' +export {default as propsSort} from 'jss-plugin-props-sort' +export {default as isolate} from 'jss-plugin-isolate' +export {default as cache} from 'jss-plugin-cache' + +export default jss diff --git a/readme.md b/readme.md index 4af0a0db3..29ae43c93 100755 --- a/readme.md +++ b/readme.md @@ -50,8 +50,8 @@ If you are a Sass (SCSS) user, this course will show how to express popular Sass ## Example Try it out on [playground](https://codesandbox.io/s/z21lpmvv33). -You need to [setup plugins](docs/setup.md#setup-with-plugins) before. -You can use a [preset](https://github.com/cssinjs/jss-preset-default) for a quick setup with default plugins. +You need to [setup plugins](docs/setup.md#setup-with-plugins) first. +You can use a [preset](https://github.com/cssinjs/jss-preset-default) for a quick setup with default plugins, or try [`jss-starter-kit`](packages/jss-starter-kit) for easy experimentation.. ```javascript import jss from 'jss' diff --git a/rollup.config.js b/rollup.config.js index 3d0fac8d8..c5a3c0d9b 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -46,7 +46,13 @@ const getBabelOptions = ({useESModules}) => ({ }) const commonjsOptions = { - ignoreGlobal: true + ignoreGlobal: true, + // The CommonJS plugin can't resolve the exports in `react` automatically. + // https://github.com/rollup/rollup-plugin-commonjs#custom-named-exports + // https://github.com/reduxjs/react-redux/issues/643#issuecomment-285008041 + namedExports: { + react: ['Component'] + } } const snapshotOptions = { @@ -146,11 +152,9 @@ export default [ commonjs(commonjsOptions), nodeGlobals({process: false}), replace({ + 'process.env.NODE_ENV': JSON.stringify('development'), 'process.env.VERSION': JSON.stringify(pkg.version) }) - // sizeSnapshot barfs with - // [!] (size-snapshot plugin) Error: Error transforming bundle with 'size-snapshot' plugin: ModuleNotFoundError: Module not found: Error: Can't resolve 'jss/node_modules/rollup-plugin-size-snapshot/node_modules/webpack/buildin/harmony-module.js' in '/' - // sizeSnapshot(snapshotOptions), ] } ]