javascriptcreate-react-appdash.js

Why does create-react-app build my app with the debug version of Dashjs?


I have a React app using the Dashjs player. I build it with react-scripts build and the app works fine except that it uses dash.all.debug.js instead of dash.all.min.js.

What did I miss?


Solution

  • looks like dashjs module is exporting the debug file as their main file program:

    after running npm install dashjs@4.0.0-npm, i opened ./node_modules/dashjs/package.json

    {
      "name": "dashjs",
      "version": "4.0.0-npm",
      "description": "A reference client implementation for the playback of MPEG DASH via Javascript and compliant browsers.",
      "author": "Dash Industry Forum",
      "license": "BSD-3-Clause",
      "main": "dist/dash.all.debug.js",
      "types": "index.d.ts",
      ...
    }
    

    as you can see, "main": "dist/dash.all.debug.js" is declared as the main entry point

    when you import the package:

    import React, { Component } from 'react';
    import dashjs from 'dashjs';
    
    export default class App extends Component { ... }
    

    the debug version will be bundled in your final artifact

    to change that, you can explicit import the min version:

    import React, { Component } from 'react';
    import dashjs from 'dashjs/dist/dash.all.min.js';
    
    export default class App extends Component { ... }
    

    or open an issue in dashjs repository