-
-
Notifications
You must be signed in to change notification settings - Fork 7.8k
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 a hasCORS boolean property to the Exchange Structure /// Webpack throws error when building in Nuxt #225
Comments
Awesome idea! Thanks so much, adding it right away! |
Done! The flag will be available in new version 1.7.109+. Thx for your feedback! |
Wow, thank you for adding it so fast! I will update sometime, however with version ERROR in pages\index.86b4ca59d1fc39bf44ed.js from UglifyJs
Unexpected token: name (CCXTError) [./node_modules/ccxt/ccxt.js:51,0][pages\index.86b4ca59d1fc39bf44ed.js:4503,6]
(node:6676) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: Webpack build exited with errors Maybe something got broken since version |
@kireerik we have recently dropped support for very old versions of Node (since ccxt 1.7.x+), because they are outdated and don't have async/await and other modern JS features. So, if you have Node 5 or 6, please, update to 7.6.0+. |
Thank you for your feedback! This issue occurs with Node.js |
@kireerik ok, can you please try to reinstall the dependencies in node_modules from scratch?
Does it still complain after that? |
Sure, I have tried the same with Yarn (I am using it for performance reasons basically), but it doesn't make any difference. I did some manual binary like search trying different versions and I can say that this issue was introduced with version |
@kireerik the problem you are experiencing is related to UglifyJS that does not understand ES2015 and modern async/await syntax out of the box. You may consider adding Babel to your build pipeline (before UglifyJS), to transpile everything down to plain old ECMAScript5. Here's how you can do it with Webpack: You can also try switching to another minifier that supports ECMAScript6 and async/await, but if you're building a browser app and want to support older browsers, it would be better if you use Babel. Hope this helps! |
@kireerik Can you please upload somewhere a minimal demo project (with Nuxt and everything set up) that demonstrates the error you experience? |
We have a minimal example as well where the issue is reproducible too. You can request access from @cklester. |
@cklester I've just registered as https://gitlab.com/xpl, can you give me access please? |
@xpl Done! Thank you! |
@cklester Unfortunately, the |
I've granted access for @xpl to the example repo. |
@kireerik I have troubles with reproducing the error... The steps I have performed so far on my MacOS: Cloned the repo and installed dependencies with
Then I had trouble with port
Seems that the |
@kireerik Hmm, looks like that the example project references a previous CCXT version. Will try changing it.. UPD: yep, now I see the error. Not sure what's causing it yet, though. Seems that it doesn't like the |
@kireerik I suspect that it is caused by a Webpack config where the |
@kireerik OK, seems I've found a way to override the Webpack config in Nuxt: How to extend webpack config?... |
@kireerik @cklester So here's the solution. Add the following to your module.exports = {
build: {
extend (config, { dev, isClient }) {
if (isClient) {
config.module.rules.push ({
test: /node_modules\/ccxt\/(.+)\.js$/,
loader: "babel-loader",
options: {
babelrc: false,
cacheDirectory: false,
presets: ["es2015"],
plugins: ["syntax-async-functions", "transform-regenerator"]
}
})
}
}
}, This will add CCXT to the Babel transpilation stage. Seems that it could be a common problem across various frameworks. So if you're not the only ones who are having this problem, we will reconsider adding the Babel transpilation stage to the CCXT itself. Hope this helps. |
@xpl Thank you for your efforts! I have tried the mentioned solution, but I still get the exact same error. By the way did you made any braking changes in version |
@kireerik What is your Webpack version? BTW, after adding the previously mentioned snippet to your Nuxt config, you should see this message in the log output:
It indicates that the transpilation is set up correctly and the CCXT source is going through Babel. If you don't see the message, something's wrong.
We stopped using Babel, since the latest Node already supports all the syntax features we need, and there's no need in transpiling, and the browser people already use Babel on their ends... But it seems that even with that, some tools are just not yet ready for ES6 modules, as they expect everything in the If the problem persists, we will return Babel to our build pipeline, it's not a big problem. |
As I can see it is I see. |
@kireerik Yep it's working on my machine, with the 'use strict'
const resolve = require('path').resolve
module.exports = {
build: {
extend (config, { dev, isClient }) {
if (isClient) {
config.module.rules.push ({
test: /node_modules\/ccxt\/(.+)\.js$/,
loader: "babel-loader",
options: {
babelrc: false,
cacheDirectory: false,
presets: ["es2015"],
plugins: ["syntax-async-functions", "transform-regenerator"]
}
})
}
}
},
/*
** Headers of the page
*/
head: {
title: 'Adonuxt',
meta: [
{
charset: 'utf-8'
},
{
name: 'viewport',
content: 'width=device-width, initial-scale=1'
},
{
hid: 'description',
name: 'description',
content: 'Adonuxt project'
}
],
link: [
{
rel: 'icon',
type: 'image/x-icon',
href: 'favicon.ico'
}
]
},
/*
** Global CSS
*/
css: ['~assets/css/main.css'],
/*
** Customize the progress-bar color
*/
loading: { color: '#744d82' },
/*
** Point to resources
*/
srcDir: resolve(__dirname, '..', 'resources')
} What is the OS you use? If it's Windows, then the |
@kireerik Have you tried that fix with the example project? If you trying it with some other project, make sure you don't override the |
I see. Yes, this occurred on Windows. Now I have tried using However when I visit the application in the browser I am getting the following error in both development and production mode: So it seems ccxt is not working on the client side this way. |
@kireerik Hmm, seems that I forgot about the module.exports = {
build: {
extend (config, { dev, isClient }) {
if (isClient && !dev) {
config.entry.common = ['babel-polyfill', ...config.entry.common]
config.module.rules.push ({
test: resolve(__dirname, '..', 'node_modules/ccxt'),
loader: "babel-loader",
options: {
babelrc: false,
cacheDirectory: false,
presets: ["es2015"],
plugins: ["syntax-async-functions", "transform-regenerator"]
}
})
}
}
}, It will add the required |
Thank you! It works correctly this way. |
@kireerik UPD: Try also changing if (isClient) { to: if (isClient && !dev) { To disable the unnessesary transpilation in the development environment. |
@kireerik Sorry, had a mistake in my previous message (now edited). Transpilation makes build times considerably slower, so it is not a something you want in the dev mode... |
Thank you! |
Tu |
I think it would be great to have a
hasCORS
boolean property in the Exchange Structure. So we would only need to define a proxy on the client side if it is really needed.The text was updated successfully, but these errors were encountered: