@maka/meteor-sdk 0.2.0 → 0.2.1
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/isopackets/combined/npm/node_modules/meteor/babel-compiler/node_modules/.package-lock.json +1 -1
- package/isopackets/combined/npm/node_modules/meteor/boilerplate-generator/node_modules/.package-lock.json +1 -1
- package/isopackets/combined/npm/node_modules/meteor/constraint-solver/node_modules/.package-lock.json +1 -1
- package/isopackets/combined/npm/node_modules/meteor/ddp-client/node_modules/.package-lock.json +1 -1
- package/isopackets/combined/npm/node_modules/meteor/ecmascript/node_modules/.package-lock.json +1 -1
- package/isopackets/combined/npm/node_modules/meteor/ecmascript-runtime/node_modules/.package-lock.json +1 -1
- package/isopackets/combined/npm/node_modules/meteor/ecmascript-runtime-client/node_modules/.package-lock.json +1 -1
- package/isopackets/combined/npm/node_modules/meteor/ecmascript-runtime-server/node_modules/.package-lock.json +1 -1
- package/isopackets/combined/npm/node_modules/meteor/fetch/node_modules/.package-lock.json +1 -1
- package/isopackets/combined/npm/node_modules/meteor/inter-process-messaging/node_modules/.package-lock.json +1 -1
- package/isopackets/combined/npm/node_modules/meteor/logging/node_modules/.package-lock.json +1 -1
- package/isopackets/combined/npm/node_modules/meteor/logic-solver/node_modules/.package-lock.json +1 -1
- package/isopackets/combined/npm/node_modules/meteor/meteor/node_modules/.package-lock.json +1 -1
- package/isopackets/combined/npm/node_modules/meteor/modules/node_modules/.package-lock.json +1 -1
- package/isopackets/combined/npm/node_modules/meteor/modules-runtime/node_modules/.package-lock.json +1 -1
- package/isopackets/combined/npm/node_modules/meteor/npm-mongo/node_modules/.package-lock.json +1 -1
- package/isopackets/combined/npm/node_modules/meteor/package-version-parser/node_modules/.package-lock.json +1 -1
- package/isopackets/combined/npm/node_modules/meteor/promise/node_modules/.package-lock.json +1 -1
- package/isopackets/combined/npm/node_modules/meteor/react-fast-refresh/node_modules/.package-lock.json +1 -1
- package/isopackets/combined/npm/node_modules/meteor/socket-stream-client/node_modules/.package-lock.json +1 -1
- package/package.json +1 -1
- package/src/bootstrap.js +42 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@maka/meteor-sdk",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "Programmatic Node API over the Meteor build tool (bundle/run/create/etc.) -- for driving Meteor's build system from plain Node code instead of shelling out to a meteor CLI (there isn't one anymore; see README.md). \"dependencies\" is generated by scripts/write-tool-package-json.js from scripts/dev-bundle-tool-package.js at the monorepo root -- do not hand-edit that field, edit that file and re-run the script instead.",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"exports": {
|
package/src/bootstrap.js
CHANGED
|
@@ -79,6 +79,47 @@ async function ensureRuntimeReady(offline) {
|
|
|
79
79
|
await catalog.official.initialize({ offline: !!offline });
|
|
80
80
|
}
|
|
81
81
|
|
|
82
|
+
// Compatibility shim for build plugins that introspect the running
|
|
83
|
+
// meteor-tool through `process.mainModule` -- zodern:types' bundled
|
|
84
|
+
// tools-imports.js is the known case in the wild: it does
|
|
85
|
+
// `process.mainModule.filename` to locate the tool's directory, then
|
|
86
|
+
// `process.mainModule.require(<abs path>)` to load isobuild/
|
|
87
|
+
// package-source, project-context, and packaging/tropohouse from it.
|
|
88
|
+
// Under the classic CLI that worked because the entry script was
|
|
89
|
+
// tools/index.js (CJS); an SDK host is typically an ESM entry (or some
|
|
90
|
+
// unrelated CJS file), where process.mainModule is undefined (or points
|
|
91
|
+
// somewhere useless), so any such plugin crashes with "Cannot read
|
|
92
|
+
// properties of undefined (reading 'filename')" while loading -- which
|
|
93
|
+
// also silently disables every file handler that plugin registers
|
|
94
|
+
// (e.g. zodern:types' *.d.ts handler, in turn breaking any package
|
|
95
|
+
// published with d.ts resources, like alanning:roles).
|
|
96
|
+
//
|
|
97
|
+
// The shim only fills in the undefined case (never clobbers a real CJS
|
|
98
|
+
// main module), with `filename` pointing into this package's own tools/
|
|
99
|
+
// (the index.js there need not exist -- plugins only dirname it) and a
|
|
100
|
+
// `require` that resolves the absolute paths plugins compute against
|
|
101
|
+
// it. Those are the exact same files this SDK itself requires, so the
|
|
102
|
+
// require cache serves back the same singletons the running tool uses.
|
|
103
|
+
// Note Node aliases newly-created CJS modules' `require.main` to
|
|
104
|
+
// process.mainModule at load time, so late-loaded CJS sees the shim
|
|
105
|
+
// there too -- harmless (nothing in tools/ reads either; audited).
|
|
106
|
+
function ensureMainModuleShim() {
|
|
107
|
+
if (process.mainModule) {
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
const path = require("path");
|
|
111
|
+
const toolsDir = path.resolve(__dirname, "..", "tools");
|
|
112
|
+
process.mainModule = {
|
|
113
|
+
id: ".",
|
|
114
|
+
filename: path.join(toolsDir, "index.js"),
|
|
115
|
+
loaded: true,
|
|
116
|
+
exports: {},
|
|
117
|
+
children: [],
|
|
118
|
+
paths: [],
|
|
119
|
+
require: (request) => require(request),
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
|
|
82
123
|
// Idempotent: safe to call from every public SDK entry point. The actual
|
|
83
124
|
// Babel require() hook installed by install-babel.js is itself naturally
|
|
84
125
|
// idempotent too (Node's own require() cache means requiring the same
|
|
@@ -107,6 +148,7 @@ async function bootstrap(options) {
|
|
|
107
148
|
// Must happen before install-babel.js (or anything else) has a chance
|
|
108
149
|
// to require tools/console/console.js -- see src/console.js's comment.
|
|
109
150
|
consoleAdapter.setHeadlessEnv();
|
|
151
|
+
ensureMainModuleShim();
|
|
110
152
|
require("../tools/tool-env/install-babel.js");
|
|
111
153
|
ensureAsyncLocalStorage();
|
|
112
154
|
consoleAdapter.patch();
|