Skip to content

Commit 970cebb

Browse files
authored
Merge branch 'master' into github-actions
2 parents e115b2e + 6a734c4 commit 970cebb

35 files changed

Lines changed: 11509 additions & 165 deletions

.eslintignore

Lines changed: 0 additions & 1 deletion
This file was deleted.

.eslintrc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,8 @@
1717
"react": {
1818
"version": "16.6"
1919
}
20-
}
20+
},
21+
"ignorePatterns": [
22+
"dist"
23+
]
2124
}

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ node_modules
77
.rts2_cache_umd
88
build
99
dist
10-
package-lock.json
1110
yarn.lock
1211
.vscode
1312
.idea

.npmrc

Lines changed: 0 additions & 1 deletion
This file was deleted.

.prettierignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
dist/

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2017-present Jason Miller
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 38 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,12 @@
2929

3030
```js
3131
{
32-
"source": "src/foo.js", // Your source file (same as 1st arg to microbundle)
33-
"main": "dist/foo.js", // output path for CommonJS/Node
34-
"module": "dist/foo.mjs", // output path for JS Modules
35-
"unpkg": "dist/foo.umd.js", // optional, for unpkg.com
32+
"source": "src/foo.js", // Your source file (same as 1st arg to microbundle)
33+
"main": "dist/foo.js", // output path for CommonJS/Node
34+
"module": "dist/foo.module.js", // output path for JS Modules
35+
"unpkg": "dist/foo.umd.js", // optional, for unpkg.com
3636
"scripts": {
37-
"build": "microbundle", // uses "source" and "main" as input and output paths by default
37+
"build": "microbundle", // uses "source" and "main" as input and output paths by default
3838
"dev": "microbundle watch"
3939
}
4040
}
@@ -68,8 +68,8 @@ This is enabled by default - all you have to do is add the field to your `packag
6868

6969
```js
7070
{
71-
"main": "dist/foo.umd.js", // legacy UMD bundle (for Node & CDN's)
72-
"module": "dist/foo.modern.mjs", // modern ES2017 bundle
71+
"main": "dist/foo.umd.js", // legacy UMD bundle (for Node & CDN's)
72+
"module": "dist/foo.modern.module.js", // modern ES2017 bundle
7373
"scripts": {
7474
"build": "microbundle src/foo.js -f modern,umd"
7575
}
@@ -94,6 +94,26 @@ Acts just like `microbundle build`, but watches your source files and rebuilds o
9494

9595
Just point the input to a `.ts` file through either the cli or the `source` key in your `package.json` and you’re done.
9696

97+
### Using CSS Modules
98+
99+
By default any css file imported as `.module.css`, will be treated as a css-module. If you wish to treat all .css
100+
imports as a module, specify the cli flag `--css-modules true`. If you wish to disable all css-module behaviours set the
101+
flag to `false`.
102+
103+
The default scope name when css-modules is turned on will be, in watch mode `_[name]__[local]__[hash:base64:5]` and when
104+
you build `_[hash:base64:5]`. This can be overriden by specifying the flag, eg
105+
`--css-modules "_something_[hash:base64:7]"`. _Note:_ by setting this, it will be treated as a true, and thus, all .css
106+
imports will be scoped.
107+
108+
| flag | import | is css module? |
109+
| ----- | ------------------------------ | :----------------: |
110+
| null | import './my-file.css'; | :x: |
111+
| null | import './my-file.module.css'; | :white_check_mark: |
112+
| false | import './my-file.css'; | :x: |
113+
| false | import './my-file.module.css'; | :x: |
114+
| true | import './my-file.css'; | :white_check_mark: |
115+
| true | import './my-file.module.css'; | :white_check_mark: |
116+
97117
### Specifying builds in `package.json`
98118

99119
You can specify output builds in a `package.json` as follows:
@@ -108,16 +128,18 @@ You can specify output builds in a `package.json` as follows:
108128

109129
### Mangling Properties
110130

111-
Libraries often wish to rename internal object properties or class members to smaller names - transforming `this._internalIdValue` to `this._i`. Microbundle doesn't currently do this by default, but it can be enabled by adding a "mangle" property to your package.json, with a pattern to control when properties should be mangled. To mangle all property names beginning an underscore, add the following:
131+
To achieve the smallest possible bundle size, libraries often wish to rename internal object properties or class members to smaller names - transforming `this._internalIdValue` to `this._i`. Microbundle doesn't do this by default, however it can be enabled by createing a `mangle.json` file (or a `"mangle"` property in your package.json). Within that file, you can specify a regular expression pattern to control which properties should be mangled. For example: to mangle all property names beginning an underscore:
112132

113133
```json
114134
{
115-
"mangle": {
116-
"regex": "^_"
117-
}
135+
"mangle": {
136+
"regex": "^_"
137+
}
118138
}
119139
```
120140

141+
It's also possible to configure repeatable short names for each mangled property, so that every build of your library has the same output. **See the wiki for a [complete guide to property mangling in Microbundle](https://github.com/developit/microbundle/wiki/mangle.json).**
142+
121143
### All CLI Options
122144

123145
```
@@ -151,6 +173,7 @@ Options
151173
--raw Show raw byte size (default false)
152174
--jsx A custom JSX pragma like React.createElement (default: h)
153175
--tsconfig Specify the path to a custom tsconfig.json
176+
--css-modules Configures .css to be treated as modules (default: null)
154177
-h, --help Displays this message
155178
156179
Examples
@@ -174,12 +197,16 @@ Here's what's coming up for Microbundle:
174197
- [Preact](https://github.com/preactjs/preact) Fast 3kB React alternative with the same modern API. Components & Virtual DOM.
175198
- [Stockroom](https://github.com/developit/stockroom) Offload your store management to a worker easily.
176199
- [Microenvi](https://github.com/fwilkerson/microenvi) Bundle, serve, and hot reload with one command.
200+
- [Theme UI](https://github.com/system-ui/theme-ui) Build consistent, themeable React apps based on constraint-based design principles.
177201
- [react-recomponent](https://github.com/philipp-spiess/react-recomponent) Reason-style reducer components for React using ES6 classes.
178202
- [brazilian-utils](https://github.com/brazilian-utils/brazilian-utils) Utils library for specific Brazilian businesses.
179203
- [react-hooks-lib](https://github.com/beizhedenglong/react-hooks-lib) A set of reusable react hooks.
180204
- [mdx-deck-live-code](https://github.com/JReinhold/mdx-deck-live-code) A library for [mdx-deck](https://github.com/jxnblk/mdx-deck) to do live React and JS coding directly in slides.
181205
- [react-router-ext](https://github.com/ri7nz/react-router-ext) An Extended [react-router-dom](https://github.com/ReactTraining/react-router/tree/master/packages/react-router-dom) with simple usage.
182206
- [routex.js](https://github.com/alexhoma/routex.js) A dynamic routing library for Next.js.
207+
- [hooked-form](https://github.com/JoviDeCroock/hooked-form) A lightweight form-management library for React.
208+
- [goober](https://github.com/cristianbote/goober) Less than 1KB css-in-js alternative with a familiar API.
209+
- [react-model](https://github.com/byte-fe/react-model) The next generation state management library for React
183210

184211
## 🥂 License
185212

bors.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ status = [
22
"continuous-integration/travis-ci/push",
33
]
44
delete_merged_branches = true
5+
use_squash_merge = true

lint-staged.config.js

Lines changed: 0 additions & 4 deletions
This file was deleted.

0 commit comments

Comments
 (0)