@@ -111,7 +111,9 @@ class IncludeDef {
111111 // -- resolve the concrete against the current script
112112 final moduleFile = realModulePath(path). normalize()
113113 // -- load the module
114- final moduleScript = loadModule0(moduleFile, resolveParams(ownerParams), session)
114+ final moduleScript = NF . getSyntaxParserVersion() == ' v2'
115+ ? loadModuleV2(moduleFile, ownerParams, session)
116+ : loadModuleV1(moduleFile, resolveParams(ownerParams), session)
115117 // -- add it to the inclusions
116118 for ( Module module : modules ) {
117119 meta. addModule(moduleScript, module. name, module. alias)
@@ -133,19 +135,37 @@ class IncludeDef {
133135 @PackageScope
134136 Path getOwnerPath () { getMeta(). getScriptPath() }
135137
138+ /**
139+ * When using the strict syntax, the included script will already
140+ * have been compiled, so simply execute it to load its definitions.
141+ *
142+ * @param path The included script path
143+ * @param params The params of the including script
144+ * @param session The current workflow run
145+ */
136146 @PackageScope
137147 @Memoized
138- static BaseScript loadModule0 (Path path , Map params , Session session ) {
148+ static BaseScript loadModuleV2 (Path path , Map params , Session session ) {
139149 final script = ScriptMeta . getScriptByPath(path)
140- if ( script ) {
141- script. getBinding(). setParams(params)
142- script. run()
143- return script
144- }
150+ if ( ! script )
151+ throw new IllegalStateException ()
152+ script. getBinding(). setParams(params)
153+ script. run()
154+ return script
155+ }
145156
157+ /**
158+ * When not using the strict syntax, compile and execute the
159+ * included script to load its definitions.
160+ *
161+ * @param path The included script path
162+ * @param params The params of the including script
163+ * @param session The current workflow run
164+ */
165+ @PackageScope
166+ @Memoized
167+ static BaseScript loadModuleV1 (Path path , Map params , Session session ) {
146168 final binding = new ScriptBinding () .setParams(params)
147-
148- // the execution of a library file has as side effect the registration of declared processes
149169 new ScriptLoaderV1 (session)
150170 .setModule(true )
151171 .setBinding(binding)
0 commit comments