@embeddable.com/sdk-react 4.0.0-next.2 → 4.0.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/dynamicImportHandler.js +14 -0
- package/lib/generate.d.ts +29 -0
- package/lib/generate.test.d.ts +1 -0
- package/lib/index.esm.js +37 -8
- package/lib/index.esm.js.map +1 -1
- package/lib/index.js +1215 -0
- package/lib/index.js.map +1 -0
- package/lib/plugin.d.ts +21 -0
- package/lib/proxyHandler.d.ts +4 -0
- package/lib/utils/modules.d.ts +13 -0
- package/lib/validate/errorFormatter.d.ts +3 -0
- package/package.json +3 -3
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
const { fileURLToPath, pathToFileURL } = require("url");
|
|
2
|
+
|
|
3
|
+
async function loadModule(modulePath) {
|
|
4
|
+
try {
|
|
5
|
+
const module = await import(pathToFileURL(modulePath).href);
|
|
6
|
+
process.stdout.write(JSON.stringify(module.meta));
|
|
7
|
+
} catch (error) {
|
|
8
|
+
console.error(`Failed to load module: ${error.message}`);
|
|
9
|
+
process.exit(1);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const modulePath = fileURLToPath(process.argv[2]);
|
|
14
|
+
loadModule(modulePath);
|
package/lib/generate.d.ts
CHANGED
|
@@ -1,5 +1,34 @@
|
|
|
1
1
|
import * as vite from "vite";
|
|
2
|
+
import { WatcherOptions } from "rollup";
|
|
2
3
|
import { ResolvedEmbeddableConfig } from "@embeddable.com/sdk-core";
|
|
4
|
+
import { LogLevel } from "vite";
|
|
3
5
|
export declare const EMB_FILE_REGEX: RegExp;
|
|
4
6
|
declare const _default: (ctx: ResolvedEmbeddableConfig) => Promise<vite.Rollup.RollupOutput | vite.Rollup.RollupOutput[] | vite.Rollup.RollupWatcher>;
|
|
5
7
|
export default _default;
|
|
8
|
+
export declare function getViteConfig(ctx: ResolvedEmbeddableConfig, watch: WatcherOptions | null, plugins: any[]): {
|
|
9
|
+
logLevel: LogLevel;
|
|
10
|
+
resolve: {
|
|
11
|
+
alias?: Record<string, string>;
|
|
12
|
+
extensions: string[];
|
|
13
|
+
};
|
|
14
|
+
plugins: any[];
|
|
15
|
+
build: {
|
|
16
|
+
sourcemap: boolean | "inline";
|
|
17
|
+
watch: {
|
|
18
|
+
include: string[];
|
|
19
|
+
exclude: string[];
|
|
20
|
+
} | undefined;
|
|
21
|
+
minify: boolean;
|
|
22
|
+
rollupOptions: vite.Rollup.RollupOptions;
|
|
23
|
+
lib: {
|
|
24
|
+
entry: string;
|
|
25
|
+
formats: vite.LibraryFormats[];
|
|
26
|
+
fileName: string;
|
|
27
|
+
};
|
|
28
|
+
outDir: string;
|
|
29
|
+
};
|
|
30
|
+
define: {
|
|
31
|
+
"process.env.NODE_ENV": string;
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
export declare function runViteBuild(ctx: ResolvedEmbeddableConfig, watch?: WatcherOptions | null): Promise<vite.Rollup.RollupOutput | vite.Rollup.RollupOutput[] | vite.Rollup.RollupWatcher>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/lib/index.esm.js
CHANGED
|
@@ -1333,7 +1333,7 @@ function getViteConfig(ctx, watch, plugins) {
|
|
|
1333
1333
|
},
|
|
1334
1334
|
plugins,
|
|
1335
1335
|
build: {
|
|
1336
|
-
sourcemap: true,
|
|
1336
|
+
sourcemap: watch ? "inline" : true, // Inline sourcemaps are faster in dev
|
|
1337
1337
|
watch: watch
|
|
1338
1338
|
? {
|
|
1339
1339
|
include: [ctx.client.srcDir + "/**"],
|
|
@@ -1344,6 +1344,7 @@ function getViteConfig(ctx, watch, plugins) {
|
|
|
1344
1344
|
rollupOptions: watch
|
|
1345
1345
|
? {
|
|
1346
1346
|
cache: true,
|
|
1347
|
+
treeshake: false, // Faster builds in dev
|
|
1347
1348
|
...ctx.client.rollupOptions,
|
|
1348
1349
|
output: {
|
|
1349
1350
|
sourcemapPathTransform: (relativeSourcePath, sourcemapPath) => {
|
|
@@ -1375,38 +1376,66 @@ async function calculateBundleHash(ctx) {
|
|
|
1375
1376
|
ctx.client.bundleHash = getContentHash(contentString);
|
|
1376
1377
|
}
|
|
1377
1378
|
async function runViteBuild(ctx, watch = null) {
|
|
1379
|
+
// In watch mode (development), combine both builds into one to avoid duplication
|
|
1380
|
+
if (watch) {
|
|
1381
|
+
const { externalComponents, externalEditors } = await findExternalComponents(ctx);
|
|
1382
|
+
return await vite.build(getViteConfig(ctx, watch, [
|
|
1383
|
+
viteReactPlugin(),
|
|
1384
|
+
validateComponentMetaPlugin(EMB_FILE_REGEX),
|
|
1385
|
+
extractComponentsConfigPlugin({
|
|
1386
|
+
isDev: true,
|
|
1387
|
+
globalKey: "componentsMeta",
|
|
1388
|
+
fileName: "embeddable-components-meta.js",
|
|
1389
|
+
outputDir: ctx.client.buildDir,
|
|
1390
|
+
componentFileRegex: EMB_FILE_REGEX,
|
|
1391
|
+
searchEntry: "defineComponent",
|
|
1392
|
+
useBundleHash: false,
|
|
1393
|
+
ctx,
|
|
1394
|
+
externalComponents: externalComponents,
|
|
1395
|
+
}),
|
|
1396
|
+
extractComponentsConfigPlugin({
|
|
1397
|
+
isDev: true,
|
|
1398
|
+
globalKey: "editorsMeta",
|
|
1399
|
+
fileName: "embeddable-editors-meta.js",
|
|
1400
|
+
outputDir: ctx.client.buildDir,
|
|
1401
|
+
componentFileRegex: EMB_FILE_REGEX,
|
|
1402
|
+
searchEntry: "defineEditor",
|
|
1403
|
+
useBundleHash: false,
|
|
1404
|
+
ctx,
|
|
1405
|
+
externalComponents: externalEditors,
|
|
1406
|
+
}),
|
|
1407
|
+
]));
|
|
1408
|
+
}
|
|
1378
1409
|
// Step 1: Initial build without extractComponentsConfigPlugin
|
|
1379
1410
|
await vite.build(getViteConfig(ctx, watch, [
|
|
1380
1411
|
viteReactPlugin(),
|
|
1381
1412
|
validateComponentMetaPlugin(EMB_FILE_REGEX),
|
|
1382
1413
|
]));
|
|
1383
1414
|
// Step 2: Calculate bundleHash in production mode
|
|
1384
|
-
|
|
1385
|
-
await calculateBundleHash(ctx);
|
|
1386
|
-
}
|
|
1415
|
+
await calculateBundleHash(ctx);
|
|
1387
1416
|
const { externalComponents, externalEditors } = await findExternalComponents(ctx);
|
|
1388
1417
|
// Step 3: Final build with extractComponentsConfigPlugin
|
|
1389
1418
|
return await vite.build(getViteConfig(ctx, watch, [
|
|
1390
1419
|
viteReactPlugin(),
|
|
1391
1420
|
extractComponentsConfigPlugin({
|
|
1392
|
-
isDev:
|
|
1421
|
+
isDev: false,
|
|
1393
1422
|
globalKey: "componentsMeta",
|
|
1394
1423
|
fileName: "embeddable-components-meta.js",
|
|
1395
1424
|
outputDir: ctx.client.buildDir,
|
|
1396
1425
|
componentFileRegex: EMB_FILE_REGEX,
|
|
1397
1426
|
searchEntry: "defineComponent",
|
|
1398
|
-
useBundleHash:
|
|
1427
|
+
useBundleHash: true,
|
|
1399
1428
|
ctx,
|
|
1400
1429
|
externalComponents: externalComponents,
|
|
1401
1430
|
}),
|
|
1402
1431
|
extractComponentsConfigPlugin({
|
|
1403
|
-
isDev:
|
|
1432
|
+
isDev: false,
|
|
1404
1433
|
globalKey: "editorsMeta",
|
|
1405
1434
|
fileName: "embeddable-editors-meta.js",
|
|
1406
1435
|
outputDir: ctx.client.buildDir,
|
|
1407
1436
|
componentFileRegex: EMB_FILE_REGEX,
|
|
1408
1437
|
searchEntry: "defineEditor",
|
|
1409
|
-
useBundleHash:
|
|
1438
|
+
useBundleHash: true,
|
|
1410
1439
|
ctx,
|
|
1411
1440
|
externalComponents: externalEditors,
|
|
1412
1441
|
}),
|