Skip to content

Commit c247131

Browse files
authored
Merge pull request #324 from symfony/webpack4
Hello Webpack4 ⭐️
2 parents 63e15ce + ab109cd commit c247131

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+4015
-2755
lines changed

.travis.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,16 @@ cache:
99
matrix:
1010
include:
1111
- os: linux
12-
node_js: "7"
12+
node_js: "10"
1313
env: JOB_PART=travis:lint
1414
- os: linux
15-
node_js: "8"
15+
node_js: "10"
16+
env: JOB_PART=test
17+
- os: linux
18+
node_js: "9"
1619
env: JOB_PART=test
1720
- os: linux
18-
node_js: "7"
21+
node_js: "8"
1922
env: JOB_PART=test
2023
- os: linux
2124
node_js: "6"

CHANGELOG.md

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,85 @@
11
# CHANGELOG
22

3+
## 0.21.0 Webpack 4 Upgrade
4+
5+
* [BC BREAK] Webpack was upgraded to version 4. This includes a number of major
6+
and minor changes. The changes are listed below.
7+
8+
* [DEPRECATION] You must now call either `Encore.enableSingleRuntimeChunk()`
9+
or `Encore.disableSingleRuntimeChunk()`: not calling either method is
10+
deprecated. The recommended setting is `Encore.enableSingleRuntimeChunk()`.
11+
This will cause a new `runtime.js` file to be created, which must be included
12+
on your page with a script tag (before any other script tags for Encore
13+
JavaScript files). See the documentation above `enableSingleRuntimeChunk()` in
14+
`index.js` for more details.
15+
16+
* [BEHAVIOR CHANGE] Previously, without any config, Babel was
17+
configured to "transpile" (i.e. re-write) your JavaScript so
18+
that it was compatible with all browsers that currently have
19+
more than 1% of the market share. The new default behavior
20+
is a bit more aggressive, and may rewrite even more code to
21+
be compatible with even older browsers. The *recommendation*
22+
is to add a new `browserslist` key to your `package.json` file
23+
that specifies exactly what browsers you need to support. For
24+
example, to get the old configuration, add the following to
25+
`package.json`:
26+
27+
```json
28+
{
29+
"browserslist": "> 1%"
30+
}
31+
```
32+
33+
See the [browserslist](https://github.com/browserslist/browserslist) library
34+
for a full description of all of the valid browser descriptions.
35+
36+
* Node 7 is no longer supported. This is because the new
37+
`mini-css-extract-plugin` does not support it (and neither)
38+
does Yarn.
39+
40+
* Introduced a new `configureSplitChunks()` method that can be
41+
used to further configure the `optimizations.splitChunks` configuration.
42+
43+
* A new `entrypoints.json` file is now always output. For expert
44+
use-cases, the `optimizations.splitChunks.chunks` configuration
45+
can be set via `configureSplitChunks()` to `all`. Then, you
46+
can write some custom server-side code to parse the `entrypoints.js`
47+
so that you know which `script` and `link` tags are needed for
48+
each entry.
49+
50+
* The "dynamic import" syntax is now supported out of the box
51+
because the `@babel/plugin-syntax-dynamic-import` babel plugin
52+
is always enabled. This allows you to do "Dynamic Imports"
53+
as described here: https://webpack.js.org/guides/code-splitting/#dynamic-imports
54+
55+
* For Preact, the necessary plugin the user needs to install
56+
changed from `babel-plugin-transform-react-jsx` to `@babel/plugin-transform-react-jsx`.
57+
58+
* The NamedModulesPlugin was removed.
59+
60+
* The `babel-preset-env` package (which was at version ^1.2.2) was
61+
removed in favor of `@babel/preset-env`.
62+
63+
* ExtractTextPlugin was removed and replaced with
64+
mini-css-extract-plugin. Accordingly, `extractTextPluginOptionsCallback()`
65+
was removed.
66+
67+
* Support for CoffeeScript was entirely removed.
68+
69+
* A new "version check" system was added for optional dependencies.
70+
Now, when you install optional plugins to support a feature, if
71+
you are using an unsupported version, you will see a warning.
72+
"Package recommendation" errors (i.e. when you enable a feature
73+
but you are missing some packages) will also contain the version
74+
in the install string when necessary (e.g. `yarn add foo@^2.0`).
75+
76+
* Actual lang="sass" no longer works for Vue. However, lang="scss"
77+
continues to work fine.
78+
79+
* uglifyjs-webpack-plugin was upgraded from 0.4.6 to 1.2.5, which
80+
includes using `uglify-es`. If you're using `configureUglifyJsPlugin`(),
81+
the options have changed.
82+
383
## 0.20.1
484

585
* Upgraded webpack-manifest-plugin from 2.0.0 RC1 to ^2.0.0.

bin/encore.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,20 @@
1313
const parseRuntime = require('../lib/config/parse-runtime');
1414
const context = require('../lib/context');
1515
const chalk = require('chalk');
16+
const logger = require('../lib/logger');
1617

1718
const runtimeConfig = parseRuntime(
1819
require('yargs/yargs')(process.argv.slice(2)).argv,
1920
process.cwd()
2021
);
2122
context.runtimeConfig = runtimeConfig;
2223

23-
// remove the command from the output
24+
// prevent logs from being dumped
25+
if (runtimeConfig.outputJson) {
26+
logger.quiet();
27+
}
28+
29+
// remove the command from the input
2430
process.argv.splice(2, 1);
2531

2632
if (!runtimeConfig.isValidCommand) {

fixtures/js/append_to_app.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
document.getElementById('app').innerHTML = document.getElementById('app').innerHTML + 'Welcome to Encore!';
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// use code splitting via a dynamic import
2+
import('./print_to_app_export').then(printToApp => {
3+
printToApp.default();
4+
});

fixtures/js/index.coffee

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

fixtures/js/print_to_app.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
document.getElementById('app').innerHTML = 'Welcome to Encore!';

fixtures/js/print_to_app_export.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export default function() {
2+
document.getElementById('app').innerHTML = 'Welcome to Encore!';
3+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
require('./arrow_function');

fixtures/js/shared_example.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// used in a createdSharedEntry() test
2+
require('./no_require');
3+
require('./requires_arrow_function');
4+
require('./../css/h1_style.css');
5+
require('./print_to_app');

0 commit comments

Comments
 (0)