charting-library-examples
charting-library-examples copied to clipboard
vue + Nuxtjs2 Cant import charting_library.min
trying to include charting_library
let { widget } = require('~/assets/js/charting_library.min')
it throws: Uncaught TypeError: Cannot read property 'TradingView' of undefined

What bundler you use? It looks it doesn't support UMD modules.
nuxt2 exists webpack4.26.1 it worked fine with webpack3 on nuxtjs
just tried to assemble with clean webpack4.26.1 without vuejs and nuxtjs so it works. I have no idea
I would suggest you check webpack's config you use to bundle your app.
same with vuejs .-.
@FF-ru adding modules: 'commonjs' to the build.babel.presets fix this issue
For example:
babel: {
presets({ isServer }) {
return [
[
require.resolve('@nuxt/babel-preset-app'),
{
//targets: isServer ? { node: '10' } : { ie: '11' },
//corejs: { version: 3 },
modules: 'commonjs'
}
]
]
}
}
For vue this should work:
babel: {
presets: [
[
'@babel/env',
{
//targets: {
// node: 'current'
//},
modules: 'commonjs'
}
]
]
}
https://github.com/tradingview/charting-library-examples/issues/170#issuecomment-745245792 I hope this will help