@lowdefy/build 5.5.0 → 5.5.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.
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2020-2026 Lowdefy, Inc
|
|
3
|
+
|
|
4
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
you may not use this file except in compliance with the License.
|
|
6
|
+
You may obtain a copy of the License at
|
|
7
|
+
|
|
8
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
|
|
10
|
+
Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
See the License for the specific language governing permissions and
|
|
14
|
+
limitations under the License.
|
|
15
|
+
*/ import path from 'path';
|
|
16
|
+
import { type } from '@lowdefy/helpers';
|
|
17
|
+
// Module refs author their path/resolver/transformer relative to the module
|
|
18
|
+
// (e.g. "resolvers/makeActionPages.js"). Rebase those relative paths against the
|
|
19
|
+
// module root so they resolve from the module, not the app config dir. Mutates
|
|
20
|
+
// refDef in place. No-op when moduleRoot is not set or a path is already absolute.
|
|
21
|
+
function rebaseModuleRefPaths({ refDef, moduleRoot }) {
|
|
22
|
+
if (!moduleRoot) return refDef;
|
|
23
|
+
for (const field of [
|
|
24
|
+
'path',
|
|
25
|
+
'resolver',
|
|
26
|
+
'transformer'
|
|
27
|
+
]){
|
|
28
|
+
if (type.isString(refDef[field]) && !path.isAbsolute(refDef[field])) {
|
|
29
|
+
refDef[field] = path.resolve(moduleRoot, refDef[field]);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return refDef;
|
|
33
|
+
}
|
|
34
|
+
export default rebaseModuleRefPaths;
|
|
@@ -17,6 +17,7 @@ import { get, serializer, type } from '@lowdefy/helpers';
|
|
|
17
17
|
import { ConfigError } from '@lowdefy/errors';
|
|
18
18
|
import { evaluateOperators } from '@lowdefy/operators';
|
|
19
19
|
import makeRefDefinition from './makeRefDefinition.js';
|
|
20
|
+
import rebaseModuleRefPaths from './rebaseModuleRefPaths.js';
|
|
20
21
|
import getRefContent from './getRefContent.js';
|
|
21
22
|
import getModuleRefContent from './getModuleRefContent.js';
|
|
22
23
|
import runTransformer from './runTransformer.js';
|
|
@@ -470,17 +471,10 @@ async function resolveRef(node, ctx) {
|
|
|
470
471
|
refDef.key = await resolve(cloneForResolve(refDef.key), ctx);
|
|
471
472
|
}
|
|
472
473
|
// 4. Module path resolution: resolve relative paths from the module root
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
if (type.isString(refDef.resolver) && !path.isAbsolute(refDef.resolver)) {
|
|
478
|
-
refDef.resolver = path.resolve(ctx.moduleRoot, refDef.resolver);
|
|
479
|
-
}
|
|
480
|
-
if (type.isString(refDef.transformer) && !path.isAbsolute(refDef.transformer)) {
|
|
481
|
-
refDef.transformer = path.resolve(ctx.moduleRoot, refDef.transformer);
|
|
482
|
-
}
|
|
483
|
-
}
|
|
474
|
+
rebaseModuleRefPaths({
|
|
475
|
+
refDef,
|
|
476
|
+
moduleRoot: ctx.moduleRoot
|
|
477
|
+
});
|
|
484
478
|
// 5. Update refMap with resolved path; store original for resolver refs
|
|
485
479
|
ctx.refMap[refDef.id].path = refDef.path;
|
|
486
480
|
if (!refDef.path) {
|
|
@@ -31,6 +31,7 @@ import evaluateStaticOperators from '../buildRefs/evaluateStaticOperators.js';
|
|
|
31
31
|
import getRefContent from '../buildRefs/getRefContent.js';
|
|
32
32
|
import jsMapParser from '../buildJs/jsMapParser.js';
|
|
33
33
|
import makeRefDefinition from '../buildRefs/makeRefDefinition.js';
|
|
34
|
+
import rebaseModuleRefPaths from '../buildRefs/rebaseModuleRefPaths.js';
|
|
34
35
|
import { resolve, WalkContext, cloneForResolve, tagRefDeep } from '../buildRefs/walker.js';
|
|
35
36
|
import validateOperatorsDynamic from '../validateOperatorsDynamic.js';
|
|
36
37
|
import writeMaps from '../writeMaps.js';
|
|
@@ -151,6 +152,23 @@ async function buildPageJit({ pageId, pageRegistry, context, directories, logger
|
|
|
151
152
|
refDef = makeRefDefinition(refDefinition, null, buildContext.refMap);
|
|
152
153
|
buildContext.refMap[refDef.id].path = refDef.path;
|
|
153
154
|
}
|
|
155
|
+
// Module path resolution: resolve relative path/resolver/transformer from the
|
|
156
|
+
// module root. The full build does this in walker.js step 4 when an _ref node
|
|
157
|
+
// is encountered, but the JIT path builds the page refDef directly from
|
|
158
|
+
// resolverOriginal (the un-rebased authored _ref) and calls getRefContent
|
|
159
|
+
// without going through the walker — so a module resolver like
|
|
160
|
+
// "resolvers/makeActionPages.js" would otherwise resolve against the app
|
|
161
|
+
// config dir instead of the module root. (File-based module pages are
|
|
162
|
+
// unaffected: their paths are stored already-rebased in refMap.)
|
|
163
|
+
if (moduleEntry?.moduleRoot) {
|
|
164
|
+
rebaseModuleRefPaths({
|
|
165
|
+
refDef,
|
|
166
|
+
moduleRoot: moduleEntry.moduleRoot
|
|
167
|
+
});
|
|
168
|
+
if (type.isString(refDef.path)) {
|
|
169
|
+
buildContext.refMap[refDef.id].path = refDef.path;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
154
172
|
const pageContent = await getRefContent({
|
|
155
173
|
context: buildContext,
|
|
156
174
|
refDef,
|