feat: support more core module
Signed-off-by: MiaoWoo <admin@yumc.pw>
This commit is contained in:
parent
9a15a0ab1f
commit
f2b8f6ff26
2
pom.xml
2
pom.xml
@ -2,7 +2,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>pw.yumc</groupId>
|
||||
<artifactId>MiaoScript</artifactId>
|
||||
<version>0.6.5</version>
|
||||
<version>0.6.6</version>
|
||||
<developers>
|
||||
<developer>
|
||||
<id>502647092</id>
|
||||
|
@ -55,7 +55,14 @@
|
||||
var JavaString = Java.type('java.lang.String')
|
||||
var separatorChar = File.separatorChar;
|
||||
|
||||
var CoreModules = ['assert', 'async_hooks', 'child_process', 'cluster', 'crypto', 'dns', 'domain', 'events', 'fs', 'http', 'http2', 'https', 'inspector', 'net', 'os', 'path', 'vm', 'url', 'util', 'zlib', 'worker_threads', 'punycode']
|
||||
var CoreModules = [
|
||||
"assert", "async_hooks", "Buffer", "child_process", "cluster", "crypto",
|
||||
"dgram", "dns", "domain", "events", "fs", "http", "http2", "https",
|
||||
"inspector", "net", "os", "path", "perf_hooks", "process", "punycode",
|
||||
"querystring", "readline", "repl", "stream", "string_decoder",
|
||||
"timer", "tls", "trace_events", "tty", "url", "util",
|
||||
"v8", "vm", "wasi", "worker_threads", "zlib"
|
||||
]
|
||||
|
||||
/**
|
||||
* @param {...object} t
|
||||
@ -308,19 +315,24 @@
|
||||
/**
|
||||
* 检查核心模块
|
||||
* @param {string} name
|
||||
* @param {string} path
|
||||
*/
|
||||
function checkCoreModule(name, path) {
|
||||
if (name.startsWith('@ms') && lastModule.endsWith('.js')) {
|
||||
console.warn(lastModule + ' load deprecated module ' + name + ' auto replace to ' + name.replace('@ms', '@ccms') + '...')
|
||||
// @ts-ignore
|
||||
console.warn(lastModule + ' load deprecated module ' + name + ' auto replace to ' + (name = name.replace('@ms', global.scope)) + '...')
|
||||
return name;
|
||||
} else {
|
||||
lastModule = name
|
||||
}
|
||||
if (CoreModules.indexOf(name) != -1) {
|
||||
var newName = '@ccms/nodejs/dist/' + name
|
||||
// @ts-ignore
|
||||
var newName = global.scope + '/nodejs/dist/' + name
|
||||
if (resolve(newName, path) !== undefined) {
|
||||
return newName;
|
||||
}
|
||||
throw new Error("Can't load nodejs core module " + name + " . maybe later will auto replace to @ccms/nodejs/" + name + ' to compatible...')
|
||||
// @ts-ignore
|
||||
throw new Error("Can't load nodejs core module " + name + " . maybe later will auto replace to " + global.scope + "/nodejs/" + name + ' to compatible...')
|
||||
}
|
||||
return name;
|
||||
}
|
||||
@ -372,24 +384,12 @@
|
||||
}
|
||||
return __DynamicRequire__
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} parent
|
||||
* @param {string} parentId
|
||||
*/
|
||||
function getRequire(parent, parentId) {
|
||||
/**
|
||||
* @type {any} require
|
||||
*/
|
||||
var require = exports(parent, parentId)
|
||||
require.resolve =
|
||||
/**
|
||||
* @param {string} name
|
||||
*/
|
||||
function __DynamicResolve__(name) {
|
||||
return _canonical(new File(resolve(name, parent)))
|
||||
}
|
||||
require.clear =
|
||||
/**
|
||||
* @param {string} name
|
||||
*/
|
||||
@ -401,7 +401,7 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
require.disable = function __DynamicDisable__() {
|
||||
function __DynamicDisable__() {
|
||||
for (var cacheModule in cacheModules) {
|
||||
delete cacheModules[cacheModule]
|
||||
}
|
||||
@ -412,7 +412,20 @@
|
||||
cacheModuleIds = undefined;
|
||||
notFoundModules = undefined;
|
||||
}
|
||||
return require;
|
||||
/**
|
||||
* @param {string} parent
|
||||
* @param {string} parentId
|
||||
*/
|
||||
function getRequire(parent, parentId) {
|
||||
/**
|
||||
* @type {any} require
|
||||
*/
|
||||
var require = exports(parent, parentId)
|
||||
require.resolve = __DynamicResolve__
|
||||
require.clear = __DynamicClear__
|
||||
require.disable = __DynamicDisable__
|
||||
require.core_modules = CoreModules
|
||||
return require
|
||||
}
|
||||
|
||||
if (typeof parent === 'string') {
|
||||
|
Loading…
Reference in New Issue
Block a user