@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
package/lib/index.js
CHANGED
|
@@ -403,7 +403,7 @@ const getContentHash = (contentString) => {
|
|
|
403
403
|
* TODO: for some reason code from @embeddable.com/extract-components-config
|
|
404
404
|
* is being cached. Thus we use this code duplication in place. Please investigate and fix.
|
|
405
405
|
*/
|
|
406
|
-
var extractComponentsConfigPlugin = ({ globalKey, outputDir, fileName, componentFileRegex, searchEntry = "", }) => {
|
|
406
|
+
var extractComponentsConfigPlugin = ({ globalKey, outputDir, fileName, componentFileRegex, isDev = false, searchEntry = "", }) => {
|
|
407
407
|
let configs = [];
|
|
408
408
|
return {
|
|
409
409
|
name: "extract-components-config",
|
|
@@ -430,10 +430,13 @@ globalThis.__EMBEDDABLE__.${globalKey} = globalThis.__EMBEDDABLE__.${globalKey}
|
|
|
430
430
|
// sort to make sure the hash is consistent
|
|
431
431
|
configs.sort((a, b) => a.localeCompare(b));
|
|
432
432
|
const contentString = configs.filter(Boolean).join(",\n");
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
433
|
+
let newFileName = fileName;
|
|
434
|
+
if (!isDev) {
|
|
435
|
+
const fileHash = getContentHash(contentString);
|
|
436
|
+
const fileHashExtention = `-${fileHash}.js`;
|
|
437
|
+
newFileName = `${fileName.replace(".js", fileHashExtention)}`;
|
|
438
|
+
}
|
|
439
|
+
await fs__namespace.writeFile(`${outputDir}/${newFileName}`, template.replace("__PLACEHOLDER__", contentString));
|
|
437
440
|
configs = [];
|
|
438
441
|
},
|
|
439
442
|
};
|
|
@@ -1103,6 +1106,7 @@ async function runViteBuild(ctx, watch = null) {
|
|
|
1103
1106
|
plugins: [
|
|
1104
1107
|
viteReactPlugin(),
|
|
1105
1108
|
extractComponentsConfigPlugin({
|
|
1109
|
+
isDev: !!watch,
|
|
1106
1110
|
globalKey: "componentsMeta",
|
|
1107
1111
|
fileName: "embeddable-components-meta.js",
|
|
1108
1112
|
outputDir: ctx.client.buildDir,
|
|
@@ -1110,6 +1114,7 @@ async function runViteBuild(ctx, watch = null) {
|
|
|
1110
1114
|
searchEntry: "defineComponent",
|
|
1111
1115
|
}),
|
|
1112
1116
|
extractComponentsConfigPlugin({
|
|
1117
|
+
isDev: !!watch,
|
|
1113
1118
|
globalKey: "editorsMeta",
|
|
1114
1119
|
fileName: "embeddable-editors-meta.js",
|
|
1115
1120
|
outputDir: ctx.client.buildDir,
|