@embeddable.com/sdk-react 3.11.7-next.2 → 4.0.0-next.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/generate.d.ts +0 -29
- package/lib/index.esm.js +12 -41
- package/lib/index.esm.js.map +1 -1
- package/package.json +3 -3
- package/lib/generate.test.d.ts +0 -1
package/lib/generate.d.ts
CHANGED
|
@@ -1,34 +1,5 @@
|
|
|
1
1
|
import * as vite from "vite";
|
|
2
|
-
import { WatcherOptions } from "rollup";
|
|
3
2
|
import { ResolvedEmbeddableConfig } from "@embeddable.com/sdk-core";
|
|
4
|
-
import { LogLevel } from "vite";
|
|
5
3
|
export declare const EMB_FILE_REGEX: RegExp;
|
|
6
4
|
declare const _default: (ctx: ResolvedEmbeddableConfig) => Promise<vite.Rollup.RollupOutput | vite.Rollup.RollupOutput[] | vite.Rollup.RollupWatcher>;
|
|
7
5
|
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>;
|
package/lib/index.esm.js
CHANGED
|
@@ -449,12 +449,12 @@ const loadJson = async (filePath) => {
|
|
|
449
449
|
|
|
450
450
|
const getComponentLibraryConfig = (componentLibrary) => {
|
|
451
451
|
let libraryName = componentLibrary;
|
|
452
|
-
|
|
452
|
+
const include = [];
|
|
453
453
|
const exclude = [];
|
|
454
454
|
if (typeof componentLibrary === "object" && componentLibrary !== null) {
|
|
455
455
|
libraryName = componentLibrary.name;
|
|
456
456
|
if (componentLibrary.include) {
|
|
457
|
-
include
|
|
457
|
+
include.push(...componentLibrary.include);
|
|
458
458
|
}
|
|
459
459
|
if (componentLibrary.exclude) {
|
|
460
460
|
exclude.push(...componentLibrary.exclude);
|
|
@@ -468,7 +468,7 @@ const getComponentLibraryMeta = async (ctx, componentLibrary) => {
|
|
|
468
468
|
const libraryMeta = (await loadJson(getLibraryPath(ctx, libraryName, EXTERNAL_LIBRARY_META_FILE_NAME)));
|
|
469
469
|
const filterItems = (items) => {
|
|
470
470
|
let result = items;
|
|
471
|
-
if (include) {
|
|
471
|
+
if (include.length > 0) {
|
|
472
472
|
result = result.filter((item) => include.includes(item));
|
|
473
473
|
}
|
|
474
474
|
return result.filter((item) => !exclude.includes(item));
|
|
@@ -1333,7 +1333,7 @@ function getViteConfig(ctx, watch, plugins) {
|
|
|
1333
1333
|
},
|
|
1334
1334
|
plugins,
|
|
1335
1335
|
build: {
|
|
1336
|
-
sourcemap:
|
|
1336
|
+
sourcemap: true,
|
|
1337
1337
|
watch: watch
|
|
1338
1338
|
? {
|
|
1339
1339
|
include: [ctx.client.srcDir + "/**"],
|
|
@@ -1344,7 +1344,6 @@ function getViteConfig(ctx, watch, plugins) {
|
|
|
1344
1344
|
rollupOptions: watch
|
|
1345
1345
|
? {
|
|
1346
1346
|
cache: true,
|
|
1347
|
-
treeshake: false, // Faster builds in dev
|
|
1348
1347
|
...ctx.client.rollupOptions,
|
|
1349
1348
|
output: {
|
|
1350
1349
|
sourcemapPathTransform: (relativeSourcePath, sourcemapPath) => {
|
|
@@ -1376,66 +1375,38 @@ async function calculateBundleHash(ctx) {
|
|
|
1376
1375
|
ctx.client.bundleHash = getContentHash(contentString);
|
|
1377
1376
|
}
|
|
1378
1377
|
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
|
-
}
|
|
1409
1378
|
// Step 1: Initial build without extractComponentsConfigPlugin
|
|
1410
1379
|
await vite.build(getViteConfig(ctx, watch, [
|
|
1411
1380
|
viteReactPlugin(),
|
|
1412
1381
|
validateComponentMetaPlugin(EMB_FILE_REGEX),
|
|
1413
1382
|
]));
|
|
1414
1383
|
// Step 2: Calculate bundleHash in production mode
|
|
1415
|
-
|
|
1384
|
+
if (!watch) {
|
|
1385
|
+
await calculateBundleHash(ctx);
|
|
1386
|
+
}
|
|
1416
1387
|
const { externalComponents, externalEditors } = await findExternalComponents(ctx);
|
|
1417
1388
|
// Step 3: Final build with extractComponentsConfigPlugin
|
|
1418
1389
|
return await vite.build(getViteConfig(ctx, watch, [
|
|
1419
1390
|
viteReactPlugin(),
|
|
1420
1391
|
extractComponentsConfigPlugin({
|
|
1421
|
-
isDev:
|
|
1392
|
+
isDev: !!watch,
|
|
1422
1393
|
globalKey: "componentsMeta",
|
|
1423
1394
|
fileName: "embeddable-components-meta.js",
|
|
1424
1395
|
outputDir: ctx.client.buildDir,
|
|
1425
1396
|
componentFileRegex: EMB_FILE_REGEX,
|
|
1426
1397
|
searchEntry: "defineComponent",
|
|
1427
|
-
useBundleHash:
|
|
1398
|
+
useBundleHash: !watch,
|
|
1428
1399
|
ctx,
|
|
1429
1400
|
externalComponents: externalComponents,
|
|
1430
1401
|
}),
|
|
1431
1402
|
extractComponentsConfigPlugin({
|
|
1432
|
-
isDev:
|
|
1403
|
+
isDev: !!watch,
|
|
1433
1404
|
globalKey: "editorsMeta",
|
|
1434
1405
|
fileName: "embeddable-editors-meta.js",
|
|
1435
1406
|
outputDir: ctx.client.buildDir,
|
|
1436
1407
|
componentFileRegex: EMB_FILE_REGEX,
|
|
1437
1408
|
searchEntry: "defineEditor",
|
|
1438
|
-
useBundleHash:
|
|
1409
|
+
useBundleHash: !watch,
|
|
1439
1410
|
ctx,
|
|
1440
1411
|
externalComponents: externalEditors,
|
|
1441
1412
|
}),
|
|
@@ -1500,7 +1471,7 @@ const findExternalComponents = async (ctx) => {
|
|
|
1500
1471
|
const externalComponents = [];
|
|
1501
1472
|
const externalEditors = [];
|
|
1502
1473
|
for (const componentLibrary of componentLibraries) {
|
|
1503
|
-
const { libraryName
|
|
1474
|
+
const { libraryName} = getComponentLibraryConfig(componentLibrary);
|
|
1504
1475
|
try {
|
|
1505
1476
|
const libMeta = await getComponentLibraryMeta(ctx, componentLibrary);
|
|
1506
1477
|
if (libMeta.plugin !== "react") {
|