@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.js
CHANGED
|
@@ -21,6 +21,7 @@ var path$1 = require('path');
|
|
|
21
21
|
var axios = require('axios');
|
|
22
22
|
var archiver = require('archiver');
|
|
23
23
|
var prompts = require('@inquirer/prompts');
|
|
24
|
+
var http = require('node:http');
|
|
24
25
|
var ws = require('ws');
|
|
25
26
|
var chokidar = require('chokidar');
|
|
26
27
|
var promises = require('fs/promises');
|
|
@@ -52,6 +53,7 @@ var YAML__namespace = /*#__PURE__*/_interopNamespaceDefault(YAML);
|
|
|
52
53
|
var url__namespace = /*#__PURE__*/_interopNamespaceDefault(url);
|
|
53
54
|
var path__namespace$1 = /*#__PURE__*/_interopNamespaceDefault(path$1);
|
|
54
55
|
var archiver__namespace = /*#__PURE__*/_interopNamespaceDefault(archiver);
|
|
56
|
+
var http__namespace = /*#__PURE__*/_interopNamespaceDefault(http);
|
|
55
57
|
var chokidar__namespace = /*#__PURE__*/_interopNamespaceDefault(chokidar);
|
|
56
58
|
|
|
57
59
|
var findFiles = async (initialSrcDir, regex) => {
|
|
@@ -504,8 +506,8 @@ async function addComponentTagName(filePath, bundleHash) {
|
|
|
504
506
|
]);
|
|
505
507
|
}
|
|
506
508
|
async function runStencil(ctx) {
|
|
507
|
-
var _a, _b
|
|
508
|
-
const logger = ((_a = ctx.dev) === null || _a === void 0 ? void 0 : _a.logger) || node.createNodeLogger(
|
|
509
|
+
var _a, _b;
|
|
510
|
+
const logger = ((_a = ctx.dev) === null || _a === void 0 ? void 0 : _a.logger) || node.createNodeLogger();
|
|
509
511
|
const sys = ((_b = ctx.dev) === null || _b === void 0 ? void 0 : _b.sys) || node.createNodeSys({ process });
|
|
510
512
|
const devMode = !!ctx.dev;
|
|
511
513
|
const isWindows = process.platform === "win32";
|
|
@@ -521,18 +523,47 @@ async function runStencil(ctx) {
|
|
|
521
523
|
tsconfig: path__namespace.resolve(ctx.client.buildDir, "tsconfig.json"),
|
|
522
524
|
namespace: "embeddable-wrapper",
|
|
523
525
|
srcDir: path__namespace.resolve(ctx.client.buildDir, "component"),
|
|
526
|
+
sourceMap: !devMode,
|
|
527
|
+
minifyJs: !devMode,
|
|
528
|
+
minifyCss: !devMode,
|
|
524
529
|
outputTargets: [
|
|
525
530
|
{
|
|
526
531
|
type: "dist",
|
|
527
532
|
},
|
|
528
533
|
],
|
|
534
|
+
watchDirs: [
|
|
535
|
+
path__namespace.resolve(ctx.client.buildDir, ctx["sdk-react"].outputOptions.buildName),
|
|
536
|
+
],
|
|
529
537
|
},
|
|
530
538
|
});
|
|
531
539
|
const compiler$1 = await compiler.createCompiler(validated.config);
|
|
532
|
-
await compiler$1.build();
|
|
540
|
+
const buildResults = await compiler$1.build();
|
|
541
|
+
if (devMode) {
|
|
542
|
+
// Handle process exit to clean up resources
|
|
543
|
+
const cleanUp = async () => {
|
|
544
|
+
await compiler$1.destroy();
|
|
545
|
+
process.exit(0);
|
|
546
|
+
};
|
|
547
|
+
process.on("SIGINT", cleanUp);
|
|
548
|
+
process.on("SIGTERM", cleanUp);
|
|
549
|
+
}
|
|
550
|
+
else {
|
|
551
|
+
if (buildResults.hasError) {
|
|
552
|
+
console.error("Stencil build error:", buildResults.diagnostics);
|
|
553
|
+
throw new Error("Stencil build error");
|
|
554
|
+
}
|
|
555
|
+
else {
|
|
556
|
+
await handleStencilBuildOutput(ctx);
|
|
557
|
+
}
|
|
558
|
+
await compiler$1.destroy();
|
|
559
|
+
}
|
|
560
|
+
process.chdir(ctx.client.rootDir);
|
|
561
|
+
}
|
|
562
|
+
async function handleStencilBuildOutput(ctx) {
|
|
563
|
+
var _a;
|
|
533
564
|
const entryFilePath = path__namespace.resolve(ctx.client.stencilBuild, "embeddable-wrapper.esm.js");
|
|
534
565
|
let fileName = "embeddable-wrapper.esm.js";
|
|
535
|
-
if (!((
|
|
566
|
+
if (!((_a = ctx.dev) === null || _a === void 0 ? void 0 : _a.watch)) {
|
|
536
567
|
const entryFileContent = await fs__namespace.readFile(entryFilePath, "utf8");
|
|
537
568
|
const fileHash = getContentHash(entryFileContent);
|
|
538
569
|
fileName = `embeddable-wrapper.esm-${fileHash}.js`;
|
|
@@ -540,8 +571,6 @@ async function runStencil(ctx) {
|
|
|
540
571
|
await addComponentTagName(entryFilePath, ctx.client.bundleHash);
|
|
541
572
|
}
|
|
542
573
|
await fs__namespace.rename(entryFilePath, path__namespace.resolve(ctx.client.stencilBuild, fileName));
|
|
543
|
-
await compiler$1.destroy();
|
|
544
|
-
process.chdir(ctx.client.rootDir);
|
|
545
574
|
}
|
|
546
575
|
async function generateSourceMap(ctx, pluginName) {
|
|
547
576
|
const componentBuildDir = path__namespace.resolve(ctx.client.buildDir, ctx[pluginName].outputOptions.buildName);
|
|
@@ -21534,14 +21563,21 @@ const addToGitingore = async () => {
|
|
|
21534
21563
|
// ignore
|
|
21535
21564
|
}
|
|
21536
21565
|
};
|
|
21566
|
+
const chokidarWatchOptions = {
|
|
21567
|
+
ignoreInitial: true,
|
|
21568
|
+
usePolling: false, // Ensure polling is disabled
|
|
21569
|
+
awaitWriteFinish: {
|
|
21570
|
+
stabilityThreshold: 200,
|
|
21571
|
+
pollInterval: 100,
|
|
21572
|
+
},
|
|
21573
|
+
};
|
|
21537
21574
|
var dev = async () => {
|
|
21538
21575
|
var _a, _b;
|
|
21539
21576
|
checkNodeVersion();
|
|
21540
21577
|
addToGitingore();
|
|
21541
|
-
const http = require("http");
|
|
21542
21578
|
ora = (await oraP).default;
|
|
21543
21579
|
process.on("warning", (e) => console.warn(e.stack));
|
|
21544
|
-
const logger = node.createNodeLogger(
|
|
21580
|
+
const logger = node.createNodeLogger();
|
|
21545
21581
|
const sys = node.createNodeSys({ process });
|
|
21546
21582
|
const defaultConfig = await provideConfig();
|
|
21547
21583
|
const buildDir = path__namespace$1.resolve(defaultConfig.client.rootDir, BUILD_DEV_DIR);
|
|
@@ -21574,7 +21610,7 @@ var dev = async () => {
|
|
|
21574
21610
|
process.exit(1);
|
|
21575
21611
|
}
|
|
21576
21612
|
workspacePreparation.succeed("Workspace is ready");
|
|
21577
|
-
const server =
|
|
21613
|
+
const server = http__namespace.createServer((request, res) => {
|
|
21578
21614
|
var _a, _b;
|
|
21579
21615
|
res.setHeader("Access-Control-Allow-Origin", "*");
|
|
21580
21616
|
res.setHeader("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, OPTIONS");
|
|
@@ -21672,9 +21708,7 @@ const onBundleBuildEnd = async (ctx) => {
|
|
|
21672
21708
|
}
|
|
21673
21709
|
};
|
|
21674
21710
|
const dataModelAndSecurityContextWatcher = (ctx) => {
|
|
21675
|
-
const fsWatcher = chokidar__namespace.watch([path__namespace$1.resolve(ctx.client.modelsSrc, "**/*.{cube,sc}.{yaml,yml,js}")],
|
|
21676
|
-
ignoreInitial: true,
|
|
21677
|
-
});
|
|
21711
|
+
const fsWatcher = chokidar__namespace.watch([path__namespace$1.resolve(ctx.client.modelsSrc, "**/*.{cube,sc}.{yaml,yml,js}")], chokidarWatchOptions);
|
|
21678
21712
|
fsWatcher.on("all", async () => {
|
|
21679
21713
|
await sendDataModelsAndSecurityContextsChanges(ctx);
|
|
21680
21714
|
});
|
|
@@ -21684,9 +21718,7 @@ const customSelfServeWatcher = (ctx) => {
|
|
|
21684
21718
|
const fsWatcher = chokidar__namespace.watch([
|
|
21685
21719
|
path__namespace$1.resolve(ctx.client.selfServeCustomizationDir, "style.css"),
|
|
21686
21720
|
path__namespace$1.resolve(ctx.client.selfServeCustomizationDir, "*.svg"),
|
|
21687
|
-
],
|
|
21688
|
-
ignoreInitial: true,
|
|
21689
|
-
});
|
|
21721
|
+
], chokidarWatchOptions);
|
|
21690
21722
|
fsWatcher.on("all", async () => {
|
|
21691
21723
|
sendMessage("customSelfServeUpdateSuccess");
|
|
21692
21724
|
});
|
|
@@ -21814,7 +21846,7 @@ var defineConfig = ({ plugins, pushBaseUrl, audienceUrl, authDomain, authClientI
|
|
|
21814
21846
|
};
|
|
21815
21847
|
|
|
21816
21848
|
var name = "@embeddable.com/sdk-core";
|
|
21817
|
-
var version = "3.
|
|
21849
|
+
var version = "3.9.0";
|
|
21818
21850
|
var description = "Core Embeddable SDK module responsible for web-components bundling and publishing.";
|
|
21819
21851
|
var keywords = [
|
|
21820
21852
|
"embeddable",
|
|
@@ -21855,7 +21887,7 @@ var dependencies = {
|
|
|
21855
21887
|
"@embeddable.com/sdk-utils": "*",
|
|
21856
21888
|
"@inquirer/prompts": "^7.0.0",
|
|
21857
21889
|
"@stencil/core": "^4.22.0",
|
|
21858
|
-
"@swc-node/register": "^1.9
|
|
21890
|
+
"@swc-node/register": "^1.10.9",
|
|
21859
21891
|
archiver: "^5.3.1",
|
|
21860
21892
|
axios: "^1.7.2",
|
|
21861
21893
|
chokidar: "^3.6.0",
|