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