firefly-compiler 0.5.16 → 0.5.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/compiler/Builder.ff +15 -1
- package/compiler/Compiler.ff +8 -3
- package/compiler/JsEmitter.ff +5 -5
- package/output/js/ff/compiler/Builder.mjs +32 -0
- package/output/js/ff/compiler/Compiler.mjs +6 -2
- package/output/js/ff/compiler/JsEmitter.mjs +273 -273
- package/package.json +1 -1
- package/vscode/package.json +1 -1
package/compiler/Builder.ff
CHANGED
|
@@ -44,6 +44,7 @@ build(
|
|
|
44
44
|
if(printMeasurements) {compiler.printMeasurements()}
|
|
45
45
|
resolvedDependencies.packagePaths.each {packagePair, packagePath =>
|
|
46
46
|
resolvedDependencies.packages.get(packagePair).each {packageInfo =>
|
|
47
|
+
processNodeModules(system, jsPathFile, packagePath, packageInfo)
|
|
47
48
|
processIncludes(jsPathFile, packagePath, packageInfo)
|
|
48
49
|
}
|
|
49
50
|
}
|
|
@@ -57,7 +58,7 @@ build(
|
|
|
57
58
|
|
|
58
59
|
}
|
|
59
60
|
|
|
60
|
-
processIncludes(jsPathFile: Path, packagePath: Path, info: PackageInfo)
|
|
61
|
+
processIncludes(jsPathFile: Path, packagePath: Path, info: PackageInfo) {
|
|
61
62
|
info.includes.each {include =>
|
|
62
63
|
let fromPath = packagePath.slash(".firefly").slash("include").slash(include.path)
|
|
63
64
|
let toPath = jsPathFile.slash(info.package.packagePair.groupName("/")).slash(include.path)
|
|
@@ -65,6 +66,19 @@ processIncludes(jsPathFile: Path, packagePath: Path, info: PackageInfo): Unit {
|
|
|
65
66
|
}
|
|
66
67
|
}
|
|
67
68
|
|
|
69
|
+
processNodeModules(system: NodeSystem, jsPathFile: Path, packagePath: Path, info: PackageInfo) {
|
|
70
|
+
if(info.includes.any {_.path == "node_modules"}) {
|
|
71
|
+
let includePath = packagePath.slash(".firefly").slash("include")
|
|
72
|
+
let nodeModules = includePath.slash("node_modules")
|
|
73
|
+
let packageJson = includePath.slash("package.json")
|
|
74
|
+
let packageLockJson = includePath.slash("package-lock.json")
|
|
75
|
+
if(!nodeModules.exists() && packageJson.exists() && packageLockJson.exists()) {
|
|
76
|
+
system.writeErrorLine("Running npm ci --no-bin-links in " + includePath.absolute())
|
|
77
|
+
system.execute("npm", ["ci", "--no-bin-links"], directory = Some(includePath))
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
68
82
|
buildViaBuildSystem(system: NodeSystem, fireflyPath: Path, mainFile: String, target: String) {
|
|
69
83
|
let resolvedDependencies = Dependencies.process(
|
|
70
84
|
system.httpClient()
|
package/compiler/Compiler.ff
CHANGED
|
@@ -216,9 +216,14 @@ extend self: Compiler {
|
|
|
216
216
|
}
|
|
217
217
|
|
|
218
218
|
let allModules = [module, ...otherModules]
|
|
219
|
-
let js =
|
|
220
|
-
|
|
221
|
-
.
|
|
219
|
+
let js = JsEmitter.new(
|
|
220
|
+
otherModules = allModules
|
|
221
|
+
emitTarget = self.emitTarget
|
|
222
|
+
isMainModule = isMainModule
|
|
223
|
+
compilerModuleFileUrl = self.compilerModulePath.map {_.url()}
|
|
224
|
+
packagePair = packagePair
|
|
225
|
+
moduleName = moduleName
|
|
226
|
+
).emitModule(packagePair, module)
|
|
222
227
|
let jsPath = self.jsOutputPath.slash(packagePair.group).slash(packagePair.name)
|
|
223
228
|
let jsFile = jsPath.slash(moduleName + ".mjs")
|
|
224
229
|
jsPath.createDirectory(createParentDirectories = True)
|
package/compiler/JsEmitter.ff
CHANGED
|
@@ -2,12 +2,12 @@ import Syntax
|
|
|
2
2
|
import Patterns
|
|
3
3
|
import JsImporter
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
class JsEmitter(
|
|
6
6
|
otherModules: Map[String, Module]
|
|
7
7
|
jsImporter: JsImporter
|
|
8
8
|
emitTarget: EmitTarget
|
|
9
9
|
isMainModule: Bool
|
|
10
|
-
|
|
10
|
+
compilerModuleFileUrl: Option[String]
|
|
11
11
|
packagePair: PackagePair
|
|
12
12
|
moduleName: String
|
|
13
13
|
mutable emittingAsync: Bool
|
|
@@ -25,7 +25,7 @@ new(
|
|
|
25
25
|
otherModules: List[Module]
|
|
26
26
|
emitTarget: EmitTarget
|
|
27
27
|
isMainModule: Bool
|
|
28
|
-
|
|
28
|
+
compilerModuleFileUrl: Option[String]
|
|
29
29
|
packagePair: PackagePair
|
|
30
30
|
moduleName: String
|
|
31
31
|
): JsEmitter {
|
|
@@ -37,7 +37,7 @@ new(
|
|
|
37
37
|
jsImporter = JsImporter.new()
|
|
38
38
|
emitTarget = emitTarget
|
|
39
39
|
isMainModule = isMainModule
|
|
40
|
-
|
|
40
|
+
compilerModuleFileUrl = compilerModuleFileUrl
|
|
41
41
|
packagePair = packagePair
|
|
42
42
|
moduleName = moduleName
|
|
43
43
|
emittingAsync = False
|
|
@@ -56,7 +56,7 @@ extend self: JsEmitter {
|
|
|
56
56
|
"import * as " + packagePair.groupName("_") + "_" + module.file.dropLast(3) + " " +
|
|
57
57
|
"from \"../../" + packagePair.groupName("/") + "/" + module.file.dropLast(3) + ".mjs\""
|
|
58
58
|
let imports = [
|
|
59
|
-
self.
|
|
59
|
+
self.compilerModuleFileUrl.map {"import * as $firefly_compiler from '" + _ + "'"}.toList()
|
|
60
60
|
module.imports.sortBy {i => Pair(i.package, i.file) }.map {self.emitImportDefinition(_)}
|
|
61
61
|
].flatten()
|
|
62
62
|
let parts = [
|
|
@@ -139,6 +139,7 @@ ff_compiler_Compiler.Compiler_printMeasurements(compiler_)
|
|
|
139
139
|
ff_core_Map.Map_each(resolvedDependencies_.packagePaths_, ((packagePair_, packagePath_) => {
|
|
140
140
|
for(const for_o = ff_core_Map.Map_get(resolvedDependencies_.packages_, packagePair_, ff_compiler_Syntax.ff_core_Ordering_Order$ff_compiler_Syntax_PackagePair); for_o.Some;) {
|
|
141
141
|
const packageInfo_ = for_o.value_;
|
|
142
|
+
ff_compiler_Builder.processNodeModules_(system_, jsPathFile_, packagePath_, packageInfo_);
|
|
142
143
|
ff_compiler_Builder.processIncludes_(jsPathFile_, packagePath_, packageInfo_)
|
|
143
144
|
break
|
|
144
145
|
}
|
|
@@ -162,6 +163,21 @@ ff_core_Path.Path_copyTo(fromPath_, toPath_, 0, 100)
|
|
|
162
163
|
}
|
|
163
164
|
}
|
|
164
165
|
|
|
166
|
+
export function processNodeModules_(system_, jsPathFile_, packagePath_, info_) {
|
|
167
|
+
if(ff_core_List.List_any(info_.includes_, ((_w1) => {
|
|
168
|
+
return (_w1.path_ === "node_modules")
|
|
169
|
+
}))) {
|
|
170
|
+
const includePath_ = ff_core_Path.Path_slash(ff_core_Path.Path_slash(packagePath_, ".firefly"), "include");
|
|
171
|
+
const nodeModules_ = ff_core_Path.Path_slash(includePath_, "node_modules");
|
|
172
|
+
const packageJson_ = ff_core_Path.Path_slash(includePath_, "package.json");
|
|
173
|
+
const packageLockJson_ = ff_core_Path.Path_slash(includePath_, "package-lock.json");
|
|
174
|
+
if((((!ff_core_Path.Path_exists(nodeModules_, false, false, false)) && ff_core_Path.Path_exists(packageJson_, false, false, false)) && ff_core_Path.Path_exists(packageLockJson_, false, false, false))) {
|
|
175
|
+
ff_core_NodeSystem.NodeSystem_writeErrorLine(system_, ("Running npm ci --no-bin-links in " + ff_core_Path.Path_absolute(includePath_)));
|
|
176
|
+
ff_core_NodeSystem.NodeSystem_execute(system_, "npm", ["ci", "--no-bin-links"], ff_core_Buffer.new_(0, false), ff_core_Option.Some(includePath_), ff_core_Option.None(), 16777216, 9, true)
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
|
|
165
181
|
export function buildViaBuildSystem_(system_, fireflyPath_, mainFile_, target_) {
|
|
166
182
|
const resolvedDependencies_ = ff_compiler_Dependencies.process_(ff_core_NodeSystem.NodeSystem_httpClient(system_), ff_compiler_DependencyLock.new_(ff_core_NodeSystem.NodeSystem_mainTask(system_)), ff_core_NodeSystem.NodeSystem_path(system_, mainFile_));
|
|
167
183
|
const fixedPackagePaths_ = (ff_core_Map.Map_contains(resolvedDependencies_.packagePaths_, ff_compiler_Syntax.PackagePair("ff", "core"), ff_compiler_Syntax.ff_core_Ordering_Order$ff_compiler_Syntax_PackagePair)
|
|
@@ -338,6 +354,7 @@ if(printMeasurements_) {
|
|
|
338
354
|
(await ff_core_Map.Map_each$(resolvedDependencies_.packagePaths_, (async (packagePair_, packagePath_, $task) => {
|
|
339
355
|
for(const for_o = ff_core_Map.Map_get(resolvedDependencies_.packages_, packagePair_, ff_compiler_Syntax.ff_core_Ordering_Order$ff_compiler_Syntax_PackagePair); for_o.Some;) {
|
|
340
356
|
const packageInfo_ = for_o.value_;
|
|
357
|
+
(await ff_compiler_Builder.processNodeModules_$(system_, jsPathFile_, packagePath_, packageInfo_, $task));
|
|
341
358
|
(await ff_compiler_Builder.processIncludes_$(jsPathFile_, packagePath_, packageInfo_, $task))
|
|
342
359
|
break
|
|
343
360
|
}
|
|
@@ -361,6 +378,21 @@ const toPath_ = (await ff_core_Path.Path_slash$((await ff_core_Path.Path_slash$(
|
|
|
361
378
|
}
|
|
362
379
|
}
|
|
363
380
|
|
|
381
|
+
export async function processNodeModules_$(system_, jsPathFile_, packagePath_, info_, $task) {
|
|
382
|
+
if(ff_core_List.List_any(info_.includes_, ((_w1) => {
|
|
383
|
+
return (_w1.path_ === "node_modules")
|
|
384
|
+
}))) {
|
|
385
|
+
const includePath_ = (await ff_core_Path.Path_slash$((await ff_core_Path.Path_slash$(packagePath_, ".firefly", $task)), "include", $task));
|
|
386
|
+
const nodeModules_ = (await ff_core_Path.Path_slash$(includePath_, "node_modules", $task));
|
|
387
|
+
const packageJson_ = (await ff_core_Path.Path_slash$(includePath_, "package.json", $task));
|
|
388
|
+
const packageLockJson_ = (await ff_core_Path.Path_slash$(includePath_, "package-lock.json", $task));
|
|
389
|
+
if((((!(await ff_core_Path.Path_exists$(nodeModules_, false, false, false, $task))) && (await ff_core_Path.Path_exists$(packageJson_, false, false, false, $task))) && (await ff_core_Path.Path_exists$(packageLockJson_, false, false, false, $task)))) {
|
|
390
|
+
(await ff_core_NodeSystem.NodeSystem_writeErrorLine$(system_, ("Running npm ci --no-bin-links in " + (await ff_core_Path.Path_absolute$(includePath_, $task))), $task));
|
|
391
|
+
(await ff_core_NodeSystem.NodeSystem_execute$(system_, "npm", ["ci", "--no-bin-links"], ff_core_Buffer.new_(0, false), ff_core_Option.Some(includePath_), ff_core_Option.None(), 16777216, 9, true, $task))
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
|
|
364
396
|
export async function buildViaBuildSystem_$(system_, fireflyPath_, mainFile_, target_, $task) {
|
|
365
397
|
const resolvedDependencies_ = (await ff_compiler_Dependencies.process_$((await ff_core_NodeSystem.NodeSystem_httpClient$(system_, $task)), (await ff_compiler_DependencyLock.new_$((await ff_core_NodeSystem.NodeSystem_mainTask$(system_, $task)), $task)), (await ff_core_NodeSystem.NodeSystem_path$(system_, mainFile_, $task)), $task));
|
|
366
398
|
const fixedPackagePaths_ = (ff_core_Map.Map_contains(resolvedDependencies_.packagePaths_, ff_compiler_Syntax.PackagePair("ff", "core"), ff_compiler_Syntax.ff_core_Ordering_Order$ff_compiler_Syntax_PackagePair)
|
|
@@ -265,7 +265,9 @@ ff_compiler_Compiler.Compiler_emit(self_, i_.packagePair_, newModuleName_, false
|
|
|
265
265
|
return ff_compiler_Compiler.Compiler_infer(self_, i_.packagePair_, newModuleName_)
|
|
266
266
|
}));
|
|
267
267
|
const allModules_ = [module_, ...otherModules_];
|
|
268
|
-
const js_ = ff_compiler_JsEmitter.JsEmitter_emitModule(ff_compiler_JsEmitter.new_(allModules_, self_.emitTarget_, isMainModule_, self_.compilerModulePath_,
|
|
268
|
+
const js_ = ff_compiler_JsEmitter.JsEmitter_emitModule(ff_compiler_JsEmitter.new_(allModules_, self_.emitTarget_, isMainModule_, ff_core_Option.Option_map(self_.compilerModulePath_, ((_w1) => {
|
|
269
|
+
return ff_core_Path.Path_url(_w1)
|
|
270
|
+
})), packagePair_, moduleName_), packagePair_, module_);
|
|
269
271
|
const jsPath_ = ff_core_Path.Path_slash(ff_core_Path.Path_slash(self_.jsOutputPath_, packagePair_.group_), packagePair_.name_);
|
|
270
272
|
const jsFile_ = ff_core_Path.Path_slash(jsPath_, (moduleName_ + ".mjs"));
|
|
271
273
|
ff_core_Path.Path_createDirectory(jsPath_, true);
|
|
@@ -398,7 +400,9 @@ const newModuleName_ = ff_core_String.String_dropLast(i_.file_, ff_core_String.S
|
|
|
398
400
|
return (await ff_compiler_Compiler.Compiler_infer$(self_, i_.packagePair_, newModuleName_, $task))
|
|
399
401
|
}), $task));
|
|
400
402
|
const allModules_ = [module_, ...otherModules_];
|
|
401
|
-
const js_ =
|
|
403
|
+
const js_ = ff_compiler_JsEmitter.JsEmitter_emitModule(ff_compiler_JsEmitter.new_(allModules_, self_.emitTarget_, isMainModule_, (await ff_core_Option.Option_map$(self_.compilerModulePath_, (async (_w1, $task) => {
|
|
404
|
+
return (await ff_core_Path.Path_url$(_w1, $task))
|
|
405
|
+
}), $task)), packagePair_, moduleName_), packagePair_, module_);
|
|
402
406
|
const jsPath_ = (await ff_core_Path.Path_slash$((await ff_core_Path.Path_slash$(self_.jsOutputPath_, packagePair_.group_, $task)), packagePair_.name_, $task));
|
|
403
407
|
const jsFile_ = (await ff_core_Path.Path_slash$(jsPath_, (moduleName_ + ".mjs"), $task));
|
|
404
408
|
(await ff_core_Path.Path_createDirectory$(jsPath_, true, $task));
|