How to introduce the module according to the subpath

see that many common modules can be introduced through subpaths, such as ant-desin :

const AdaBoost = require("mlhelper/algorithm/AdaBoost");

//or
import AdaBoost from "mlhelper/algorithm/AdaBoost";

report the error of module not found directly.

what can I do to achieve this kind of on-demand loading?


is something like this: https://github.com/Jiasm/tetr.

create a separate index.js file as an index, in which other module can be introduced.

a.js
 

you need to package multiple files instead of a single bundle file. mlhelper/algorithm/AdaBoost will be parsed to node_modules/mlhelper/algorithm/AdaBoost obviously there is no algorithm directory in your mlhelper package. You can require ('mlhelper/src/algorithm/AdaBoost') provided that your environment is configured to compile the ts content in node_modules.

you need to configure tsconfig.json to compile each file of your src to another lib directory.

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