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