problem description
nowadays, the mainstream organization of JS is modular development, but there is a scenario in common development:
for example, in a project, the file name of a module is changed , for example: ModuleA.js-> ModuleB.js
this will cause me to find every JS file that introduces ModuleA
to make changes , otherwise I will report an error
import {xxx} from "./ModuleA" -> import {xxx} from "./ModuleB"
this is a lot of work and inconvenient, and if you use the method introduced by < script >
, you only need to find the place where the script
tag introduces the change, and the only need to change one place .
<script src="./ModuleA.js"></script> -> <script src="./ModuleB.js"></script>
or a more common example:
in React development, React components need to have
import React, { Component } from "react";
if one day react
changes its name to react2
. Then we don"t have to find the js files of all the react components to change to
import React, { Component } from "react2";
so I would like to ask you to give us some advice on how to solve this scene more elegantly. Or is this an inconvenience of modular development? Thank you very much!