@embeddable.com/sdk-react 3.0.2 → 3.1.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
@@ -6,8 +6,6 @@ import * as vite from 'vite';
6
6
  import viteReactPlugin from '@vitejs/plugin-react';
7
7
  import * as fs from 'node:fs/promises';
8
8
  import { readdir, lstat, rm } from 'node:fs/promises';
9
- import * as url from 'node:url';
10
- import { generate as generate$1 } from 'astring';
11
9
  import 'node:child_process';
12
10
  import { z } from 'zod';
13
11
  import { parse } from '@babel/parser';
@@ -26,13 +24,8 @@ var createContext = (pluginRoot, coreCtx) => {
26
24
  };
27
25
  };
28
26
 
29
- const loadComponentMeta = async (moduleId, ast) => {
30
- const tempFilePath = moduleId
31
- .replace(".emb.", ".emb-temp.")
32
- .replace(/\.ts$/, ".js");
33
- await fs.writeFile(tempFilePath, generate$1(ast));
34
- const module = await import(url.pathToFileURL(tempFilePath).href + `?${Date.now()}`);
35
- await fs.rm(tempFilePath);
27
+ const loadComponentMeta = async ({ moduleId, ast, }) => {
28
+ const module = await import(moduleId);
36
29
  return module.meta;
37
30
  };
38
31
 
@@ -48,7 +41,10 @@ var extractComponentsConfigPlugin = ({ globalKey, outputDir, fileName, component
48
41
  var _a;
49
42
  if (componentFileRegex.test(moduleInfo.id) &&
50
43
  ((_a = moduleInfo.code) === null || _a === void 0 ? void 0 : _a.includes(searchEntry))) {
51
- const meta = await loadComponentMeta(moduleInfo.id, moduleInfo.ast);
44
+ const meta = await loadComponentMeta({
45
+ moduleId: moduleInfo.id,
46
+ ast: moduleInfo.ast,
47
+ });
52
48
  const configJSON = JSON.stringify(meta, (_key, value) => typeof value === "object" &&
53
49
  value !== null &&
54
50
  "__embeddableType" in value
@@ -848,7 +844,10 @@ var validateComponentMetaPlugin = (componentFileRegex) => {
848
844
  ? getModuleType(moduleInfo)
849
845
  : null;
850
846
  if (moduleType) {
851
- const meta = await loadComponentMeta(moduleInfo.id, moduleInfo.ast);
847
+ const meta = await loadComponentMeta({
848
+ moduleId: moduleInfo.id,
849
+ ast: moduleInfo.ast,
850
+ });
852
851
  metaConfigs.push({
853
852
  moduleId: moduleInfo.id,
854
853
  meta,
@@ -1129,7 +1128,9 @@ var build = async (ctx) => {
1129
1128
  return await generate(ctx);
1130
1129
  };
1131
1130
 
1132
- var cleanup = async (ctx) => await rm(resolve(ctx.client.rootDir, ctx["sdk-react"].outputOptions.componentsEntryPointFilename));
1131
+ var cleanup = async (ctx) => {
1132
+ await rm(resolve(ctx.client.rootDir, ctx["sdk-react"].outputOptions.componentsEntryPointFilename));
1133
+ };
1133
1134
 
1134
1135
  var index = () => {
1135
1136
  return {