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

[Bug Report] Dev build from source fails #18304

Open
Tofandel opened this issue Dec 4, 2019 · 14 comments
Open

[Bug Report] Dev build from source fails #18304

Tofandel opened this issue Dec 4, 2019 · 14 comments
Labels

Comments

@Tofandel
Copy link

Tofandel commented Dec 4, 2019

Element UI version

2.13.0

OS/Browsers version

Linux (Kubuntu 19)

Vue version

2.6.10

Reproduction Link

https://github.com/ElemeFE/element.git#dev

Steps to reproduce

Simply clone the dev branch

And run npm install && npm run dist

What is Expected?

The build process to run successfully

What is actually happening?

The build process fails at 89% with a ton of errors like the following

ERROR in ./packages/tooltip/src/main.js 81:8
Module parse failed: Unexpected token (81:8)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
|     if (this.popperVM) {
|       this.popperVM.node = (
>         <transition
|           name={ this.transition }
|           onAfterLeave={ this.doDestroy }>
 @ ./packages/tooltip/index.js 1:0-33 4:0-7 5:16-23 5:30-37 8:15-22
 @ ./src/index.js
 @ multi ./src/index.js

It seems like the jsx loader is not correctly configured

@Linkontoask
Copy link

I suspect that you made some errors during the installation, you can try to reinstall the dependencies. jsx is mainly compiled by transform-vue-jsx in babel

@Tofandel
Copy link
Author

Tofandel commented Dec 5, 2019

Already tried deleting node_modules and reinstalling, same issue, tried with a clean clone, same issue

@Linkontoask
Copy link

npm i yarn -g

You can try to reinstall dependencies using yarn

@Tofandel
Copy link
Author

Tofandel commented Dec 5, 2019

Just tried yarn install && yarn run dist on a clean clone
Getting the same issue

I got a warning during install
warning " > karma-webpack@3.0.5" has incorrect peer dependency "webpack@^2.0.0 || ^3.0.0".

Don't know if it's related

PS: I ruled out a possible global package conflict by uninstalling all my global packages

@Tofandel
Copy link
Author

Tofandel commented Dec 5, 2019

Webpack profiling output for one of the errors is:

{
          "id": 36,
          "identifier": "./element-ui/node_modules/vue-loader/lib/index.js??vue-loader-options!./element-ui/packages/dropdown/src/dropdown.vue?vue&type=script&lang=js&",
          "name": "./node_modules/vue-loader/lib??vue-loader-options!./packages/dropdown/src/dropdown.vue?vue&type=script&lang=js&",
          "index": 51,
          "index2": 46,
          "size": 354,
          "cacheable": true,
          "built": true,
          "optional": false,
          "prefetched": false,
          "chunks": [
            0
          ],
          "issuer": "./element-ui/node_modules/vue-loader/lib/loaders/pitcher.js??ref--4!./element-ui/node_modules/vue-loader/lib/index.js??vue-loader-options!./element-ui/packages/dropdown/src/dropdown.vue?vue&type=script&lang=js&",
          "issuerId": 35,
          "issuerName": "./packages/dropdown/src/dropdown.vue?vue&type=script&lang=js&",
          "issuerPath": [
            {
              "id": 98,
              "identifier": "multi ./src/index.js",
              "name": "multi ./src/index.js",
              "profile": {
                "factory": 1,
                "building": 4
              }
            },
            {
              "id": null,
              "identifier": "./element-ui/src/index.js",
              "name": "./src/index.js",
              "profile": {
                "factory": 44,
                "building": 30
              }
            },
            {
              "id": null,
              "identifier": "./element-ui/packages/dropdown/index.js",
              "name": "./packages/dropdown/index.js",
              "profile": {
                "factory": 194,
                "building": 95,
                "dependencies": 0
              }
            },
            {
              "id": 19,
              "identifier": "./element-ui/node_modules/vue-loader/lib/index.js??vue-loader-options!./element-ui/packages/dropdown/src/dropdown.vue",
              "name": "./packages/dropdown/src/dropdown.vue",
              "profile": {
                "factory": 378,
                "building": 187,
                "dependencies": 2312
              }
            },
            {
              "id": 35,
              "identifier": "./element-ui/node_modules/vue-loader/lib/loaders/pitcher.js??ref--4!./element-ui/node_modules/vue-loader/lib/index.js??vue-loader-options!./element-ui/packages/dropdown/src/dropdown.vue?vue&type=script&lang=js&",
              "name": "./packages/dropdown/src/dropdown.vue?vue&type=script&lang=js&",
              "profile": {
                "factory": 2312,
                "building": 37
              }
            }
          ],
          "profile": {
            "factory": 35,
            "building": 40
          },
          "failed": true,
          "errors": 1,
          "warnings": 0,
          "assets": [],
          "reasons": [
            {
              "moduleId": 35,
              "moduleIdentifier": "./element-ui/node_modules/vue-loader/lib/loaders/pitcher.js??ref--4!./element-ui/node_modules/vue-loader/lib/index.js??vue-loader-options!./element-ui/packages/dropdown/src/dropdown.vue?vue&type=script&lang=js&",
              "module": "./packages/dropdown/src/dropdown.vue?vue&type=script&lang=js&",
              "moduleName": "./packages/dropdown/src/dropdown.vue?vue&type=script&lang=js&",
              "type": "harmony side effect evaluation",
              "userRequest": "-!../../../node_modules/vue-loader/lib/index.js??vue-loader-options!./dropdown.vue?vue&type=script&lang=js&",
              "loc": "1:0-126"
            },
            {
              "moduleId": 35,
              "moduleIdentifier": "./element-ui/node_modules/vue-loader/lib/loaders/pitcher.js??ref--4!./element-ui/node_modules/vue-loader/lib/index.js??vue-loader-options!./element-ui/packages/dropdown/src/dropdown.vue?vue&type=script&lang=js&",
              "module": "./packages/dropdown/src/dropdown.vue?vue&type=script&lang=js&",
              "moduleName": "./packages/dropdown/src/dropdown.vue?vue&type=script&lang=js&",
              "type": "harmony import specifier",
              "userRequest": "-!../../../node_modules/vue-loader/lib/index.js??vue-loader-options!./dropdown.vue?vue&type=script&lang=js&",
              "loc": "1:142-145"
            },
            {
              "moduleId": 35,
              "moduleIdentifier": "./element-ui/node_modules/vue-loader/lib/loaders/pitcher.js??ref--4!./element-ui/node_modules/vue-loader/lib/index.js??vue-loader-options!./element-ui/packages/dropdown/src/dropdown.vue?vue&type=script&lang=js&",
              "module": "./packages/dropdown/src/dropdown.vue?vue&type=script&lang=js&",
              "moduleName": "./packages/dropdown/src/dropdown.vue?vue&type=script&lang=js&",
              "type": "harmony side effect evaluation",
              "userRequest": "-!../../../node_modules/vue-loader/lib/index.js??vue-loader-options!./dropdown.vue?vue&type=script&lang=js&",
              "loc": "1:147-270"
            },
            {
              "moduleId": 35,
              "moduleIdentifier": "./element-ui/node_modules/vue-loader/lib/loaders/pitcher.js??ref--4!./element-ui/node_modules/vue-loader/lib/index.js??vue-loader-options!./element-ui/packages/dropdown/src/dropdown.vue?vue&type=script&lang=js&",
              "module": "./packages/dropdown/src/dropdown.vue?vue&type=script&lang=js&",
              "moduleName": "./packages/dropdown/src/dropdown.vue?vue&type=script&lang=js&",
              "type": "harmony export imported specifier",
              "userRequest": "-!../../../node_modules/vue-loader/lib/index.js??vue-loader-options!./dropdown.vue?vue&type=script&lang=js&",
              "loc": "1:147-270"
            }
          ],
          "usedExports": [
            "default"
          ],
          "providedExports": null,
          "optimizationBailout": [
            "ModuleConcatenation bailout: Module is not an ECMAScript module"
          ],
          "depth": 5,
          "source": "throw new Error(\"Module parse failed: Unexpected token (262:9)\\nYou may need an appropriate loader to handle this file type.\\n|     let triggerElm = !splitButton\\n|       ? this.$slots.default\\n>       : (<el-button-group>\\n|         <el-button type={type} size={dropdownSize} nativeOn-click={handleMainButtonClick}>\\n|           {this.$slots.default}\");"
},

Command used => webpack --config build/webpack.common.js --profile --json

The other webpack command runs fine (webpack --config build/webpack.component.js)

Hopefully that helps because I have no clue about what the problem is at this point

And being unable to compile from source is quite frustrating because I can't test changes and pull requests

@Linkontoask
Copy link

Can you post the current branch names, .babelrc, node and npm versions? I can restore your situation on my machine, because according to the information you told, I can't analyze the problem.

@Tofandel
Copy link
Author

Tofandel commented Dec 6, 2019

Branch is dev (It was in the url)
.babelrc is exactly the same
Npm: 6.13.1
Node: v10.15.2
Webpack: 4.41.2

@Linkontoask
Copy link

Linkontoask commented Dec 6, 2019 via email

@Tofandel
Copy link
Author

Tofandel commented Dec 6, 2019

Well I said that I'm cloning the original repo on dev, I don't see what a reproduction repo being exactly the same will add

I can add the node_modules folder but it's gonna be pretty much the same since it seems being environment related

(maybe a path variable story like vue cli)

@Linkontoask
Copy link

Linkontoask commented Dec 7, 2019 via email

@Linkontoask
Copy link

I use the same environment / command as you, but it doesn't happen to you, I don't think this is a problem with Element
@Tofandel sorry I can't help you

@Tofandel
Copy link
Author

I finally figured it out...

For some reason if the directory is cloned into another node_modules directory (eg: my_project/node_modules/element-ui/)

Then the build fails, if not then all works correctly, I'm guessing there is something wrong with how directory are handled on the jsx vue plugin

@Tofandel
Copy link
Author

Tofandel commented Jan 13, 2020

Having found the source of the bug and a solution for it I will reopen this until a PR fixes the config

Issue is in lib/config.js

exports.jsexclude = /node_modules|utils\/popper\.js|utils\/date\.js/;

Because the regex doesn't care about the tree directory, if the project is under a node modules directory, everything will be excluded

Replacing it with
exports.jsexclude = [path.resolve('./node_modules'), path.resolve('./utils', 'popper.js'), path.resolve('./utils', 'date.js')]
Fixed the issue

@Tofandel Tofandel reopened this Jan 13, 2020
Tofandel added a commit to Tofandel/element that referenced this issue Jan 13, 2020
…ctory named 'node_modules')

Instead of a regex for exclusion, this PR resolves the actual path for the excluded files
@stale
Copy link

stale bot commented Apr 29, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Apr 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
2 participants