project-nv / night-vision

Highly customizable charting library, created for professional traders
https://nightvision.dev
MIT License
252 stars 58 forks source link

Can not get any script to work #75

Closed mariusvigariu closed 1 year ago

mariusvigariu commented 1 year ago

Describe the bug

I have a typescript nuxt test project to play with the nv library. I've created a test page which looks like:

image

For some reason I always get the error: Failed to load module script: Expected a JavaScript module script but the server responded with a MIME type of "text/html". Strict MIME type checking is enforced for module scripts per HTML spec.

Error occurs on line 25 above, on new NightVision ...

The second pane shows blank.

image

I am wild guessing this has to do with nv sending the navyjs scripts to the webworker for compilation or is it me doing something wrong?

Reproduction

https://nightvision.dev/guide/built-in-indicators/RSI.html

Steps to reproduce

  1. Follow https://nightvision.dev/guide/intro/getting-started.html
  2. Modify your main.js to include the RSI script.
  3. See below.

image

Javascript Framework

vue

Logs

No response

Validations

mariusvigariu commented 1 year ago

I've got it working by using the source code directly: import { NightVision } from '~/vendors/night-vision/src/interface' and adding this in my nuxt.config.ts:

import { svelte } from '@sveltejs/vite-plugin-svelte'
import viteRawPlugin from './vendors/night-vision/vite/vite-raw-plugin'

export default defineNuxtConfig({
  // ...
  vite: {
    plugins: [
      svelte({ emitCss: false }),
      viteRawPlugin({
        fileRegex: /\.navy$/,
      }),
    ],
  },
})

Two things I've found: web workers are not yet supported in firefox (in dev mode only) and Metamask extension might interfere and should be disabled.