@movable/studio-framework-build-config 2.42.1-canary.0 → 2.43.0
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 +4 -4
- package/src/apps/data-loader.js +31 -25
- package/src/apps/rollup.js +1 -10
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@movable/studio-framework-build-config",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.43.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"private": false,
|
|
6
6
|
"author": "Movable Ink",
|
|
@@ -14,8 +14,8 @@
|
|
|
14
14
|
"@babel/preset-env": "^7.14.1",
|
|
15
15
|
"@babel/preset-react": "^7.14.5",
|
|
16
16
|
"@babel/runtime-corejs2": "^7.14.0",
|
|
17
|
-
"@movable/rollup-plugin-manifest-merger": "^2.
|
|
18
|
-
"@movable/rollup-plugin-package-manifest-validator": "^2.
|
|
17
|
+
"@movable/rollup-plugin-manifest-merger": "^2.43.0",
|
|
18
|
+
"@movable/rollup-plugin-package-manifest-validator": "^2.43.0",
|
|
19
19
|
"@rollup/plugin-url": "^6.0.0",
|
|
20
20
|
"esbuild": "^0.15.14",
|
|
21
21
|
"glob": "^7.1.7",
|
|
@@ -46,5 +46,5 @@
|
|
|
46
46
|
"volta": {
|
|
47
47
|
"extends": "../../package.json"
|
|
48
48
|
},
|
|
49
|
-
"gitHead": "
|
|
49
|
+
"gitHead": "463c301a85be7f9a36d1695be3f4de3c75721d29"
|
|
50
50
|
}
|
package/src/apps/data-loader.js
CHANGED
|
@@ -2,39 +2,17 @@ const esbuild = require('esbuild');
|
|
|
2
2
|
const fs = require('fs').promises;
|
|
3
3
|
const path = require('path');
|
|
4
4
|
|
|
5
|
-
const {
|
|
5
|
+
const { ENVIRONMENT } = process.env;
|
|
6
6
|
|
|
7
7
|
const loaderHtmlSourceDefault = path.resolve(__dirname, './html/loader.html');
|
|
8
8
|
const loaderDebugHtmlSourceDefault = path.resolve(__dirname, './html/loader-debug.html');
|
|
9
9
|
|
|
10
|
-
function
|
|
11
|
-
return new Promise((res) => setTimeout(res, ms));
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
async function waitForFile(filePath) {
|
|
15
|
-
let waitCount = 0;
|
|
16
|
-
while (waitCount < 500) {
|
|
17
|
-
try {
|
|
18
|
-
await fs.stat(filePath);
|
|
19
|
-
break;
|
|
20
|
-
} catch (e) {
|
|
21
|
-
await sleep(200);
|
|
22
|
-
if (++waitCount >= 500) {
|
|
23
|
-
throw e;
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
module.exports = async function buildDataLoader(buildConfig = {}) {
|
|
10
|
+
async function buildDataLoader(watchMode = false, buildConfig = {}) {
|
|
30
11
|
if (typeof buildConfig !== 'object') {
|
|
31
12
|
// might have passed dataLoader: true; if so, use defaults
|
|
32
13
|
buildConfig = {};
|
|
33
14
|
}
|
|
34
15
|
|
|
35
|
-
// We cannot write to dist before dist/index.js appears, or studio-tunnel will break
|
|
36
|
-
await waitForFile('./dist/index.js');
|
|
37
|
-
|
|
38
16
|
console.log('Copying data loader wrappers: dist/loader.html, dist/loader-debug.html');
|
|
39
17
|
|
|
40
18
|
await fs.copyFile(buildConfig.loaderHtml || loaderHtmlSourceDefault, './dist/loader.html');
|
|
@@ -42,6 +20,10 @@ module.exports = async function buildDataLoader(buildConfig = {}) {
|
|
|
42
20
|
|
|
43
21
|
console.log('Building data loader: dist/loader.js');
|
|
44
22
|
|
|
23
|
+
if (watchMode) {
|
|
24
|
+
console.log('Watching for changes to data loader');
|
|
25
|
+
}
|
|
26
|
+
|
|
45
27
|
esbuild.build({
|
|
46
28
|
entryPoints: ['./app/loader/index.js'],
|
|
47
29
|
outfile: 'dist/loader.js',
|
|
@@ -50,7 +32,31 @@ module.exports = async function buildDataLoader(buildConfig = {}) {
|
|
|
50
32
|
bundle: true,
|
|
51
33
|
logLevel: 'info',
|
|
52
34
|
minify: ENVIRONMENT === 'production',
|
|
53
|
-
watch:
|
|
35
|
+
watch: watchMode,
|
|
54
36
|
...buildConfig
|
|
55
37
|
});
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// Only invoke the first time rollup runs
|
|
41
|
+
let dataLoaderBuilt = false;
|
|
42
|
+
|
|
43
|
+
module.exports = function buildDataLoaderPlugin(options = {}) {
|
|
44
|
+
return {
|
|
45
|
+
name: 'build-data-loader',
|
|
46
|
+
closeBundle() {
|
|
47
|
+
if (dataLoaderBuilt) {
|
|
48
|
+
// closeBundle happens on every build; we only invoke esbuild the first time and
|
|
49
|
+
// it watches its own changes
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const { watchMode } = this.meta;
|
|
54
|
+
dataLoaderBuilt = true;
|
|
55
|
+
|
|
56
|
+
buildDataLoader(watchMode, options.dataLoader).catch((error) => {
|
|
57
|
+
console.error(error);
|
|
58
|
+
dataLoaderBuilt = false;
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
};
|
|
56
62
|
};
|
package/src/apps/rollup.js
CHANGED
|
@@ -24,16 +24,6 @@ module.exports = function rollupConfig(passedConfig = {}) {
|
|
|
24
24
|
...passedConfig
|
|
25
25
|
};
|
|
26
26
|
|
|
27
|
-
if (passedConfig.dataLoader) {
|
|
28
|
-
const { dataLoader } = passedConfig;
|
|
29
|
-
delete passedConfig.dataLoader;
|
|
30
|
-
|
|
31
|
-
buildDataLoader(dataLoader).catch((error) => {
|
|
32
|
-
console.error(error);
|
|
33
|
-
process.exit(1);
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
|
|
37
27
|
const vendorTree = {
|
|
38
28
|
input: inputFile,
|
|
39
29
|
plugins: [
|
|
@@ -53,6 +43,7 @@ module.exports = function rollupConfig(passedConfig = {}) {
|
|
|
53
43
|
replace({
|
|
54
44
|
'process.env.NODE_ENV': JSON.stringify('production')
|
|
55
45
|
}),
|
|
46
|
+
config.dataLoader ? buildDataLoader(config.dataLoader) : null,
|
|
56
47
|
config.minify ? minify({ comments: false, sourceMap: true }) : null,
|
|
57
48
|
config.serve ? serve() : null
|
|
58
49
|
].filter(Boolean),
|