Skip to content

Commit 418042f

Browse files
Kocalweaverryan
authored andcommitted
fix(babel): move Babel dependencies to (optional) peerDependencies
1 parent 417981c commit 418042f

Some content is hidden

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

63 files changed

+31837
-1906
lines changed

.github/workflows/testing_apps.yml

+57-7
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
name: Testing apps
1+
name: Testing in real apps
22
on: [push, pull_request]
33

44
jobs:
55
testing_app:
66
strategy:
77
fail-fast: false
88
matrix:
9-
test_app:
9+
app:
1010
- name: npm
1111
working_directory: test_apps/npm
1212
script: |
@@ -15,6 +15,22 @@ jobs:
1515
npm run encore dev
1616
npm run encore production
1717
18+
- name: npm (with Babel)
19+
working_directory: test_apps/npm-with-babel
20+
script: |
21+
npm install --ci
22+
npm add --save-dev ../../webpack-encore.tgz
23+
npm run encore dev
24+
npm run encore production
25+
26+
- name: npm (with external Babel configuration file)
27+
working_directory: test_apps/npm-with-external-babel-config
28+
script: |
29+
npm install --ci
30+
npm add --save-dev ../../webpack-encore.tgz
31+
npm run encore dev
32+
npm run encore production
33+
1834
- name: pnpm
1935
working_directory: test_apps/pnpm
2036
script: |
@@ -23,16 +39,50 @@ jobs:
2339
pnpm run encore dev
2440
pnpm run encore production
2541
42+
- name: pnpm (with Babel)
43+
working_directory: test_apps/pnpm-with-babel
44+
script: |
45+
pnpm install --frozen-lockfile
46+
pnpm add --save-dev ../../webpack-encore.tgz
47+
pnpm run encore dev
48+
pnpm run encore production
49+
50+
- name: pnpm (with external Babel configuration file)
51+
working_directory: test_apps/pnpm-with-external-babel-config
52+
script: |
53+
pnpm install --frozen-lockfile
54+
pnpm add --save-dev ../../webpack-encore.tgz
55+
pnpm run encore dev
56+
pnpm run encore production
57+
2658
- name: Yarn Plug'n'Play
27-
working_directory: test_apps/yarn_pnp
59+
working_directory: test_apps/yarn-pnp
60+
script: |
61+
yarn set version berry
62+
yarn install --frozen-lockfile
63+
yarn add --dev ../../webpack-encore.tgz
64+
yarn run encore dev
65+
yarn run encore production
66+
67+
- name: Yarn Plug'n'Play (with Babel)
68+
working_directory: test_apps/yarn-pnp-with-babel
69+
script: |
70+
yarn set version berry
71+
yarn install --frozen-lockfile
72+
yarn add --dev ../../webpack-encore.tgz
73+
yarn run encore dev
74+
yarn run encore production
75+
76+
- name: Yarn Plug'n'Play (with external Babel configuration file)
77+
working_directory: test_apps/yarn-pnp-with-external-babel-config
2878
script: |
2979
yarn set version berry
3080
yarn install --frozen-lockfile
3181
yarn add --dev ../../webpack-encore.tgz
3282
yarn run encore dev
3383
yarn run encore production
3484
35-
name: ${{ matrix.test_app.name }}
85+
name: ${{ matrix.app.name }}
3686
runs-on: ubuntu-latest
3787

3888
steps:
@@ -44,7 +94,7 @@ jobs:
4494
with:
4595
node-version: '14'
4696

47-
- if: matrix.test_app.name == 'pnpm'
97+
- if: ${{ contains(matrix.app.name, 'pnpm') }}
4898
name: Install pnpm
4999
uses: pnpm/action-setup@v2
50100
with:
@@ -54,5 +104,5 @@ jobs:
54104
run: yarn pack --filename webpack-encore.tgz
55105

56106
- name: Running script
57-
working-directory: ${{ matrix.test_app.working_directory }}
58-
run: ${{ matrix.test_app.script }}
107+
working-directory: ${{ matrix.app.working_directory }}
108+
run: ${{ matrix.app.script }}

lib/features.js

-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,6 @@ const features = {
8282
packages: [
8383
{ name: 'typescript' },
8484
{ name: '@babel/preset-typescript', enforce_version: true },
85-
{ name: '@babel/plugin-proposal-class-properties', enforce_version: true },
8685
],
8786
description: 'process TypeScript files with Babel'
8887
},

lib/loaders/babel.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,13 @@ module.exports = {
5555
presets: [
5656
[require.resolve('@babel/preset-env'), presetEnvOptions]
5757
],
58-
plugins: [require.resolve('@babel/plugin-syntax-dynamic-import')]
58+
plugins: []
5959
});
6060

6161
if (webpackConfig.useBabelTypeScriptPreset) {
6262
loaderFeatures.ensurePackagesExistAndAreCorrectVersion('typescript-babel');
6363

6464
babelConfig.presets.push([require.resolve('@babel/preset-typescript'), webpackConfig.babelTypeScriptPresetOptions]);
65-
babelConfig.plugins.push(require.resolve('@babel/plugin-proposal-class-properties'));
6665
}
6766

6867
if (webpackConfig.useReact) {

package.json

+9-7
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,6 @@
2727
},
2828
"homepage": "https://github.com/symfony/webpack-encore",
2929
"dependencies": {
30-
"@babel/core": "^7.17.0",
31-
"@babel/plugin-syntax-dynamic-import": "^7.8.0",
32-
"@babel/preset-env": "^7.16.0",
3330
"@nuxt/friendly-errors-webpack-plugin": "^2.5.1",
3431
"assets-webpack-plugin": "7.0.*",
3532
"babel-loader": "^8.2.5",
@@ -52,9 +49,10 @@
5249
"yargs-parser": "^21.0.0"
5350
},
5451
"devDependencies": {
52+
"@babel/core": "^7.17.0",
5553
"@babel/eslint-parser": "^7.17.0",
56-
"@babel/plugin-proposal-class-properties": "^7.0.0",
5754
"@babel/plugin-transform-react-jsx": "^7.12.11",
55+
"@babel/preset-env": "^7.16.0",
5856
"@babel/preset-react": "^7.0.0",
5957
"@babel/preset-typescript": "^7.0.0",
6058
"@hotwired/stimulus": "^3.0.0",
@@ -103,8 +101,9 @@
103101
"zombie": "^6.1.4"
104102
},
105103
"peerDependencies": {
106-
"@babel/plugin-proposal-class-properties": "^7.0.0",
104+
"@babel/core": "^7.17.0",
107105
"@babel/plugin-transform-react-jsx": "^7.12.11",
106+
"@babel/preset-env": "^7.16.0",
108107
"@babel/preset-react": "^7.0.0",
109108
"@babel/preset-typescript": "^7.0.0",
110109
"@symfony/stimulus-bridge": "^3.0.0",
@@ -135,12 +134,15 @@
135134
"webpack-notifier": "^1.15.0"
136135
},
137136
"peerDependenciesMeta": {
138-
"@babel/plugin-proposal-class-properties": {
139-
"optional": true
137+
"@babel/core": {
138+
"optional": false
140139
},
141140
"@babel/plugin-transform-react-jsx": {
142141
"optional": true
143142
},
143+
"@babel/preset-env": {
144+
"optional": false
145+
},
144146
"@babel/preset-react": {
145147
"optional": true
146148
},

test/functional.js

-4
Original file line numberDiff line numberDiff line change
@@ -1858,7 +1858,6 @@ module.exports = {
18581858
corejs: 3,
18591859
}]
18601860
],
1861-
plugins: ['@babel/plugin-syntax-dynamic-import']
18621861
} `
18631862
);
18641863

@@ -1950,9 +1949,6 @@ module.exports = {
19501949
config.setPublicPath('/build');
19511950
config.addEntry('main', './stimulus/assets/app.js');
19521951
config.enableStimulusBridge(__dirname + '/../fixtures/stimulus/assets/controllers.json');
1953-
config.configureBabel(function(config) {
1954-
config.plugins.push('@babel/plugin-proposal-class-properties');
1955-
});
19561952

19571953
testSetup.runWebpack(config, (webpackAssert) => {
19581954
expect(config.outputPath).to.be.a.directory().with.deep.files([

test/loaders/babel.js

-4
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,6 @@ describe('loaders/babel', () => {
9191
const actualLoaders = babelLoader.getLoaders(config);
9292

9393
expect(actualLoaders[0].options.plugins).to.deep.include.members([
94-
require.resolve('@babel/plugin-syntax-dynamic-import'),
9594
[require.resolve('@babel/plugin-transform-react-jsx'), { pragma: 'h' }],
9695
'foo'
9796
]);
@@ -108,7 +107,6 @@ describe('loaders/babel', () => {
108107
const actualLoaders = babelLoader.getLoaders(config);
109108

110109
expect(actualLoaders[0].options.plugins).to.deep.include.members([
111-
require.resolve('@babel/plugin-syntax-dynamic-import'),
112110
[require.resolve('@babel/plugin-transform-react-jsx')],
113111
'foo'
114112
]);
@@ -183,8 +181,6 @@ describe('loaders/babel', () => {
183181
expect(actualLoaders[0].options.presets[1][0]).to.equal(require.resolve('@babel/preset-typescript'));
184182
expect(actualLoaders[0].options.presets[1][1]).to.equal(presetTypeScriptOptions);
185183
expect(actualLoaders[0].options.plugins).to.deep.include.members([
186-
require.resolve('@babel/plugin-syntax-dynamic-import'),
187-
require.resolve('@babel/plugin-proposal-class-properties'),
188184
'foo'
189185
]);
190186
});

test_apps/npm-with-babel/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
public/build

test_apps/npm-with-babel/README.md

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Testing app: npm (with Babel)
2+
3+
This testing app is used to test how Encore installation and usage work when using the [**npm** package manager](https://docs.npmjs.com/cli/).
4+
5+
## Installation
6+
7+
```shell
8+
$ (cd ../..; yarn pack --filename webpack-encore.tgz)
9+
$ npm add --save-dev ../../webpack-encore.tgz
10+
$ npm install
11+
```
12+
13+
## Usage
14+
15+
```
16+
$ npm run encore dev
17+
$ npm run encore production
18+
```
+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/*
2+
* This file is part of the Symfony Webpack Encore package.
3+
*
4+
* (c) Fabien Potencier <[email protected]>
5+
*
6+
* For the full copyright and license information, please view the LICENSE
7+
* file that was distributed with this source code.
8+
*/
9+
10+
'use strict';
11+
12+
console.log('Hello world!');
13+
14+
function add(x, y) { return x + y; }
15+
const addOne = add(1, ?);
16+
console.log(addOne(2))

0 commit comments

Comments
 (0)