Skip to content

Commit 52cc6b5

Browse files
committed
docs: update documentation
1 parent 5c4202a commit 52cc6b5

File tree

5 files changed

+889
-1319
lines changed

5 files changed

+889
-1319
lines changed

site/docs/apis/project-configuration.md

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,12 @@ module.exports = {
3838
main: ['./src/app/index.js'],
3939
mobile: ['./src/app/mobile.js'],
4040
},
41+
// If enabled, all WordPress provided external scripts, including React
42+
// and ReactDOM are aliased automatically. Do note that all `@wordpress`
43+
// namespaced imports are automatically aliased and enqueued by the
44+
// PHP library. It will not change the JSX pragma because of external
45+
// dependencies.
46+
optimizeForGutenberg: false,
4147
// Extra webpack config to be passed directly
4248
webpackConfig: undefined,
4349
},
@@ -64,6 +70,10 @@ module.exports = {
6470
// Project specific config
6571
// Needs react?
6672
hasReact: true,
73+
// Whether or not to use the new jsx runtime introduced in React 17
74+
// this is opt-in
75+
// @see {https://reactjs.org/blog/2020/09/22/introducing-the-new-jsx-transform.html}
76+
useReactJsxRuntime: false,
6777
// Disable react refresh
6878
disableReactRefresh: false,
6979
// Needs sass?
@@ -155,17 +165,14 @@ it has to be an array of object of a certain shape. First let us see an example.
155165

156166
```js
157167
module.exports = {
158-
// ...
159-
// Files we need to compile, and where to put
160168
files: [
161-
// If this has length === 1, then single compiler
162169
{
163170
name: 'app',
164171
entry: {
165172
main: ['./src/app/index.js'],
166173
mobile: ['./src/app/mobile.js'],
167174
},
168-
// Extra webpack config to be passed directly
175+
optimizeForGutenberg: false,
169176
webpackConfig: undefined,
170177
},
171178
],
@@ -197,7 +204,6 @@ interface EntryConfig {
197204
interface FileConfig {
198205
name: string;
199206
entry: EntryConfig;
200-
typeWatchFiles?: string[];
201207
hasTypeScript?: boolean;
202208
webpackConfig?:
203209
| webpack.Configuration
@@ -240,6 +246,17 @@ code.
240246
It can support both webpack configuration objects or function to get further
241247
control. Kindly read the [_Extending Webpack Config_](/tutorials/extending-webpack-config/) under [tutorials](/tutorials/).
242248

249+
#### `optimizeForGutenberg` (`boolean`):
250+
251+
_since v6.0.0_
252+
253+
If enabled, then all of WordPress managed JavaScript files, including, React,
254+
ReactDOM, lodash, lodash-es, jQuery and everything under `@wordpress` namespace
255+
are automatically marked externals and loaded from global `wp` object.
256+
257+
The new PHP library automatically takes care of loading those WordPress scripts
258+
so you don't have to do anything from your part.
259+
243260
##### Callback Function
244261

245262
The most powerful form is the function. It has the following signature
@@ -291,6 +308,13 @@ You can not pass `rel/path/to/dist` here.
291308

292309
Where you need support for react specific presets, like `jsx`.
293310

311+
## `useReactJsxRuntime` (`boolean`):
312+
313+
_since v6.0.0_
314+
315+
Whether or not to use the new jsx runtime introduced in React 17. This is opt-in
316+
as of now. Please see [here for implications](https://reactjs.org/blog/2020/09/22/introducing-the-new-jsx-transform.html).
317+
294318
## `disableReactRefresh` (`boolean`):
295319

296320
When you have react for your project, wpackio will use react fast refresh
@@ -341,8 +365,6 @@ incorporate [react hot loader](https://github.com/gaearon/react-hot-loader).
341365

342366
```js
343367
module.exports = {
344-
// ...
345-
// Hook into babeloverride so that we can add react-hot-loader plugin
346368
jsBabelOverride: defaults => ({
347369
...defaults,
348370
plugins: ['react-hot-loader/babel'],
@@ -382,7 +404,6 @@ files and reload browser on change. Useful for watching `.php` files.
382404

383405
```js
384406
module.exports = {
385-
// ...
386407
watch: './(inc|includes)/**/*.php',
387408
};
388409
```
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
---
2+
title: Upgrading from v5 to v6 and Breaking Changes
3+
order: -2
4+
shortTitle: Breaking v5 ➡️ v6
5+
---
6+
7+
Version 6 of `@wpackio/scripts` has many improvements. While most of the changes
8+
are kept as backward compatible, some might break your project. So please take
9+
note of the followings.
10+
11+
## POSTCSS VERSION UPDATE
12+
13+
`postcss-loader` has been updated to the very latest and now `postcss` is a
14+
peer dependency. So after updating you'd either need to install `postcss`
15+
16+
```bash
17+
yarn add postcss --dev
18+
```
19+
20+
Or bootstrap again
21+
22+
```bash
23+
yarn bootstrap
24+
```
25+
26+
For CSS processing to work.
27+
28+
## AUTOMATIC WORDPRESS SCRIPTS ALIASING
29+
30+
> If you are not using anything from `@wordpress` package, then you are not affected.
31+
32+
Starting v6, all modules under `@wordpress` namespace will be automatically
33+
marked as externals. So when you do something like
34+
35+
```js
36+
import { __ } from '@wordpress/i18n';
37+
38+
const greetings = __('Hello World', 'domain');
39+
```
40+
41+
It will be roughly compiled into
42+
43+
```js
44+
const { __ } = wp.i18n;
45+
46+
const greetings = __('Hello World', 'domain');
47+
```
48+
49+
But it doesn't mean you have to add `wp-i18n` script dependency manually. If you
50+
are using `wpackio/enqueue` PHP library, then this process is automatic. No code
51+
change is necessary.
52+
53+
We do this by default only for all `@wordpress` namespace packages. We don't do
54+
this for React, ReactDOM, jQuery or any other scripts.
55+
56+
Except when `optimizeForGutenberg` is set to true. Please see [Project Configuration](/apis/project-configuration/#optimizeforgutenberg-boolean) to learn more.
57+
58+
## CHANGES IN MANIFEST
59+
60+
> If you are not dealing with the manifest file directly, then you are not affected.
61+
62+
webpack asset manifest plugin has been updated and it has changed the output
63+
format. Accordingly `wpackio/enqueue` has also been updated (`v3.0.0`). If you
64+
are dealing with the manifest directly, then note instead of
65+
66+
```php
67+
$manifest['wpackioEp'][ $entryPoint ]
68+
```
69+
70+
we now have to do
71+
72+
```php
73+
$manifest['wpackioEp'][ $entryPoint ]['assets']
74+
```
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
---
2+
title: Updating wpackio scripts to the latest version
3+
order: -1
4+
shortTitle: Update wpackio
5+
---
6+
7+
Updating `@wpackio/scripts` and related toolchain is very straight forward and
8+
just like updating any other nodejs dependencies.
9+
10+
First update the package by running
11+
12+
```bash
13+
yarn upgrade-interactive --latest
14+
```
15+
16+
or
17+
18+
```bash
19+
yarn add @wpackio/scripts --dev
20+
# IF USING NPM
21+
npm i --save-dev @wpackio/scripts
22+
```
23+
24+
This will install the latest version.
25+
26+
Now run the following command
27+
28+
```bash
29+
yarn bootstrap
30+
# IF USING NPM
31+
npm run bootstrap
32+
```
33+
34+
This will check for other updates necessary and install the latest version of
35+
needed packages.

site/package.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
"version": "1.0.0",
55
"author": "Kyle Mathews <mathews.kyle@gmail.com>",
66
"dependencies": {
7-
"@svgr/webpack": "5.4.0",
8-
"bulma": "0.9.1",
9-
"classnames": "2.2.6",
7+
"@svgr/webpack": "5.5.0",
8+
"bulma": "0.9.2",
9+
"classnames": "2.3.1",
1010
"docsearch.js": "2.6.3",
1111
"gatsby": "2.27.1",
1212
"gatsby-image": "2.6.0",
@@ -26,8 +26,8 @@
2626
"gatsby-remark-smartypants": "2.5.0",
2727
"gatsby-source-filesystem": "2.6.1",
2828
"gatsby-transformer-remark": "2.11.0",
29-
"node-sass": "4.14.1",
30-
"prismjs": "1.22.0",
29+
"node-sass": "^4.14.1",
30+
"prismjs": "1.23.0",
3131
"prop-types": "15.7.2",
3232
"react": "16.14.0",
3333
"react-dom": "16.14.0",
@@ -46,10 +46,10 @@
4646
},
4747
"devDependencies": {
4848
"@wpackio/eslint-config": "file:../packages/eslint-config",
49-
"eslint": "7.14.0",
49+
"eslint": "7.25.0",
5050
"gatsby-plugin-sharp": "2.9.0",
5151
"gatsby-transformer-sharp": "2.7.0",
52-
"prettier": "2.2.0"
52+
"prettier": "2.2.1"
5353
},
5454
"repository": {
5555
"type": "git",

0 commit comments

Comments
 (0)