From f43c1d902d908c6cd523b0174338ac0c98a30647 Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Thu, 16 Aug 2018 10:57:25 +0200 Subject: Add support for importing ES modules in .qml files This is a straight-forward hook into the module implementation in QV4::ExecutionEngine. Modules are pre-compiled in the QML type loader thread. That thread keeps track of all pending loading scripts through the type loader's m_scriptCache. Once a module is compiled, it's thread-safely registered with the execution engine. Script instantiation and evaluation is done solely in the QQmlEngine's thread. ES Modules are identified in imports as well as qmldir files by the .mjs extension. Change-Id: Ie9c59785118afcb49f43a1e176a9f7db00f09428 Reviewed-by: Lars Knoll --- src/qml/jsruntime/qv4engine_p.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/qml/jsruntime/qv4engine_p.h') diff --git a/src/qml/jsruntime/qv4engine_p.h b/src/qml/jsruntime/qv4engine_p.h index 4cd7e40013..8312adee48 100644 --- a/src/qml/jsruntime/qv4engine_p.h +++ b/src/qml/jsruntime/qv4engine_p.h @@ -580,8 +580,10 @@ public: QQmlRefPointer compileModule(const QUrl &url, const QString &sourceCode); static QQmlRefPointer compileModule(bool debugMode, const QUrl &url, const QString &sourceCode, QList *diagnostics); + mutable QMutex moduleMutex; QHash> modules; void injectModule(const QQmlRefPointer &moduleUnit); + QQmlRefPointer moduleForUrl(const QUrl &_url, const CompiledData::CompilationUnit *referrer = nullptr) const; QQmlRefPointer loadModule(const QUrl &_url, const CompiledData::CompilationUnit *referrer = nullptr); #endif -- cgit v1.2.3