@embeddable.com/sdk-core 3.8.0 → 3.9.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/lib/index.esm.js +47 -16
- package/lib/index.esm.js.map +1 -1
- package/lib/index.js +49 -17
- package/lib/index.js.map +1 -1
- package/loader/custom-esm-loader.mjs +9 -3
- package/package.json +2 -2
- package/src/dev.test.ts +103 -0
- package/src/dev.ts +14 -8
- package/src/generate.test.ts +49 -1
- package/src/generate.ts +35 -6
package/lib/index.esm.js
CHANGED
|
@@ -23,6 +23,7 @@ import path__default$1, { basename } from 'path';
|
|
|
23
23
|
import axios from 'axios';
|
|
24
24
|
import * as archiver from 'archiver';
|
|
25
25
|
import { select } from '@inquirer/prompts';
|
|
26
|
+
import * as http from 'node:http';
|
|
26
27
|
import { WebSocketServer } from 'ws';
|
|
27
28
|
import * as chokidar from 'chokidar';
|
|
28
29
|
import { stat } from 'fs/promises';
|
|
@@ -477,8 +478,8 @@ async function addComponentTagName(filePath, bundleHash) {
|
|
|
477
478
|
]);
|
|
478
479
|
}
|
|
479
480
|
async function runStencil(ctx) {
|
|
480
|
-
var _a, _b
|
|
481
|
-
const logger = ((_a = ctx.dev) === null || _a === void 0 ? void 0 : _a.logger) || createNodeLogger(
|
|
481
|
+
var _a, _b;
|
|
482
|
+
const logger = ((_a = ctx.dev) === null || _a === void 0 ? void 0 : _a.logger) || createNodeLogger();
|
|
482
483
|
const sys = ((_b = ctx.dev) === null || _b === void 0 ? void 0 : _b.sys) || createNodeSys({ process });
|
|
483
484
|
const devMode = !!ctx.dev;
|
|
484
485
|
const isWindows = process.platform === "win32";
|
|
@@ -494,18 +495,47 @@ async function runStencil(ctx) {
|
|
|
494
495
|
tsconfig: path.resolve(ctx.client.buildDir, "tsconfig.json"),
|
|
495
496
|
namespace: "embeddable-wrapper",
|
|
496
497
|
srcDir: path.resolve(ctx.client.buildDir, "component"),
|
|
498
|
+
sourceMap: !devMode,
|
|
499
|
+
minifyJs: !devMode,
|
|
500
|
+
minifyCss: !devMode,
|
|
497
501
|
outputTargets: [
|
|
498
502
|
{
|
|
499
503
|
type: "dist",
|
|
500
504
|
},
|
|
501
505
|
],
|
|
506
|
+
watchDirs: [
|
|
507
|
+
path.resolve(ctx.client.buildDir, ctx["sdk-react"].outputOptions.buildName),
|
|
508
|
+
],
|
|
502
509
|
},
|
|
503
510
|
});
|
|
504
511
|
const compiler = await createCompiler(validated.config);
|
|
505
|
-
await compiler.build();
|
|
512
|
+
const buildResults = await compiler.build();
|
|
513
|
+
if (devMode) {
|
|
514
|
+
// Handle process exit to clean up resources
|
|
515
|
+
const cleanUp = async () => {
|
|
516
|
+
await compiler.destroy();
|
|
517
|
+
process.exit(0);
|
|
518
|
+
};
|
|
519
|
+
process.on("SIGINT", cleanUp);
|
|
520
|
+
process.on("SIGTERM", cleanUp);
|
|
521
|
+
}
|
|
522
|
+
else {
|
|
523
|
+
if (buildResults.hasError) {
|
|
524
|
+
console.error("Stencil build error:", buildResults.diagnostics);
|
|
525
|
+
throw new Error("Stencil build error");
|
|
526
|
+
}
|
|
527
|
+
else {
|
|
528
|
+
await handleStencilBuildOutput(ctx);
|
|
529
|
+
}
|
|
530
|
+
await compiler.destroy();
|
|
531
|
+
}
|
|
532
|
+
process.chdir(ctx.client.rootDir);
|
|
533
|
+
}
|
|
534
|
+
async function handleStencilBuildOutput(ctx) {
|
|
535
|
+
var _a;
|
|
506
536
|
const entryFilePath = path.resolve(ctx.client.stencilBuild, "embeddable-wrapper.esm.js");
|
|
507
537
|
let fileName = "embeddable-wrapper.esm.js";
|
|
508
|
-
if (!((
|
|
538
|
+
if (!((_a = ctx.dev) === null || _a === void 0 ? void 0 : _a.watch)) {
|
|
509
539
|
const entryFileContent = await fs.readFile(entryFilePath, "utf8");
|
|
510
540
|
const fileHash = getContentHash(entryFileContent);
|
|
511
541
|
fileName = `embeddable-wrapper.esm-${fileHash}.js`;
|
|
@@ -513,8 +543,6 @@ async function runStencil(ctx) {
|
|
|
513
543
|
await addComponentTagName(entryFilePath, ctx.client.bundleHash);
|
|
514
544
|
}
|
|
515
545
|
await fs.rename(entryFilePath, path.resolve(ctx.client.stencilBuild, fileName));
|
|
516
|
-
await compiler.destroy();
|
|
517
|
-
process.chdir(ctx.client.rootDir);
|
|
518
546
|
}
|
|
519
547
|
async function generateSourceMap(ctx, pluginName) {
|
|
520
548
|
const componentBuildDir = path.resolve(ctx.client.buildDir, ctx[pluginName].outputOptions.buildName);
|
|
@@ -21507,14 +21535,21 @@ const addToGitingore = async () => {
|
|
|
21507
21535
|
// ignore
|
|
21508
21536
|
}
|
|
21509
21537
|
};
|
|
21538
|
+
const chokidarWatchOptions = {
|
|
21539
|
+
ignoreInitial: true,
|
|
21540
|
+
usePolling: false, // Ensure polling is disabled
|
|
21541
|
+
awaitWriteFinish: {
|
|
21542
|
+
stabilityThreshold: 200,
|
|
21543
|
+
pollInterval: 100,
|
|
21544
|
+
},
|
|
21545
|
+
};
|
|
21510
21546
|
var dev = async () => {
|
|
21511
21547
|
var _a, _b;
|
|
21512
21548
|
checkNodeVersion();
|
|
21513
21549
|
addToGitingore();
|
|
21514
|
-
const http = require("http");
|
|
21515
21550
|
ora = (await oraP).default;
|
|
21516
21551
|
process.on("warning", (e) => console.warn(e.stack));
|
|
21517
|
-
const logger = createNodeLogger(
|
|
21552
|
+
const logger = createNodeLogger();
|
|
21518
21553
|
const sys = createNodeSys({ process });
|
|
21519
21554
|
const defaultConfig = await provideConfig();
|
|
21520
21555
|
const buildDir = path$1.resolve(defaultConfig.client.rootDir, BUILD_DEV_DIR);
|
|
@@ -21645,9 +21680,7 @@ const onBundleBuildEnd = async (ctx) => {
|
|
|
21645
21680
|
}
|
|
21646
21681
|
};
|
|
21647
21682
|
const dataModelAndSecurityContextWatcher = (ctx) => {
|
|
21648
|
-
const fsWatcher = chokidar.watch([path$1.resolve(ctx.client.modelsSrc, "**/*.{cube,sc}.{yaml,yml,js}")],
|
|
21649
|
-
ignoreInitial: true,
|
|
21650
|
-
});
|
|
21683
|
+
const fsWatcher = chokidar.watch([path$1.resolve(ctx.client.modelsSrc, "**/*.{cube,sc}.{yaml,yml,js}")], chokidarWatchOptions);
|
|
21651
21684
|
fsWatcher.on("all", async () => {
|
|
21652
21685
|
await sendDataModelsAndSecurityContextsChanges(ctx);
|
|
21653
21686
|
});
|
|
@@ -21657,9 +21690,7 @@ const customSelfServeWatcher = (ctx) => {
|
|
|
21657
21690
|
const fsWatcher = chokidar.watch([
|
|
21658
21691
|
path$1.resolve(ctx.client.selfServeCustomizationDir, "style.css"),
|
|
21659
21692
|
path$1.resolve(ctx.client.selfServeCustomizationDir, "*.svg"),
|
|
21660
|
-
],
|
|
21661
|
-
ignoreInitial: true,
|
|
21662
|
-
});
|
|
21693
|
+
], chokidarWatchOptions);
|
|
21663
21694
|
fsWatcher.on("all", async () => {
|
|
21664
21695
|
sendMessage("customSelfServeUpdateSuccess");
|
|
21665
21696
|
});
|
|
@@ -21787,7 +21818,7 @@ var defineConfig = ({ plugins, pushBaseUrl, audienceUrl, authDomain, authClientI
|
|
|
21787
21818
|
};
|
|
21788
21819
|
|
|
21789
21820
|
var name = "@embeddable.com/sdk-core";
|
|
21790
|
-
var version = "3.
|
|
21821
|
+
var version = "3.9.0";
|
|
21791
21822
|
var description = "Core Embeddable SDK module responsible for web-components bundling and publishing.";
|
|
21792
21823
|
var keywords = [
|
|
21793
21824
|
"embeddable",
|
|
@@ -21828,7 +21859,7 @@ var dependencies = {
|
|
|
21828
21859
|
"@embeddable.com/sdk-utils": "*",
|
|
21829
21860
|
"@inquirer/prompts": "^7.0.0",
|
|
21830
21861
|
"@stencil/core": "^4.22.0",
|
|
21831
|
-
"@swc-node/register": "^1.9
|
|
21862
|
+
"@swc-node/register": "^1.10.9",
|
|
21832
21863
|
archiver: "^5.3.1",
|
|
21833
21864
|
axios: "^1.7.2",
|
|
21834
21865
|
chokidar: "^3.6.0",
|