How can the introduction of js files through script tags be replaced with the introduction of import?

there is a project that I need to introduce the viz.js file in order to implement a function.
so I put viz.js in the static directory, and then introduce it through the script tag in index.html .

let head = document.getElementsByTagName("head")[0];
createElement("script", head, { src: "static/resource/plugin/viz.js" })

function createElement(tag, target, attrs){
  let element = document.createElement(tag)
  if(attrs && typeof attrs === "object"){
    for(let key in attrs){
      element.setAtrribute ? element.setAtrribute(key, attrs[key]) : element[key] = attrs[key]
    }
  }
  target.append(element)
}

this method allows my project to run normally, but when I packaged the project into a framework and released it as a npm module package, I found in the test that because the static in the new project is an empty folder , it will lead to an error in this way, the introduced js does not exist, and the error unexpected token <
tries to solve the problem:
1 replaces the static folder in the module package for the new project, but I think this method is not reasonable. It is not convenient for
2 to modify the reference path of the script tag to the relative path createElement ("script", head, {src: ".. / static/resource/plugin/viz.js"}) but still recognized by the browser as static/resource/plugin/viz.js . It is not advisable to
3 introduce viz, npm I viz.js through npm and then introduce import" viz" or import Viz from "viz" in a js file somewhere. All reported errors, but no instructions were found for viz.js projects on GitHub. Abandon this method
4 introduce the local viz.js file by import or put viz.js in the src folder to report syntax error , indicating that there is a ts syntax, resulting in an error in the compilation process. Unable to start the project
5 to change the script tag path to https://cdn.bootcss.com/viz.j., which is feasible, but it is not safe to introduce online

. Project address of

framework: https://gitee.com/g2333/data_.


solution: adopt measure 2 to modify the reference path of the script tag to a relative path. When developing, the path is "static/resource/plugin/viz.js" , and when publishing, the path is ". / node_modules/modulecomponents/static/resource/plugin/viz.js"
code is as follows:

MODULE_PATH'',npm'./node_modules/modulecomponents/'
createElement('script', head, { src: MODULE_PATH + "static/resource/plugin/viz.js" })
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-7be8da-2a4f1.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-7be8da-2a4f1.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?