@swell/cli 2.9.35 → 2.9.36
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.
|
@@ -18,6 +18,11 @@ function checkTargets(config) {
|
|
|
18
18
|
throw new Error(TARGETS_SHAPE);
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
|
+
function checkUi(config) {
|
|
22
|
+
if (config.ui !== undefined && typeof config.ui !== 'boolean') {
|
|
23
|
+
throw new Error('ui must be true or false');
|
|
24
|
+
}
|
|
25
|
+
}
|
|
21
26
|
/**
|
|
22
27
|
* The values to push for a component's static config
|
|
23
28
|
* @param {string} name component name
|
|
@@ -29,6 +34,7 @@ function checkTargets(config) {
|
|
|
29
34
|
export function resolveComponentValues(name, config, extensions, siblings) {
|
|
30
35
|
const values = { ...config };
|
|
31
36
|
checkTargets(values);
|
|
37
|
+
checkUi(values);
|
|
32
38
|
const { extension } = values;
|
|
33
39
|
// A string extension is the legacy swell.app contract
|
|
34
40
|
if (extension === undefined || typeof extension === 'string') {
|
package/dist/lib/apps/paths.js
CHANGED
|
@@ -52,6 +52,10 @@ function globOptions(appPath, options) {
|
|
|
52
52
|
'**/bun.lockb',
|
|
53
53
|
'**/bun.lock',
|
|
54
54
|
'**/.wrangler/**',
|
|
55
|
+
// OS folder metadata, untracked yet rarely in an app's .gitignore
|
|
56
|
+
'**/.DS_Store',
|
|
57
|
+
'**/Thumbs.db',
|
|
58
|
+
'**/desktop.ini',
|
|
55
59
|
...CREDENTIAL_FILE_GLOBS,
|
|
56
60
|
...(options?.ignore || []),
|
|
57
61
|
],
|
package/dist/lib/bundle.js
CHANGED
|
@@ -456,6 +456,27 @@ const preactJsxPlugin = {
|
|
|
456
456
|
});
|
|
457
457
|
},
|
|
458
458
|
};
|
|
459
|
+
// The platform loads the Swell UI kit into a component frame that sets
|
|
460
|
+
// config.ui = true, so its code must never be bundled: a value import of it
|
|
461
|
+
// resolves to an empty module and warns
|
|
462
|
+
const SWELL_UI_KIT = 'swell-ui-kit';
|
|
463
|
+
const swellUiKitPlugin = {
|
|
464
|
+
name: SWELL_UI_KIT,
|
|
465
|
+
setup(build) {
|
|
466
|
+
build.onResolve({ filter: /^@swell\/swell-ui(?:\/|$)/ }, (args) => ({
|
|
467
|
+
namespace: SWELL_UI_KIT,
|
|
468
|
+
path: args.path,
|
|
469
|
+
warnings: [
|
|
470
|
+
{
|
|
471
|
+
text: `"${args.path}" is left out of the bundle: set config.ui = true in the component and the platform loads the Swell UI kit; import the kit only as types`,
|
|
472
|
+
},
|
|
473
|
+
],
|
|
474
|
+
}));
|
|
475
|
+
build.onLoad({ filter: /.*/, namespace: SWELL_UI_KIT }, () => ({
|
|
476
|
+
contents: '',
|
|
477
|
+
}));
|
|
478
|
+
},
|
|
479
|
+
};
|
|
459
480
|
/**
|
|
460
481
|
* Builds a component into the module the component frame loads: generated
|
|
461
482
|
* mount, update and unmount functions render its default export with Preact.
|
|
@@ -466,7 +487,7 @@ const preactJsxPlugin = {
|
|
|
466
487
|
export async function bundleComponentModule(filePath, appRoot) {
|
|
467
488
|
const entry = `./${filePath.split(path.sep).join('/')}`;
|
|
468
489
|
try {
|
|
469
|
-
const { metafile, outputFiles } = await esbuild.build({
|
|
490
|
+
const { metafile, outputFiles, warnings } = await esbuild.build({
|
|
470
491
|
absWorkingDir: appRoot,
|
|
471
492
|
alias: COMPONENT_ALIASES,
|
|
472
493
|
bundle: true,
|
|
@@ -477,7 +498,7 @@ export async function bundleComponentModule(filePath, appRoot) {
|
|
|
477
498
|
metafile: true,
|
|
478
499
|
minify: true,
|
|
479
500
|
platform: 'browser',
|
|
480
|
-
plugins: [preactJsxPlugin],
|
|
501
|
+
plugins: [swellUiKitPlugin, preactJsxPlugin],
|
|
481
502
|
stdin: {
|
|
482
503
|
contents: [
|
|
483
504
|
"import { h, render } from 'preact';",
|
|
@@ -495,7 +516,13 @@ export async function bundleComponentModule(filePath, appRoot) {
|
|
|
495
516
|
});
|
|
496
517
|
const inputs = Object.keys(metafile.inputs).filter((input) => !input.includes('node_modules/') &&
|
|
497
518
|
!input.startsWith('<') &&
|
|
519
|
+
!input.startsWith(`${SWELL_UI_KIT}:`) &&
|
|
498
520
|
input !== COMPONENT_ENTRY);
|
|
521
|
+
for (const warning of warnings) {
|
|
522
|
+
if (warning.pluginName === SWELL_UI_KIT) {
|
|
523
|
+
console.warn(`Warning: component "${filePath}": ${warning.text}`);
|
|
524
|
+
}
|
|
525
|
+
}
|
|
499
526
|
return { code: outputFiles[0].text, inputs };
|
|
500
527
|
}
|
|
501
528
|
catch (error) {
|
package/oclif.manifest.json
CHANGED