@mosetta/build 0.0.9 → 0.0.10
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/CHANGELOG.md +16 -0
- package/package.json +9 -7
- package/src/node.mjs +113 -0
- package/src/nodeApi.mjs +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @mosetta/build
|
|
2
2
|
|
|
3
|
+
## 0.0.10
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 95b93d5: The build's node host is an entry of the build: `@mosetta/build/node` gives the real file system,
|
|
8
|
+
the framework's files resolved from the installed build, and `buildDirectory(root, …)` — the build
|
|
9
|
+
of a palette that lies on disk with its dependencies installed, by the build installed for it. The
|
|
10
|
+
CLI builds with it, and so does a platform's build container: a palette is built by the framework
|
|
11
|
+
version its lock names. `systemjs`, whose files the build mixes into a page, is a dependency of the
|
|
12
|
+
build now, not of the CLI.
|
|
13
|
+
- @mosetta/router@0.0.10
|
|
14
|
+
- @mosetta/runtime@0.0.10
|
|
15
|
+
- @mosetta/server@0.0.10
|
|
16
|
+
- @mosetta/server-action@0.0.10
|
|
17
|
+
- @mosetta/tar@0.0.10
|
|
18
|
+
|
|
3
19
|
## 0.0.9
|
|
4
20
|
|
|
5
21
|
### Patch Changes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mosetta/build",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.10",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "The core of the tile forge: builds a tile palette — its tile side artifacts, their dependency closure, the tile host descriptor. Environment-agnostic — the file system and the bundling engine are supplied from outside.",
|
|
6
6
|
"type": "module",
|
|
@@ -11,7 +11,8 @@
|
|
|
11
11
|
"./packagesResolver": "./src/packagesResolver.mjs",
|
|
12
12
|
"./scanner": "./src/scanner.mjs",
|
|
13
13
|
"./archive": "./src/archive.mjs",
|
|
14
|
-
"./release": "./src/release.mjs"
|
|
14
|
+
"./release": "./src/release.mjs",
|
|
15
|
+
"./node": "./src/node.mjs"
|
|
15
16
|
},
|
|
16
17
|
"dependencies": {
|
|
17
18
|
"@pnpm/dependency-path": "^1000.0.9",
|
|
@@ -24,12 +25,13 @@
|
|
|
24
25
|
"react-dom": "*",
|
|
25
26
|
"resolve.exports": "^2.0.3",
|
|
26
27
|
"scheduler": "*",
|
|
28
|
+
"systemjs": "^6.15.1",
|
|
27
29
|
"yaml": "^2.9.0",
|
|
28
|
-
"@mosetta/
|
|
29
|
-
"@mosetta/
|
|
30
|
-
"@mosetta/
|
|
31
|
-
"@mosetta/tar": "0.0.
|
|
32
|
-
"@mosetta/server": "0.0.
|
|
30
|
+
"@mosetta/router": "0.0.10",
|
|
31
|
+
"@mosetta/runtime": "0.0.10",
|
|
32
|
+
"@mosetta/server": "0.0.10",
|
|
33
|
+
"@mosetta/tar": "0.0.10",
|
|
34
|
+
"@mosetta/server-action": "0.0.10"
|
|
33
35
|
},
|
|
34
36
|
"publishConfig": {
|
|
35
37
|
"access": "public"
|
package/src/node.mjs
ADDED
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
// THE NODE HOST of the build: what a host running in node gives the build — the real file system
|
|
2
|
+
// (read only), the framework's files resolved from this installation, and the build of a palette
|
|
3
|
+
// that lies on disk with its dependencies installed. Shared by the CLI and the platform's build
|
|
4
|
+
// container; anything that runs node builds the same way.
|
|
5
|
+
//
|
|
6
|
+
// Nothing here fetches anything: the dependencies are installed by whoever calls (a developer's
|
|
7
|
+
// pnpm, CI, a build container), the build only reads them.
|
|
8
|
+
//
|
|
9
|
+
// The one entry of the package that is node's: the port's node implementation, an entry of its
|
|
10
|
+
// own (`@mosetta/build/node`) that the build's core never imports.
|
|
11
|
+
/* eslint-disable no-restricted-imports -- the node HOST: the file port and resolution, for node */
|
|
12
|
+
import fs from 'node:fs';
|
|
13
|
+
import { createRequire } from 'node:module';
|
|
14
|
+
import path from 'node:path';
|
|
15
|
+
import { build, INERT_BUILD_CONFIG } from './build.mjs';
|
|
16
|
+
import { FileSystem } from './fileSystem.mjs';
|
|
17
|
+
import { FRAMEWORK_RESOLUTIONS, PackagesResolver, packageDirOf } from './packagesResolver.mjs';
|
|
18
|
+
import { BUILD_CONFIG_FILE, scanCatalog } from './scanner.mjs';
|
|
19
|
+
/* eslint-enable no-restricted-imports */
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Node implementation of the file port: the real FS, read-only.
|
|
23
|
+
*
|
|
24
|
+
* Packages are resolved by `PackagesResolver` from the scanner catalog, identically in all
|
|
25
|
+
* environments — not here.
|
|
26
|
+
*/
|
|
27
|
+
export class NodeFileSystem extends FileSystem {
|
|
28
|
+
readFile(file, encoding = null) {
|
|
29
|
+
return encoding ? fs.readFileSync(file, encoding) : fs.readFileSync(file);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
exists(file) {
|
|
33
|
+
return fs.existsSync(file);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
readDir(dir) {
|
|
37
|
+
return fs.readdirSync(dir, { withFileTypes: true })
|
|
38
|
+
.map((e) => ({ name: e.name, isDirectory: e.isDirectory() }));
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
isDirectory(dir) {
|
|
42
|
+
try {
|
|
43
|
+
return fs.statSync(dir).isDirectory();
|
|
44
|
+
} catch {
|
|
45
|
+
return false;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
realPath(file) {
|
|
50
|
+
return fs.realpathSync(file);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
mtimeMs(file) {
|
|
54
|
+
try {
|
|
55
|
+
return fs.statSync(file).mtimeMs;
|
|
56
|
+
} catch {
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const buildRequire = createRequire(import.meta.url);
|
|
63
|
+
|
|
64
|
+
/** a framework file (`systemjs/dist/system.js`, `@mosetta/runtime/bootstrap`) as this installation of the build resolves it */
|
|
65
|
+
export function frameworkFileOf(specifier) {
|
|
66
|
+
return buildRequire.resolve(specifier);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/** `catalog.framework`: the files of FRAMEWORK_RESOLUTIONS from this installation of the build */
|
|
70
|
+
export function frameworkResolutions() {
|
|
71
|
+
const framework = {};
|
|
72
|
+
for (const spec of FRAMEWORK_RESOLUTIONS) framework[spec] = frameworkFileOf(spec);
|
|
73
|
+
return framework;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* The directory generated sides' imports (the default ssr) resolve from: this installation of the
|
|
78
|
+
* build, where @mosetta/router, @mosetta/server and react are declared.
|
|
79
|
+
*/
|
|
80
|
+
export function frameworkDirOf(fileSystem = new NodeFileSystem()) {
|
|
81
|
+
return packageDirOf(fileSystem, frameworkFileOf('@mosetta/build'));
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* The build of the palette at `root` — on disk, its dependencies installed — with THIS build: the
|
|
86
|
+
* one installed for the palette, so a palette is built by the framework version its lock names.
|
|
87
|
+
* `engine` — the host's bundling engine; `evaluate` — the host's way to run a module the build
|
|
88
|
+
* bundled (settings schemas); `released` — ids the target already holds, not built again. A palette
|
|
89
|
+
* with build hooks (mosetta.build.mjs) needs its `buildConfig` made executable by the host; without
|
|
90
|
+
* one the build is refused rather than made without its hooks.
|
|
91
|
+
*/
|
|
92
|
+
export async function buildDirectory(root, { mode = 'production', engine, log = () => {}, evaluate = null, released = null, buildConfig = null } = {}) {
|
|
93
|
+
const fileSystem = new NodeFileSystem();
|
|
94
|
+
if (!buildConfig && fileSystem.exists(path.join(root, BUILD_CONFIG_FILE))) {
|
|
95
|
+
throw new Error(`the tile palette uses ${BUILD_CONFIG_FILE} (build hooks), but no executable hooks were passed`);
|
|
96
|
+
}
|
|
97
|
+
const frameworkDir = frameworkDirOf(fileSystem);
|
|
98
|
+
const resolver = new PackagesResolver({
|
|
99
|
+
fileSystem,
|
|
100
|
+
catalog: { ...scanCatalog({ fileSystem, root, frameworkDir, includeDev: mode !== 'production', log }), framework: frameworkResolutions() },
|
|
101
|
+
});
|
|
102
|
+
return build(root, {
|
|
103
|
+
mode,
|
|
104
|
+
log,
|
|
105
|
+
fileSystem,
|
|
106
|
+
resolver,
|
|
107
|
+
engine,
|
|
108
|
+
frameworkDir,
|
|
109
|
+
buildConfig: buildConfig ?? INERT_BUILD_CONFIG,
|
|
110
|
+
...(evaluate ? { evaluate } : {}),
|
|
111
|
+
...(released ? { released } : {}),
|
|
112
|
+
});
|
|
113
|
+
}
|
package/src/nodeApi.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* eslint-disable no-restricted-imports -- the ONLY place in the
|
|
1
|
+
/* eslint-disable no-restricted-imports -- the ONLY place in the build's core where `node:*` is allowed (node.mjs is the node host, not the core) */
|
|
2
2
|
import path from 'node:path';
|
|
3
3
|
import crypto from 'node:crypto';
|
|
4
4
|
import { builtinModules } from 'node:module';
|