File name change loaded in JS modularization

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

when we use the project developed by react.
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!

Apr.03,2021

1. The examples of import and < script > you cited are not comparable. The operation of changing import for file name corresponds to the change of function name in the script file of < script >. If this function is used in many places, you also have to manually modify it one by one. And your example of < script > corresponds more to files like app.js/vendor.dll.js

.

2. So this is not the downside of "modular" development, because the traditional way also exists.

3. Why is it so inconvenient, because changing the file name of is essentially changing the dependency , just like changing jquery to zepto,react to preact,.

4. There is currently no general solution, because this operation requires changing the name in the corresponding file against the old reference relationship. In fact, only the editor / IDE can do this, at least currently VS Code is supported


I think you should use a smart IDE , such as try WebStorm ? folder renaming File renaming Custom Module renaming function renaming Parameter variable renaming these changes will be intelligently updated if there are references in these items, saving a lot of time, so there is no problem with you

.
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-1b3ea35-2bba8.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-1b3ea35-2bba8.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?