How does the front-end js implement the require(“./example “) similar to node.js

  node.js, question

There are some common codes to be used in multiple js files. How can I refer to this common js in a js? , please tell me how to implement var comm=require(“./comm “) similar to node.js

First of all, as a front-end application, you definitely need to set a following path -> root;
Then rewrite the require method and customize the corresponding format to obtain this key->example;
Then find the corresponding template cache-> simple arr;
If it is found, this object is returned; if it is not found, this data is requested.

The request was successful-> continue with the previous cache push
The request failed, and since the attempt failed several times, the error was still reported.