Skip to content

Commit

Permalink
Remove --jsx flag, less is more, update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
KidkArolis committed Feb 7, 2022
1 parent 03daf74 commit 661322a
Show file tree
Hide file tree
Showing 10 changed files with 15 additions and 16 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
- **Breaking:** the runtime content is now referenced via `runtime` instead of `assets.runtime` in the template
- **Breaking:** simplified logging behind `--log` flag, choose between `info`, `progress` or `none`, with default being `info,progress`
- **Breaking:** removed support for react-hot-loader, you can still tweak your config to pull it in, but it is no longer automatically configured, use `react-refresh` instead!
- **Breaking:** remove --jsx command line flag, use config instead

# 0.22.0

Expand Down
1 change: 0 additions & 1 deletion docs/01-configuration-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ Options:
-p, --port <n> port, defaults to 3030
-d, --dir [path] run jetpack in the context of this directory
-c, --config config file to use, defaults to jetpack.config.js
--jsx <pragma> specify jsx pragma, defaults to React.createElement or Preact.h if preact is installed
-r, --no-hot disable hot reloading
-u, --no-minify disable minification
-m, --modern build a modern bundle
Expand Down
2 changes: 1 addition & 1 deletion docs/03-customizing-swc.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Customizing Babel
# Customizing SWC

Jetpack uses SWC via swc-loader by default, because:

Expand Down
6 changes: 3 additions & 3 deletions docs/04-customizing-postcss.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Jetpack uses the following PostCSS plugins and presets:

See [lib/webpack.css.js](../lib/webpack.css.js) for the exact configuration.

It's a bit more difficult to extend PostCSS than say Babel. There are 2 options that jetpack provides here.
There are 2 ways to cusotmize postcss config.

## Specify extra postcss-preset-env features

Expand Down Expand Up @@ -43,8 +43,8 @@ module.exports = {
'jetpack/postcss-preset-env': {
autoprefixer: { grid: true }
},
'colorguard': {},
'stylelint': {}
colorguard: {},
stylelint: {}
}
}
```
Expand Down
2 changes: 1 addition & 1 deletion docs/05-customizing-browserslist.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Customizing browserslist

Jetpack compiles your code using `babel-preset-env` and `postcss-preset-env` plugins to ensure the code is ready for all the browsers you support. Those projects follow the lovely [browserlist](https://github.com/browserslist/browserslist) convention.
Jetpack compiles your code using `swc-loader` and `postcss-preset-env` plugins to ensure the code is ready for all the browsers you support. Those projects follow the lovely [browserlist](https://github.com/browserslist/browserslist) convention.

Jetpack supports differential serving, that is it can produce 2 bundles - modern and legacy. By default jetpack only builds a modern bundle using the following browserslist query:

Expand Down
8 changes: 4 additions & 4 deletions docs/07-differential-serving.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,12 @@ app.get('/api/data', (req, res) => {
// or legacy and serve an appropriate entry point
app.get('*', jetpack)

app.listen(3000, function() {
app.listen(3000, function () {
console.log('Running server on http://localhost:3000')
})
```

This is the most convenient option, but can be undesirable if you'd like to avoid shipping the entire jetpack package with all of it's dependencies (i.e. `webpack`, `babel`, `postcss`, etc.) to your production apps. To avoid that, consider installing `jetpack` as a dev dependency and using the standalone `jetpack-serve` package instead.
This is the most convenient option, but can be undesirable if you'd like to avoid shipping the entire jetpack package with all of it's dependencies (i.e. `webpack`, `swc`, `postcss`, etc.) to your production apps. To avoid that, consider installing `jetpack` as a dev dependency and using the standalone `jetpack-serve` package instead.

### jetpack-serve package

Expand All @@ -103,7 +103,7 @@ app.get('/api/data', (req, res) => {
// express.static for the actual assets
app.use(jetpack())

app.listen(3000, function() {
app.listen(3000, function () {
console.log('Running server on http://localhost:3000')
})
```
Expand All @@ -113,7 +113,7 @@ Or if you're using something other than express or want to customise the behavio
```js
const jetpack = require('jetpack-serve')

module.exports = function handle (req, res) {
module.exports = function handle(req, res) {
const isModern = jetpack.regexp({ modern: true }).test(req.headers['user-agent'])
if (isModern) {
// serve modern
Expand Down
2 changes: 2 additions & 0 deletions docs/recipe-04-adding-flow.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Adding Flow

**Note:** This is outdated now that jetpack uses `swc-loader` instead of `babel`.

Flow is a static type checker that helps you write code with fewer bugs. Check out this [introduction to using static types in JavaScript](https://medium.com/@preethikasireddy/why-use-static-types-in-javascript-part-1-8382da1e0adb) if you are new to this concept.

To add Flow to a jetpack project, follow these steps:
Expand Down
1 change: 0 additions & 1 deletion lib/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ program
.option('-p, --port <n>', 'port, defaults to 3030', Number)
.option('-d, --dir [path]', 'run jetpack in the context of this directory')
.option('-c, --config', 'config file to use, defaults to jetpack.config.js')
.option('--jsx <pragma>', 'specify jsx pragma, defaults to React.createElement or Preact.h if preact is installed')
.option('-r, --no-hot', 'disable hot reloading', null)
.option('-u, --no-minify', 'disable minification', null)
.option('-m, --modern', 'build a modern bundle')
Expand Down
2 changes: 1 addition & 1 deletion lib/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ module.exports = function options(command = 'dev', program = {}) {
const options = Object.assign(
{},
configFromFile,
pick(opts, ['port', 'dir', 'exec', 'jsx', 'hot', 'config', 'minify', 'log'])
pick(opts, ['port', 'dir', 'exec', 'hot', 'config', 'minify', 'log'])
)

// if specified in config file
Expand Down
6 changes: 2 additions & 4 deletions test/options.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,7 @@ test('accepts cli flags', (t) => {
opts: () => ({
dir: dir('fixtures', 'pkg-swoosh'),
hot: false,
port: 2800,
jsx: 'React.createElement'
port: 2800
})
}
const opts = options('dev', program)
Expand All @@ -63,8 +62,7 @@ test('accepts cli flags', (t) => {
base('pkg-swoosh', {
hot: false,
entry: './some/path',
port: 2800,
jsx: 'React.createElement'
port: 2800
})
)
})
Expand Down

0 comments on commit 661322a

Please sign in to comment.