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

Errors when bundling plotly.js with ionic #2599

Closed
aiko-psi opened this issue May 2, 2018 · 8 comments
Closed

Errors when bundling plotly.js with ionic #2599

aiko-psi opened this issue May 2, 2018 · 8 comments
Labels
community community contribution

Comments

@aiko-psi
Copy link

aiko-psi commented May 2, 2018

Hi,
I'm using plotly.js with ionic and I am very happy with it. But when I trie to minify the project during build for production, there is a strange Error. All other Errors are gone with the newest Version (1.37.0). I had the same issues with V 1.35.2 .
Does someone has a clue whats the problem and how I can solve it?

[12:45:38] Error: ./node_modules/plotly.js/src/plots/cartesian/axes.js Module parse failed: Error parsing regular
expression: Invalid regular expression: / newDiff + 1e-6) % 1 < 2e-6 &&(((newFirst - ax._forceTick0) /:
Unmatched ')' (185:53) You may need an appropriate loader to handle this file type. | // and forceTick0 can
be shifted to newFirst | if (function (ax, _minDtick) { | if (_minDtick === void 0) { _minDtick = / newDiff
+ 1e-6) % 1 < 2e-6 &&(((newFirst - ax._forceTick0) / newDiff % 1) + | 1.000001) % 1 < 2e-6; } | ax._minDtick
= newDiff; @ ./node_modules/plotly.js/src/transforms/sort.js 10:11-45 @ ./node_modules/plotly.js/lib/sort.js
@ ./node_modules/plotly.js/lib/index.js @ ./src/pages/statSites/statQuestionnaire/statQuestionnaire.ts @
./src/pages/statSites/statQuestionnaire/statQuestionnaire.ngfactory.ts @ ./src/app/app.module.ngfactory.ts @
./src/app/main.ts
Error: ./node_modules/plotly.js/src/plots/cartesian/axes.js
Module parse failed: Error parsing regular expression: Invalid regular expression: / newDiff + 1e-6) % 1 < 2e-6 &&(((newFirst - ax._forceTick0) /: Unmatched ')' (185:53)
You may need an appropriate loader to handle this file type.
| // and forceTick0 can be shifted to newFirst
| if (function (ax, _minDtick) {
| if (_minDtick === void 0) { _minDtick = / newDiff + 1e-6) % 1 < 2e-6 &&(((newFirst - ax._forceTick0) / newDiff % 1) +
| 1.000001) % 1 < 2e-6; }
| ax._minDtick = newDiff;
@ ./node_modules/plotly.js/src/transforms/sort.js 10:11-45
@ ./node_modules/plotly.js/lib/sort.js
@ ./node_modules/plotly.js/lib/index.js
@ ./src/pages/statSites/statQuestionnaire/statQuestionnaire.ts
@ ./src/pages/statSites/statQuestionnaire/statQuestionnaire.ngfactory.ts
@ ./src/app/app.module.ngfactory.ts
@ ./src/app/main.ts
at BuildError.Error (native)
at new BuildError (/home/aiko/IdeaProjects/etmos_the/node_modules/@ionic/app-scripts/dist/util/errors.js:16:28)
at callback (/home/aiko/IdeaProjects/etmos_the/node_modules/@ionic/app-scripts/dist/webpack.js:119:28)
at emitRecords.err (/home/aiko/IdeaProjects/etmos_the/node_modules/webpack/lib/Compiler.js:265:13)
at Compiler.emitRecords (/home/aiko/IdeaProjects/etmos_the/node_modules/webpack/lib/Compiler.js:371:38)
at emitAssets.err (/home/aiko/IdeaProjects/etmos_the/node_modules/webpack/lib/Compiler.js:258:10)
at applyPluginsAsyncSeries1.err (/home/aiko/IdeaProjects/etmos_the/node_modules/webpack/lib/Compiler.js:364:12)
at next (/home/aiko/IdeaProjects/etmos_the/node_modules/tapable/lib/Tapable.js:218:11)
at Compiler.compiler.plugin (/home/aiko/IdeaProjects/etmos_the/node_modules/webpack/lib/performance/SizeLimitsPlugin.js:99:4)
at Compiler.applyPluginsAsyncSeries1 (/home/aiko/IdeaProjects/etmos_the/node_modules/tapable/lib/Tapable.js:222:13)

@alexcjohnson
Copy link
Collaborator

The source for that is:

if((ax._minDtick / newDiff + 1e-6) % 1 < 2e-6 &&
(((newFirst - ax._forceTick0) / newDiff % 1) +

It looks like you have some transformation that's incorrectly adding = before the / newDiff?
A little farther down in your traceback:

if (_minDtick === void 0) { _minDtick = / newDiff
+ 1e-6) % 1 < 2e-6 &&(((newFirst - ax._forceTick0) / newDiff % 1)

No idea why that would have happened, but it certainly doesn't look like a correct transformation of the source.

@etpinard
Copy link
Contributor

etpinard commented May 2, 2018

This might be related to #2528 which got resolved by dropping browser-pack-flat in #2572.

@aiko-psi if 1.37.0 is working for you, than I suggest using that. We won't patch the 1.35.x series to resolve this issue. But if you're still seeing issues in 1.37.0, would you mind giving us a bit more info e.g. which minifier are you using, which entry file are you pointing your minifier towards, what command are you using?

@aiko-psi
Copy link
Author

aiko-psi commented May 4, 2018

Thank you both for your replies!

@etpinard I am using ionic and its minifier. The command ionic cordova build android --prod produces this error. I am not sure what kind of minifier ionic is using.
While testing the app I found a even bigger problem with version 1.37.0 for me. When I try to to run the app, I get a Error

Uncaught TypeError: Cannot read property 'format' of undefined

I tried to go back to Version 1.35.2 but the error is still there. The Error remains the same with different versions of plotly, just the line of the error changes (always in plotly files). I attach two exaples for errors I got. It seems to me this problem has something to do with the date formats for the axes, would you agree? Do you have any idea to fix it? Because the app is completly broken at the moment and I need it.
Thank you for your help!
bildschirmfoto vom 2018-05-04 11-04-29
bildschirmfoto vom 2018-05-03 14-51-01

@aiko-psi
Copy link
Author

aiko-psi commented May 4, 2018

I was surprised that I did not find the word 'format' in the code the error message points to. After I few tries I found an error pointing to this line. Perhaps that helps?
bildschirmfoto vom 2018-05-04 12-56-09

@alexcjohnson
Copy link
Collaborator

@aiko-psi any chance your environment has d3 v4 in it? Plotly uses d3 v3, and we've seen a case where d3 v4 ends up replacing v3 and breaking everything, in similar ways to that (@nicolaskruchten remind me where that was debugged?)

@aiko-psi
Copy link
Author

aiko-psi commented May 4, 2018

@alexcjohnson I think d3 is not integrated in Ionic because every tutorial for ionic explains that you have to run npm install d3 before using it with ionic.
I checked if there is another version of d3 but npm list d3 only gives me

├─┬ plotly.js@1.37.0
│ └── d3@3.5.17

@nicolaskruchten
Copy link
Contributor

The symptom we had was that window.d3.version was set to 4.x, and I think it was Webpack exposing things in a funny way.

@etpinard etpinard changed the title Error parsing regular in cartesian/axes.js Errors when bundling plotly.js with ionic May 14, 2018
@etpinard etpinard added bug something broken community community contribution labels May 14, 2018
@etpinard etpinard removed the bug something broken label Oct 4, 2018
@etpinard
Copy link
Contributor

Odds are this ticket is obsolete. Closing. @aiko-psi feel free to reopen another issue if you're still encountering problems of the likes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
community community contribution
Projects
None yet
Development

No branches or pull requests

4 participants