@embeddable.com/sdk-react 3.2.0 → 3.2.1
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/extractComponentsConfigPlugin.d.ts +2 -1
- package/lib/index.esm.js +10 -5
- package/lib/index.esm.js.map +1 -1
- package/lib/index.js +10 -5
- package/lib/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -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
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
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,
|