Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for pnpm and Yarn PnP #1142

Merged
merged 1 commit into from
Aug 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 58 additions & 0 deletions .github/workflows/testing_apps.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: Testing apps
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a more descriptive name we could use here?

Copy link
Member Author

@Kocal Kocal Aug 24, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know, this workflow means to test the installation and run of Encore on real projects/app.

Do you have something in mind?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You may have just suggested a good one

name: Testing installation in real apps

on: [push, pull_request]

jobs:
testing_app:
strategy:
fail-fast: false
matrix:
test_app:
- name: npm
working_directory: test_apps/npm
script: |
npm install --ci
npm add --save-dev ../../webpack-encore.tgz
Copy link
Member Author

@Kocal Kocal Aug 26, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Installing the webpack-encore.tgz (packed in a previous step before) here instead of having it in the package.json, prevents the package manager to fails if checksums are different, which was the case for npm/pnpm/yarn pnp.

npm run encore dev
npm run encore production

- name: pnpm
working_directory: test_apps/pnpm
script: |
pnpm install --frozen-lockfile
pnpm add --save-dev ../../webpack-encore.tgz
pnpm run encore dev
pnpm run encore production

- name: Yarn Plug'n'Play
working_directory: test_apps/yarn_pnp
script: |
yarn set version berry
yarn install --frozen-lockfile
yarn add --dev ../../webpack-encore.tgz
yarn run encore dev
yarn run encore production

name: ${{ matrix.test_app.name }}
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v2.0.0

- name: Node ${{matrix.node-versions}}
uses: actions/setup-node@v2
with:
node-version: '14'

- if: matrix.test_app.name == 'pnpm'
name: Install pnpm
uses: pnpm/action-setup@v2
with:
version: latest

- name: Packing Encore
run: yarn pack --filename webpack-encore.tgz

- name: Running script
working-directory: ${{ matrix.test_app.working_directory }}
run: ${{ matrix.test_app.script }}
32 changes: 1 addition & 31 deletions lib/WebpackConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,44 +36,14 @@ function validateRuntimeConfig(runtimeConfig) {
}
}

/**
* @param {RuntimeConfig} runtimeConfig
* @return {void}
*/
function checkPackageJson(runtimeConfig) {
// Display a warning if webpack is listed as a [dev-]dependency
try {
const packageInfo = JSON.parse(
fs.readFileSync(path.resolve(runtimeConfig.context, 'package.json'), { encoding: 'utf-8' })
);

if (packageInfo) {
const dependencies = new Set([
...(packageInfo.dependencies ? Object.keys(packageInfo.dependencies) : []),
...(packageInfo.devDependencies ? Object.keys(packageInfo.devDependencies) : []),
]);

if (dependencies.has('webpack')) {
logger.warning('Webpack is already provided by Webpack Encore, also adding it to your package.json file may cause issues.');
}
}
} catch (e) {
logger.warning('Could not read package.json file.');
}
}

class WebpackConfig {
constructor(runtimeConfig, enablePackageJsonCheck = false) {
constructor(runtimeConfig) {
validateRuntimeConfig(runtimeConfig);

if (runtimeConfig.verbose) {
logger.verbose();
}

if (enablePackageJsonCheck) {
checkPackageJson(runtimeConfig);
}

this.runtimeConfig = runtimeConfig;
this.entries = new Map();
this.styleEntries = new Map();
Expand Down
16 changes: 8 additions & 8 deletions lib/loaders/babel.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,22 +53,22 @@ module.exports = {

Object.assign(babelConfig, {
presets: [
['@babel/preset-env', presetEnvOptions]
[require.resolve('@babel/preset-env'), presetEnvOptions]
],
plugins: ['@babel/plugin-syntax-dynamic-import']
plugins: [require.resolve('@babel/plugin-syntax-dynamic-import')]
});

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

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

if (webpackConfig.useReact) {
loaderFeatures.ensurePackagesExistAndAreCorrectVersion('react');

babelConfig.presets.push('@babel/react');
babelConfig.presets.push(require.resolve('@babel/preset-react'));
}

if (webpackConfig.usePreact) {
Expand All @@ -77,20 +77,20 @@ module.exports = {
if (webpackConfig.preactOptions.preactCompat) {
// If preact-compat is enabled tell babel to
// transform JSX into React.createElement calls.
babelConfig.plugins.push(['@babel/plugin-transform-react-jsx']);
babelConfig.plugins.push([require.resolve('@babel/plugin-transform-react-jsx')]);
} else {
// If preact-compat is disabled tell babel to
// transform JSX into Preact h() calls.
babelConfig.plugins.push([
'@babel/plugin-transform-react-jsx',
require.resolve('@babel/plugin-transform-react-jsx'),
{ 'pragma': 'h' }
]);
}
}

if (webpackConfig.useVueLoader && webpackConfig.vueOptions.useJsx) {
loaderFeatures.ensurePackagesExistAndAreCorrectVersion('vue-jsx');
babelConfig.presets.push('@vue/babel-preset-jsx');
babelConfig.presets.push(require.resolve('@vue/babel-preset-jsx'));
}

babelConfig = applyOptionsCallback(webpackConfig.babelConfigurationCallback, babelConfig);
Expand Down
129 changes: 127 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,9 @@
"semver": "^7.3.2",
"style-loader": "^3.3.0",
"sync-rpc": "^1.3.6",
"tapable": "^2.2.1",
"terser-webpack-plugin": "^5.3.0",
"tmp": "^0.2.1",
"webpack": "^5.72",
"webpack-cli": "^4.9.1",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will this mean that webpack and webpack-cli will now need to live in the user's package.json?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For webpack yes, but for webpack-cli it looks like it depends of what package manager/script runner the user use.

If you take a look to package.json files used in Yarn PNP and pnpm testing apps, you will notice:

  • the Yarn PNP project need to require (as dev dependency) webpack-cli, otherwise Encore won't be able to run (I don't remeber the issue, but it can be easily reproduced)
  • the pnpm project need to not require webpack-cli, otherwise Encore won't be able to run either 🤔 (and I don't remember the issue aswell)

Maybe Yarn PNP and pnpm have a different way to deal with dependencies's peer dependencies.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes. But this is necessary anyway as soon as you want to install an extra webpack plugin and being sure that it uses the same webpack version than the one used for the build, which is a must-have. If we want to hide the tool, we need to hide it entirely, which is not the purpose of Encore as it is a configurable tool.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep. In our case we need to use the same version of webpack between Encore and Cypress for Component testing, otherwise we got this kind of error:
image

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The situation about webpack-cli is still not clear to me:

A) (?) For non-PNP, you will or won't need to install webpack-cli? Which is it?
B) For Yarn PNP, it MUST be installed
C) For pnpm it must NOT be installed

Will the code in Webpack's executable (https://github.com/webpack/webpack/blob/9fcaa243573005d6fdece9a3f8d89a0e8b399613/bin/webpack.js#L90-L118) effectively enforce whether or not the user will need to install it?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A) For npm (8), If webpack-cli is installed (or not) alongside webpack, then webpack prompts to install webpack-cli:

➜  npm git:(fix/GH-655) ✗ npm version
{
  npm: '8.3.1',
  node: '16.14.0',
  v8: '9.4.146.24-node.20',
  uv: '1.43.0',
  zlib: '1.2.11',
  brotli: '1.0.9',
  ares: '1.18.1',
  modules: '93',
  nghttp2: '1.45.1',
  napi: '8',
  llhttp: '6.0.4',
  openssl: '1.1.1m+quic',
  cldr: '40.0',
  icu: '70.1',
  tz: '2021a3',
  unicode: '14.0',
  ngtcp2: '0.1.0-DEV',
  nghttp3: '0.1.0-DEV'
}
➜  npm git:(fix/GH-655) ✗ npm run encore dev

> encore
> encore "dev"

Running webpack ...

CLI for webpack must be installed.
  webpack-cli (https://github.com/webpack/webpack-cli)

We will use "npm" to install the CLI via "npm install -D webpack-cli".
Do you want to install 'webpack-cli' (yes/no): %

And if I type yes, webpack is not able to find webpack-cli/package.json anymore:

➜  npm git:(fix/GH-655) ✗ npm run encore dev

> encore
> encore "dev"

Running webpack ...

CLI for webpack must be installed.
  webpack-cli (https://github.com/webpack/webpack-cli)

We will use "npm" to install the CLI via "npm install -D webpack-cli".
Do you want to install 'webpack-cli' (yes/no): yes
Installing 'webpack-cli' (running 'npm install -D webpack-cli')...

added 40 packages, and audited 120 packages in 709ms

15 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities
Error: Cannot find module 'webpack-cli/package.json'
Require stack:
- /Users/halliaume/workspace-os/webpack-encore/node_modules/webpack/bin/webpack.js
- /Users/halliaume/workspace-os/webpack-encore/bin/encore.js
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
    at Function.resolve (node:internal/modules/cjs/helpers:108:19)
    at runCli (/Users/halliaume/workspace-os/webpack-encore/node_modules/webpack/bin/webpack.js:65:26)
    at /Users/halliaume/workspace-os/webpack-encore/node_modules/webpack/bin/webpack.js:154:5
    at processTicksAndRejections (node:internal/process/task_queues:96:5) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/Users/halliaume/workspace-os/webpack-encore/node_modules/webpack/bin/webpack.js',
    '/Users/halliaume/workspace-os/webpack-encore/bin/encore.js'
  ]
}

B) For Yarn PNP, if webpack-cli is not installed alongside webpack, we have the following error when running Encore :

➜  yarn_pnp git:(fix/GH-655) ✗ yarn encore dev
Running webpack ...

/Users/halliaume/workspace-os/webpack-encore/test_apps/yarn_pnp/.pnp.cjs:17149
      Error.captureStackTrace(firstError);
            ^

Error: webpack tried to access webpack-cli (a peer dependency) but it isn't provided by its ancestors; this makes the require call ambiguous and unsound.

Required package: webpack-cli (via "webpack-cli/package.json")
Required by: webpack@virtual:dc3fc578bfa5e06182a4d2be39ede0bc5b74940b1ffe0d70c26892ab140a4699787750fba175dc306292e80b4aa2c8c5f68c2a821e69b2c37e360c0dff36ff66#npm:5.74.0 (via /Users/halliaume/workspace-os/webpack-encore/test_apps/yarn_pnp/.yarn/__virtual__/webpack-virtual-56df3fe76f/0/cache/webpack-npm-5.74.0-f5b838a00d-320c41369a.zip/node_modules/webpack/bin/)

Ancestor breaking the chain: @nuxt/friendly-errors-webpack-plugin@virtual:88b9d4c96fcb105b7912cf41ba60d36a65b77cc85cb7e2f55cdd948cb01c6273c2b3f87cf3b37f43c721a4b2a3c78362f07f9f591b99690320400302ac172c1d#npm:2.5.2
Ancestor breaking the chain: @symfony/webpack-encore@virtual:dc3fc578bfa5e06182a4d2be39ede0bc5b74940b1ffe0d70c26892ab140a4699787750fba175dc306292e80b4aa2c8c5f68c2a821e69b2c37e360c0dff36ff66#portal:../..::locator=root-workspace-0b6124%40workspace%3A.
Ancestor breaking the chain: assets-webpack-plugin@virtual:88b9d4c96fcb105b7912cf41ba60d36a65b77cc85cb7e2f55cdd948cb01c6273c2b3f87cf3b37f43c721a4b2a3c78362f07f9f591b99690320400302ac172c1d#npm:7.0.0
Ancestor breaking the chain: babel-loader@virtual:88b9d4c96fcb105b7912cf41ba60d36a65b77cc85cb7e2f55cdd948cb01c6273c2b3f87cf3b37f43c721a4b2a3c78362f07f9f591b99690320400302ac172c1d#npm:8.2.5
Ancestor breaking the chain: clean-webpack-plugin@virtual:88b9d4c96fcb105b7912cf41ba60d36a65b77cc85cb7e2f55cdd948cb01c6273c2b3f87cf3b37f43c721a4b2a3c78362f07f9f591b99690320400302ac172c1d#npm:4.0.0
Ancestor breaking the chain: css-loader@virtual:88b9d4c96fcb105b7912cf41ba60d36a65b77cc85cb7e2f55cdd948cb01c6273c2b3f87cf3b37f43c721a4b2a3c78362f07f9f591b99690320400302ac172c1d#npm:6.7.1
Ancestor breaking the chain: css-minimizer-webpack-plugin@virtual:88b9d4c96fcb105b7912cf41ba60d36a65b77cc85cb7e2f55cdd948cb01c6273c2b3f87cf3b37f43c721a4b2a3c78362f07f9f591b99690320400302ac172c1d#npm:4.0.0
Ancestor breaking the chain: mini-css-extract-plugin@virtual:88b9d4c96fcb105b7912cf41ba60d36a65b77cc85cb7e2f55cdd948cb01c6273c2b3f87cf3b37f43c721a4b2a3c78362f07f9f591b99690320400302ac172c1d#npm:2.6.1
Ancestor breaking the chain: root-workspace-0b6124@workspace:.
Ancestor breaking the chain: style-loader@virtual:88b9d4c96fcb105b7912cf41ba60d36a65b77cc85cb7e2f55cdd948cb01c6273c2b3f87cf3b37f43c721a4b2a3c78362f07f9f591b99690320400302ac172c1d#npm:3.3.1
Ancestor breaking the chain: terser-webpack-plugin@virtual:88b9d4c96fcb105b7912cf41ba60d36a65b77cc85cb7e2f55cdd948cb01c6273c2b3f87cf3b37f43c721a4b2a3c78362f07f9f591b99690320400302ac172c1d#npm:5.3.3
Ancestor breaking the chain: webpack-dev-middleware@virtual:6299a4ab64fb92119dc9f6fc2240d23765f58c7d6b46ef18176fa5a773fddeeadb64458c8e83463926a516c544f2edf4a78bfef3cdbf97ab1a34bef7fa72b0ef#npm:5.3.3


Require stack:
- /Users/halliaume/workspace-os/webpack-encore/test_apps/yarn_pnp/.yarn/__virtual__/webpack-virtual-56df3fe76f/0/cache/webpack-npm-5.74.0-f5b838a00d-320c41369a.zip/node_modules/webpack/bin/webpack.js
- /Users/halliaume/workspace-os/webpack-encore/test_apps/yarn_pnp/.yarn/__virtual__/@symfony-webpack-encore-virtual-88b9d4c96f/3/bin/encore.js
    at Function.require$$0.Module._resolveFilename (/Users/halliaume/workspace-os/webpack-encore/test_apps/yarn_pnp/.pnp.cjs:17149:13)
    at Function.resolve (node:internal/modules/cjs/helpers:108:19)
    at runCli (/Users/halliaume/workspace-os/webpack-encore/test_apps/yarn_pnp/.yarn/__virtual__/webpack-virtual-56df3fe76f/0/cache/webpack-npm-5.74.0-f5b838a00d-320c41369a.zip/node_modules/webpack/bin/webpack.js:65:26)
    at Object.<anonymous> (/Users/halliaume/workspace-os/webpack-encore/test_apps/yarn_pnp/.yarn/__virtual__/webpack-virtual-56df3fe76f/0/cache/webpack-npm-5.74.0-f5b838a00d-320c41369a.zip/node_modules/webpack/bin/webpack.js:162:2)
    at Module._compile (node:internal/modules/cjs/loader:1103:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1155:10)
    at Object.require$$0.Module._extensions..js (/Users/halliaume/workspace-os/webpack-encore/test_apps/yarn_pnp/.pnp.cjs:17193:33)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.require$$0.Module._load (/Users/halliaume/workspace-os/webpack-encore/test_apps/yarn_pnp/.pnp.cjs:17033:14)
    at Module.require (node:internal/modules/cjs/loader:1005:19)

And when I install webpack-cli, it works:

➜  yarn_pnp git:(fix/GH-655) ✗ yarn add -D webpack-cli
➤ YN0000: ┌ Resolution step
➤ YN0000: └ Completed in 19s 667ms
➤ YN0000: ┌ Fetch step
➤ YN0013: │ resolve-from@npm:5.0.0 can't be found in the cache and will be fetched from the remote registry
➤ YN0013: │ shallow-clone@npm:3.0.1 can't be found in the cache and will be fetched from the remote registry
➤ YN0013: │ webpack-cli@npm:4.10.0 can't be found in the cache and will be fetched from the remote registry
➤ YN0013: │ webpack-merge@npm:5.8.0 can't be found in the cache and will be fetched from the remote registry
➤ YN0013: │ wildcard@npm:2.0.0 can't be found in the cache and will be fetched from the remote registry
➤ YN0000: └ Completed
➤ YN0000: ┌ Link step
➤ YN0000: │ ESM support for PnP uses the experimental loader API and is therefore experimental
➤ YN0000: └ Completed
➤ YN0000: Done with warnings in 19s 990ms
➜  yarn_pnp git:(fix/GH-655) ✗ yarn run encore dev
Running webpack ...

 DONE  Compiled successfully in 235ms                                                                                                                         11:59:58

3 files written to public/build
Entrypoint app 5.65 KiB = runtime.js 4.92 KiB app.js 749 bytes
webpack compiled successfully

C) Hum, same A) now, I don't know what changed. 🤔

Copy link
Member Author

@Kocal Kocal Aug 26, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For A) and C), adding webpack-cli as a peer dependency for Encore does not change anything.
Looks like https://github.com/webpack/webpack/blob/9fcaa243573005d6fdece9a3f8d89a0e8b399613/bin/webpack.js#L34-L57 is broken?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

webpack defines the peerDependenciesMeta to mark webpack-cli as optional without adding webpack-cli in peerDependencies. In such case, yarn automatically treat is a peer dependency (accepting any version). I suspect that pnpm does not do the same (and that webpack is then not compatible with pnpm for their CLI bin relying on accessing webpack-cli)

Copy link
Member Author

@Kocal Kocal Aug 26, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay I think I found the issue, when running encore from test_apps/npm, it will use the webpack dependency from Encore project root and not from test_apps/npm, and this webpack dependency does not have webpack-cli installed.

I will push ASAP.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 575f5e1 (#1142), with webpack and webpack-cli dependencies installed for npm/pnpm/yarn pnp ✨

cc @weaverryan

"webpack-dev-server": "^4.8.0",
"yargs-parser": "^21.0.0"
},
Expand Down Expand Up @@ -98,9 +97,135 @@
"vue": "^3.2.14",
"vue-loader": "^17.0.0",
"vue-template-compiler": "^2.5",
"webpack": "^5.72",
"webpack-cli": "^4.9.1",
"webpack-notifier": "^1.15.0",
"zombie": "^6.1.4"
},
"peerDependencies": {
"@babel/plugin-proposal-class-properties": "^7.0.0",
"@babel/plugin-transform-react-jsx": "^7.12.11",
"@babel/preset-react": "^7.0.0",
"@babel/preset-typescript": "^7.0.0",
"@symfony/stimulus-bridge": "^3.0.0",
"@vue/babel-helper-vue-jsx-merge-props": "^1.0.0",
"@vue/babel-preset-jsx": "^1.0.0",
"@vue/compiler-sfc": "^3.0.2",
"eslint": "^8.0.0",
"eslint-webpack-plugin": "^3.1.0",
"file-loader": "^6.0.0",
"fork-ts-checker-webpack-plugin": "^7.0.0",
"handlebars": "^4.7.7",
"handlebars-loader": "^1.7.0",
"less": "^4.0.0",
"less-loader": "^11.0.0",
"postcss": "^8.3.0",
"postcss-loader": "^7.0.0",
"sass": "^1.17.0",
"sass-loader": "^13.0.0",
"stylus": "^0.58.1",
"stylus-loader": "^7.0.0",
"ts-loader": "^9.0.0",
"typescript": "^4.2.2",
"vue": "^3.2.14",
"vue-loader": "^17.0.0",
"vue-template-compiler": "^2.5",
"webpack": "^5.72",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No webpack-cli here?

Copy link
Member Author

@Kocal Kocal Aug 24, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed it since webpack already ships webpack-cli as a dev dependency (useful for when developing Encore) and as an optional peer dependency (useful for Encore users).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dev dependencies of webpack have no impact when developing Encore. We are not developing webpack in such situation.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do I have anything to change here? ATM webpack-cli, in this package.json is present in devDependencies only.

"webpack-cli": "^4.9.1",
"webpack-notifier": "^1.15.0"
},
"peerDependenciesMeta": {
"@babel/plugin-proposal-class-properties": {
"optional": true
},
"@babel/plugin-transform-react-jsx": {
"optional": true
},
"@babel/preset-react": {
"optional": true
},
"@babel/preset-typescript": {
"optional": true
},
"@symfony/stimulus-bridge": {
"optional": true
},
"@vue/babel-helper-vue-jsx-merge-props": {
"optional": true
},
"@vue/babel-preset-jsx": {
"optional": true
},
"@vue/compiler-sfc": {
"optional": true
},
"eslint": {
"optional": true
},
"eslint-webpack-plugin": {
"optional": true
},
"file-loader": {
"optional": true
},
"fork-ts-checker-webpack-plugin": {
"optional": true
},
"handlebars": {
"optional": true
},
"handlebars-loader": {
"optional": true
},
"less": {
"optional": true
},
"less-loader": {
"optional": true
},
"postcss": {
"optional": true
},
"postcss-loader": {
"optional": true
},
"sass": {
"optional": true
},
"sass-loader": {
"optional": true
},
"stylus": {
"optional": true
},
"stylus-loader": {
"optional": true
},
"ts-loader": {
"optional": true
},
"typescript": {
"optional": true
},
"vue": {
"optional": true
},
"vue-loader": {
"optional": true
},
"vue-template-compiler": {
"optional": true
},
"webpack": {
"optional": false
},
"webpack-cli": {
"optional": false
},
"webpack-notifier": {
"optional": true
}
},
"files": [
"lib/",
"bin/",
Expand Down
42 changes: 0 additions & 42 deletions test/bin/encore.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ module.exports = Encore.getWebpackConfig();
}

expect(stdout).to.contain('Compiled successfully');
expect(stdout).not.to.contain('Webpack is already provided by Webpack Encore');

expect(stdout).not.to.contain('Hash: ');
expect(stdout).not.to.contain('Version: ');
Expand Down Expand Up @@ -176,47 +175,6 @@ module.exports = Encore.getWebpackConfig();
});
});

it('Display a warning message when webpack is also added to the package.json file', (done) => {
testSetup.emptyTmpDir();
const testDir = testSetup.createTestAppDir();

fs.writeFileSync(
path.join(testDir, 'package.json'),
`{
"devDependencies": {
"@symfony/webpack-encore": "*",
"webpack": "*"
}
}`
);

fs.writeFileSync(
path.join(testDir, 'webpack.config.js'),
`
const Encore = require('../../index.js');
Encore
.enableSingleRuntimeChunk()
.setOutputPath('build/')
.setPublicPath('/build')
.addEntry('main', './js/no_require')
;

module.exports = Encore.getWebpackConfig();
`
);

const binPath = path.resolve(__dirname, '../', '../', 'bin', 'encore.js');
exec(`node ${binPath} dev --context=${testDir}`, { cwd: testDir }, (err, stdout, stderr) => {
if (err) {
throw new Error(`Error executing encore: ${err} ${stderr} ${stdout}`);
}

expect(stdout).to.contain('Webpack is already provided by Webpack Encore');

done();
});
});

it('Display an error when calling an unknown method', (done) => {
testSetup.emptyTmpDir();
const testDir = testSetup.createTestAppDir();
Expand Down
Loading