History

Fixed Script.require

ksuprynowicz committed 3 years ago

Commit e786fd41 parent 386242d4 files · +50 −9Browse files

Showing the changes to libraries/script-engine/src/ScriptManager.cpp (1 of 4 files). Show all

Unified · Split

libraries/script-engine/src/ScriptManager.cpp+3−2
@@ -1341,7 +1341,7 @@ ScriptValue ScriptManager::newModule(const QString& modulePath, const ScriptValu · 1340 unmodified lines
1341 // module.require is a bound version of require that always resolves relative to that module's path1341 // module.require is a bound version of require that always resolves relative to that module's path
1342 auto boundRequire = _engine->evaluate("(function(id) { return Script.require(Script.require.resolve(id, this.filename)); })", "(boundRequire)");1342 auto boundRequire = _engine->evaluate("(function(id) { return Script.require(Script.require.resolve(id, this.filename)); })", "(boundRequire)");
1343 module.setProperty("require", boundRequire, READONLY_PROP_FLAGS);1343 module.setProperty("require", boundRequire, READONLY_PROP_FLAGS);
1344 qDebug() << "Module object contents" << _engine->scriptValueDebugListMembers(module);1344 //qDebug() << "Module object contents" << _engine->scriptValueDebugListMembers(module);
1345 return module;1345 return module;
1346}1346}
1347 1347
@@ -1421,7 +1421,7 @@ ScriptValue ScriptManager::instantiateModule(const ScriptValue& module, const QS · 73 unmodified lines
1421 closure.setProperty("require", module.property("require"));1421 closure.setProperty("require", module.property("require"));
1422 closure.setProperty("__filename", modulePath, READONLY_HIDDEN_PROP_FLAGS);1422 closure.setProperty("__filename", modulePath, READONLY_HIDDEN_PROP_FLAGS);
1423 closure.setProperty("__dirname", QString(modulePath).replace(QRegExp("/[^/]*$"), ""), READONLY_HIDDEN_PROP_FLAGS);1423 closure.setProperty("__dirname", QString(modulePath).replace(QRegExp("/[^/]*$"), ""), READONLY_HIDDEN_PROP_FLAGS);
1424 _engine->scriptValueDebugDetails(module);1424 //_engine->scriptValueDebugDetails(module);
1425 result = _engine->evaluateInClosure(closure, _engine->newProgram( sourceCode, modulePath ));1425 result = _engine->evaluateInClosure(closure, _engine->newProgram( sourceCode, modulePath ));
1426 }1426 }
1427 _engine->maybeEmitUncaughtException(__FUNCTION__);1427 _engine->maybeEmitUncaughtException(__FUNCTION__);
@@ -1531,6 +1531,7 @@ ScriptValue ScriptManager::require(const QString& moduleId) { · 103 unmodified lines
1531 qCDebug(scriptengine_module) << "//ScriptManager::require(" << moduleId << ")";1531 qCDebug(scriptengine_module) << "//ScriptManager::require(" << moduleId << ")";
1532 1532
1533 _engine->maybeEmitUncaughtException(__FUNCTION__);1533 _engine->maybeEmitUncaughtException(__FUNCTION__);
1534 qCDebug(scriptengine_module) << "Exports: " << _engine->scriptValueDebugDetails(module.property("exports"));
1534 return module.property("exports");1535 return module.property("exports");
1535}1536}
1536 1537