ci010 / electron-vue-next

A starter template for using vue-next with the electron.
https://ci010.github.io/electron-vue-next/
191 stars 27 forks source link

Usage of optionalDependencies #26

Closed ci010 closed 3 years ago

ci010 commented 3 years ago

@cawa-93 It seems npm install will add the optionalDependencies into the dependencies list. I think maybe we should just keep the eslint in the devDependencies

cawa-93 commented 3 years ago

@ci010 Thus, by default, optional dependencies are install in the same way as devDependencies. The same under normal conditions, the difference is not noticeable. However, the idea is to be able to skip the installation of dependencies that are not required for compilation. This will, though not significantly, reduce build time. Lets say why we need install eslint and all eslint plugins if only build:production will be run?

ci010 commented 3 years ago

I understand your concern. I agree with the idea that, lesser the dependencies we have, shorter the build time will take.

My point is this might confuse user. For example,

If someone try to run npm install locally and install the dependencies (maybe they just clone the project). The npm will install all dependencies and modify the local package.json, adding all optionalDependencies into dependencies. If user doesn't notice that, the npm run dev will failed as some eslint dependencies are using node modules.

In the case I described above, there are two unexpected things:

  1. npm will modify the package.json, adding eslint packages to dependencies.
  2. vite will fail if user does not move the eslint package to devDependencies.
cawa-93 commented 3 years ago

npm will modify the package.json, adding eslint packages to dependencies.

I do not observe this problem. I just did some tests in the master. After npm install eslint remains in optionalDependencies.

Windows npm version: 6.14.8

ci010 commented 3 years ago

npm will modify the package.json, adding eslint packages to dependencies.

I do not observe this problem. I just did some tests in the master. After npm install eslint remains in optionalDependencies.

Windows npm version: 6.14.8

ah, I'm using the npm 7.0.3. I'm not sure if this is a bug of the npm 7.

cawa-93 commented 3 years ago

Related issue: https://github.com/npm/cli/issues/1886 I think this can be fixed if you get rid of duplicates eslint in devDependencies

https://github.com/ci010/electron-vue-next/blob/bf0187d3c39faea9bf41a9b01eac03e0901edaad/package.json#L39-L45

ci010 commented 3 years ago

Close due to the new project structure.