@merkur/integration 0.35.0 → 0.35.3
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/package.json +2 -2
- package/server/index.js +36 -9
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@merkur/integration",
|
|
3
|
-
"version": "0.35.
|
|
3
|
+
"version": "0.35.3",
|
|
4
4
|
"description": "Merkur module for easy integration with other apps.",
|
|
5
5
|
"main": "lib/index",
|
|
6
6
|
"module": "lib/index",
|
|
@@ -54,5 +54,5 @@
|
|
|
54
54
|
"peerDependencies": {
|
|
55
55
|
"@merkur/core": "*"
|
|
56
56
|
},
|
|
57
|
-
"gitHead": "
|
|
57
|
+
"gitHead": "6b65a5581c1c32a14479c3bb4702c394592d0a20"
|
|
58
58
|
}
|
package/server/index.js
CHANGED
|
@@ -22,21 +22,34 @@ async function processAssetInFolder({
|
|
|
22
22
|
fileName,
|
|
23
23
|
staticFolder,
|
|
24
24
|
staticBaseUrl,
|
|
25
|
+
cliConfig,
|
|
25
26
|
}) {
|
|
26
27
|
if (!asset.name || !fileName || typeof asset.source === 'string') {
|
|
27
28
|
return asset;
|
|
28
29
|
}
|
|
29
30
|
|
|
30
31
|
if (asset.type.includes('inline')) {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
32
|
+
try {
|
|
33
|
+
asset.source = await fsp.readFile(
|
|
34
|
+
path.join(staticFolder, folder, fileName),
|
|
35
|
+
{ encoding: 'utf-8' },
|
|
36
|
+
);
|
|
37
|
+
} catch (error) {
|
|
38
|
+
// TODO remove (process.env.NODE_ENV !== 'development' && !cliConfig)
|
|
39
|
+
if (
|
|
40
|
+
(process.env.NODE_ENV !== 'development' && !cliConfig) ||
|
|
41
|
+
(cliConfig?.writeToDisk && cliConfig?.command !== 'dev')
|
|
42
|
+
) {
|
|
43
|
+
throw error;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
35
46
|
|
|
36
|
-
|
|
47
|
+
if (asset.source) {
|
|
48
|
+
return asset;
|
|
49
|
+
}
|
|
37
50
|
}
|
|
38
51
|
|
|
39
|
-
if (asset.type === 'stylesheet') {
|
|
52
|
+
if (asset.type === 'stylesheet' || asset.type === 'inlineStyle') {
|
|
40
53
|
asset.source = `${staticBaseUrl}/${folder}/${fileName}`;
|
|
41
54
|
|
|
42
55
|
return asset;
|
|
@@ -48,11 +61,25 @@ async function processAssetInFolder({
|
|
|
48
61
|
return asset;
|
|
49
62
|
}
|
|
50
63
|
|
|
51
|
-
|
|
64
|
+
// TODO remove folders
|
|
65
|
+
async function createAssets({
|
|
66
|
+
assets,
|
|
67
|
+
staticFolder,
|
|
68
|
+
staticBaseUrl,
|
|
69
|
+
folders,
|
|
70
|
+
cliConfig,
|
|
71
|
+
merkurConfig,
|
|
72
|
+
}) {
|
|
52
73
|
if (staticBaseUrl.endsWith('/')) {
|
|
53
74
|
staticBaseUrl = staticBaseUrl.slice(0, -1);
|
|
54
75
|
}
|
|
55
76
|
|
|
77
|
+
folders =
|
|
78
|
+
folders ||
|
|
79
|
+
Object.values(merkurConfig?.task)
|
|
80
|
+
.filter((task) => task.build.platform !== 'node')
|
|
81
|
+
.map((task) => task.name);
|
|
82
|
+
|
|
56
83
|
const processedAssets = await folders.reduce(
|
|
57
84
|
async (assets, folder) => {
|
|
58
85
|
assets = await assets;
|
|
@@ -73,6 +100,8 @@ async function createAssets({ assets, staticFolder, folders, staticBaseUrl }) {
|
|
|
73
100
|
fileName: manifest[asset.name],
|
|
74
101
|
staticBaseUrl,
|
|
75
102
|
staticFolder,
|
|
103
|
+
cliConfig,
|
|
104
|
+
merkurConfig,
|
|
76
105
|
}),
|
|
77
106
|
),
|
|
78
107
|
);
|
|
@@ -119,7 +148,6 @@ function deleteCache(modulePath, force = false) {
|
|
|
119
148
|
});
|
|
120
149
|
}
|
|
121
150
|
}
|
|
122
|
-
|
|
123
151
|
function searchCache(moduleName, callback) {
|
|
124
152
|
if (moduleName && require.cache[moduleName] !== undefined) {
|
|
125
153
|
const module = require.cache[moduleName];
|
|
@@ -147,7 +175,6 @@ function traverse(module, callback) {
|
|
|
147
175
|
const memoPathResolve = memo(path.resolve);
|
|
148
176
|
function requireUncached(module, options = {}) {
|
|
149
177
|
const modulePath = memoPathResolve(module);
|
|
150
|
-
|
|
151
178
|
if (process.env.NODE_WATCH === 'true') {
|
|
152
179
|
if (options.optional && modulePath && !getFileStats(modulePath)) {
|
|
153
180
|
return;
|