![Create React App Officially Deprecated Amid React 19 Compatibility Issues](https://cdn.sanity.io/images/cgdhsj6q/production/04fa08cf844d798abc0e1a6391c129363cc7e2ab-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Create React App Officially Deprecated Amid React 19 Compatibility Issues
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
batch-import
Advanced tools
批量加载指定目录下node.js模块,并将模块导出结果保存到与模块路径结构一致的对象中
npm install batch-import
let batchImport = require('batch-import')
let modules = batchImport(options, container)
options.path
String - 指定模块加载目录
options.contain
Array - 仅加载指定模块,不能与exclude同时使用
options.exclude
Array - 排除指定模块,不能与contain同时使用
options.process
Function - 模块导出数据处理函数,用于数据检验、预处理等操作。
container
Object - 指定一个容器用于存放模块导出结果,按照指定顺序加载模块,来解决依赖时序问题(可选)
函数中this指向根容器,按照约定,process函数必须返回包含error和data属性的对象,error用于抛出错误信息,data输出正常结果。
filename
String - 当前文件名称,不含后缀
data
* - 模块返回值
let batchImport = require('batch-import')
let modules = batchImport({
"middleware": {
"path": "middleware/",
"exclude": ["test.js"],
},
"models": {
"path": "models/",
process(filename, func) {
if (typeof func === 'function') {
return func(this)
} else {
return { error: `模块输出数据类型必须为函数` }
}
},
},
"controllers": {
"path": "controllers/",
"contain": ["_route.js"],
},
})
配置项加载顺序与定义顺序一致,配置越靠前优先级越高
path路径以入口文件所在位置作为根路径
path路径中不应该出现./、../等相对路径表达式
2.x调整了process函数的入参,参考入参部分
取消process函数必须以{error、data}作为返回值的约定,不再使用模块内代理throw抛出异常,导致不能直接定位到错误
FAQs
批量加载node.js模块、目录,并转换为对应的JS对象
The npm package batch-import receives a total of 3 weekly downloads. As such, batch-import popularity was classified as not popular.
We found that batch-import demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.