@embeddable.com/sdk-react 3.2.0 → 3.2.2

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.
@@ -1,9 +1,10 @@
1
1
  import { ModuleInfo } from "rollup";
2
- declare const _default: ({ globalKey, outputDir, fileName, componentFileRegex, searchEntry, }: {
2
+ declare const _default: ({ globalKey, outputDir, fileName, componentFileRegex, isDev, searchEntry, }: {
3
3
  globalKey: string;
4
4
  outputDir: string;
5
5
  fileName: string;
6
6
  componentFileRegex: RegExp;
7
+ isDev?: boolean;
7
8
  searchEntry?: string;
8
9
  }) => {
9
10
  name: string;
package/lib/index.esm.js CHANGED
@@ -377,7 +377,7 @@ const getContentHash = (contentString) => {
377
377
  * TODO: for some reason code from @embeddable.com/extract-components-config
378
378
  * is being cached. Thus we use this code duplication in place. Please investigate and fix.
379
379
  */
380
- var extractComponentsConfigPlugin = ({ globalKey, outputDir, fileName, componentFileRegex, searchEntry = "", }) => {
380
+ var extractComponentsConfigPlugin = ({ globalKey, outputDir, fileName, componentFileRegex, isDev = false, searchEntry = "", }) => {
381
381
  let configs = [];
382
382
  return {
383
383
  name: "extract-components-config",
@@ -404,10 +404,13 @@ globalThis.__EMBEDDABLE__.${globalKey} = globalThis.__EMBEDDABLE__.${globalKey}
404
404
  // sort to make sure the hash is consistent
405
405
  configs.sort((a, b) => a.localeCompare(b));
406
406
  const contentString = configs.filter(Boolean).join(",\n");
407
- const fileHash = getContentHash(contentString);
408
- const fileHashExtention = `-${fileHash}.js`;
409
- const fileNameHashed = `${fileName.replace(".js", fileHashExtention)}`;
410
- await fs.writeFile(`${outputDir}/${fileNameHashed}`, template.replace("__PLACEHOLDER__", contentString));
407
+ let newFileName = fileName;
408
+ if (!isDev) {
409
+ const fileHash = getContentHash(contentString);
410
+ const fileHashExtention = `-${fileHash}.js`;
411
+ newFileName = `${fileName.replace(".js", fileHashExtention)}`;
412
+ }
413
+ await fs.writeFile(`${outputDir}/${newFileName}`, template.replace("__PLACEHOLDER__", contentString));
411
414
  configs = [];
412
415
  },
413
416
  };
@@ -1077,6 +1080,7 @@ async function runViteBuild(ctx, watch = null) {
1077
1080
  plugins: [
1078
1081
  viteReactPlugin(),
1079
1082
  extractComponentsConfigPlugin({
1083
+ isDev: !!watch,
1080
1084
  globalKey: "componentsMeta",
1081
1085
  fileName: "embeddable-components-meta.js",
1082
1086
  outputDir: ctx.client.buildDir,
@@ -1084,6 +1088,7 @@ async function runViteBuild(ctx, watch = null) {
1084
1088
  searchEntry: "defineComponent",
1085
1089
  }),
1086
1090
  extractComponentsConfigPlugin({
1091
+ isDev: !!watch,
1087
1092
  globalKey: "editorsMeta",
1088
1093
  fileName: "embeddable-editors-meta.js",
1089
1094
  outputDir: ctx.client.buildDir,
@@ -1096,6 +1101,16 @@ async function runViteBuild(ctx, watch = null) {
1096
1101
  sourcemap: true,
1097
1102
  watch,
1098
1103
  minify: !watch,
1104
+ rollupOptions: watch
1105
+ ? {
1106
+ output: {
1107
+ sourcemapPathTransform: (relativeSourcePath, sourcemapPath) => {
1108
+ // will replace relative paths with absolute paths
1109
+ return path.resolve(path.dirname(sourcemapPath), relativeSourcePath);
1110
+ },
1111
+ },
1112
+ }
1113
+ : undefined,
1099
1114
  lib: {
1100
1115
  entry: path.resolve(ctx.client.rootDir, ctx["sdk-react"].outputOptions.componentsEntryPointFilename),
1101
1116
  formats: ["es"],