piral-cli 0.14.0-pre.2983 → 0.14.0-pre.3074
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/api.js +23 -23
- package/lib/api.js.map +1 -1
- package/lib/apps/build-pilet.js +18 -16
- package/lib/apps/build-pilet.js.map +1 -1
- package/lib/apps/build-piral.js +35 -34
- package/lib/apps/build-piral.js.map +1 -1
- package/lib/apps/debug-pilet.js +28 -27
- package/lib/apps/debug-pilet.js.map +1 -1
- package/lib/apps/debug-piral.js +15 -14
- package/lib/apps/debug-piral.js.map +1 -1
- package/lib/apps/declaration-piral.js +5 -3
- package/lib/apps/declaration-piral.js.map +1 -1
- package/lib/apps/new-pilet.js +40 -39
- package/lib/apps/new-pilet.js.map +1 -1
- package/lib/apps/new-piral.js +21 -20
- package/lib/apps/new-piral.js.map +1 -1
- package/lib/apps/pack-pilet.js +6 -4
- package/lib/apps/pack-pilet.js.map +1 -1
- package/lib/apps/publish-pilet.js +48 -47
- package/lib/apps/publish-pilet.js.map +1 -1
- package/lib/apps/publish-piral.js +23 -22
- package/lib/apps/publish-piral.js.map +1 -1
- package/lib/apps/upgrade-pilet.js +34 -33
- package/lib/apps/upgrade-pilet.js.map +1 -1
- package/lib/apps/upgrade-piral.js +20 -19
- package/lib/apps/upgrade-piral.js.map +1 -1
- package/lib/apps/validate-pilet.js +13 -11
- package/lib/apps/validate-pilet.js.map +1 -1
- package/lib/apps/validate-piral.js +12 -10
- package/lib/apps/validate-piral.js.map +1 -1
- package/lib/bundler.js +18 -18
- package/lib/bundler.js.map +1 -1
- package/lib/cli.js +2 -2
- package/lib/cli.js.map +1 -1
- package/lib/commands.js +12 -12
- package/lib/commands.js.map +1 -1
- package/lib/common/archive.js +8 -8
- package/lib/common/archive.js.map +1 -1
- package/lib/common/browser.js +2 -2
- package/lib/common/browser.js.map +1 -1
- package/lib/common/clients/lerna.js +4 -4
- package/lib/common/clients/lerna.js.map +1 -1
- package/lib/common/clients/npm.js +12 -12
- package/lib/common/clients/npm.js.map +1 -1
- package/lib/common/clients/pnpm.js +5 -5
- package/lib/common/clients/pnpm.js.map +1 -1
- package/lib/common/clients/yarn.js +5 -5
- package/lib/common/clients/yarn.js.map +1 -1
- package/lib/common/compatibility.js +9 -9
- package/lib/common/compatibility.js.map +1 -1
- package/lib/common/config.d.ts +5 -1
- package/lib/common/config.js +2 -1
- package/lib/common/config.js.map +1 -1
- package/lib/common/declaration.js +19 -19
- package/lib/common/declaration.js.map +1 -1
- package/lib/common/emulator.js +23 -23
- package/lib/common/emulator.js.map +1 -1
- package/lib/common/envs.js +3 -3
- package/lib/common/envs.js.map +1 -1
- package/lib/common/hash.d.ts +1 -0
- package/lib/common/hash.js +8 -3
- package/lib/common/hash.js.map +1 -1
- package/lib/common/http.d.ts +1 -0
- package/lib/common/http.js +28 -14
- package/lib/common/http.js.map +1 -1
- package/lib/common/injectors.js +4 -4
- package/lib/common/injectors.js.map +1 -1
- package/lib/common/inspect.js +4 -4
- package/lib/common/inspect.js.map +1 -1
- package/lib/common/io.d.ts +1 -1
- package/lib/common/io.js +114 -93
- package/lib/common/io.js.map +1 -1
- package/lib/common/language.js +2 -2
- package/lib/common/language.js.map +1 -1
- package/lib/common/log.js +8 -8
- package/lib/common/log.js.map +1 -1
- package/lib/common/npm.js +43 -43
- package/lib/common/npm.js.map +1 -1
- package/lib/common/pack.js +18 -18
- package/lib/common/pack.js.map +1 -1
- package/lib/common/package.d.ts +3 -1
- package/lib/common/package.js +181 -80
- package/lib/common/package.js.map +1 -1
- package/lib/common/patcher.js +20 -20
- package/lib/common/patcher.js.map +1 -1
- package/lib/common/port.js +3 -3
- package/lib/common/port.js.map +1 -1
- package/lib/common/rules.js +4 -4
- package/lib/common/rules.js.map +1 -1
- package/lib/common/scaffold.js +15 -15
- package/lib/common/scaffold.js.map +1 -1
- package/lib/common/scripts.js +5 -5
- package/lib/common/scripts.js.map +1 -1
- package/lib/common/template.js +4 -4
- package/lib/common/template.js.map +1 -1
- package/lib/external/index.js +1369 -611
- package/lib/helpers.js +1 -1
- package/lib/helpers.js.map +1 -1
- package/lib/inject.js +2 -2
- package/lib/inject.js.map +1 -1
- package/lib/injectors/pilet.d.ts +1 -10
- package/lib/injectors/pilet.js +74 -27
- package/lib/injectors/pilet.js.map +1 -1
- package/lib/injectors/piral.js +4 -4
- package/lib/injectors/piral.js.map +1 -1
- package/lib/messages.d.ts +7 -2
- package/lib/messages.js +7 -2
- package/lib/messages.js.map +1 -1
- package/lib/pb-cli.js +1 -1
- package/lib/pb-cli.js.map +1 -1
- package/lib/pilet-cli.js +1 -1
- package/lib/pilet-cli.js.map +1 -1
- package/lib/piral-cli.js +1 -1
- package/lib/piral-cli.js.map +1 -1
- package/lib/plugin.js +10 -10
- package/lib/plugin.js.map +1 -1
- package/lib/release.js +3 -3
- package/lib/release.js.map +1 -1
- package/lib/resolvers.js +13 -13
- package/lib/resolvers.js.map +1 -1
- package/lib/rules/index.js +7 -7
- package/lib/rules/index.js.map +1 -1
- package/lib/rules/pilet-has-externals-as-peers.js +3 -3
- package/lib/rules/pilet-has-externals-as-peers.js.map +1 -1
- package/lib/rules/pilet-has-no-self-reference.js +1 -1
- package/lib/rules/pilet-has-no-self-reference.js.map +1 -1
- package/lib/rules/pilet-stays-small.js +3 -3
- package/lib/rules/pilet-stays-small.js.map +1 -1
- package/lib/rules/pilet-uses-latest-piral.js +1 -1
- package/lib/rules/pilet-uses-latest-piral.js.map +1 -1
- package/lib/rules/piral-entry-ends-with-html.js +1 -1
- package/lib/rules/piral-entry-ends-with-html.js.map +1 -1
- package/lib/rules/piral-has-valid-files.js +5 -5
- package/lib/rules/piral-has-valid-files.js.map +1 -1
- package/lib/runner.js +1 -1
- package/lib/runner.js.map +1 -1
- package/lib/select.js +6 -6
- package/lib/select.js.map +1 -1
- package/lib/types/common.d.ts +8 -0
- package/lib/types/public.d.ts +4 -2
- package/package.json +2 -2
- package/src/apps/build-pilet.ts +8 -5
- package/src/apps/build-piral.ts +4 -3
- package/src/apps/debug-pilet.ts +5 -4
- package/src/apps/debug-piral.ts +2 -1
- package/src/apps/declaration-piral.ts +3 -1
- package/src/apps/new-pilet.ts +3 -2
- package/src/apps/new-piral.ts +2 -1
- package/src/apps/pack-pilet.ts +3 -1
- package/src/apps/publish-pilet.ts +6 -5
- package/src/apps/publish-piral.ts +3 -2
- package/src/apps/upgrade-pilet.ts +4 -3
- package/src/apps/upgrade-piral.ts +2 -1
- package/src/apps/validate-pilet.ts +5 -2
- package/src/apps/validate-piral.ts +3 -1
- package/src/bundler.test.ts +18 -22
- package/src/common/config.ts +6 -1
- package/src/common/hash.ts +5 -0
- package/src/common/http.ts +18 -4
- package/src/common/io.ts +56 -33
- package/src/common/package.ts +118 -8
- package/src/helpers.ts +1 -1
- package/src/injectors/pilet.ts +82 -22
- package/src/messages.ts +7 -2
- package/src/types/common.ts +9 -0
- package/src/types/public.ts +4 -1
package/src/common/package.ts
CHANGED
|
@@ -5,12 +5,13 @@ import { unpackTarball } from './archive';
|
|
|
5
5
|
import { getDependencies, getDevDependencies } from './language';
|
|
6
6
|
import { SourceLanguage, ForceOverwrite } from './enums';
|
|
7
7
|
import { checkAppShellCompatibility } from './compatibility';
|
|
8
|
+
import { deepMerge } from './merge';
|
|
9
|
+
import { getHashFromUrl } from './http';
|
|
10
|
+
import { isGitPackage, isLocalPackage, makeGitUrl, makeFilePath, makeExternals } from './npm';
|
|
8
11
|
import { filesTar, filesOnceTar, declarationEntryExtensions } from './constants';
|
|
9
|
-
import { getHash, checkIsDirectory, matchFiles
|
|
12
|
+
import { getHash, checkIsDirectory, matchFiles } from './io';
|
|
10
13
|
import { readJson, copy, updateExistingJson, findFile, checkExists } from './io';
|
|
11
|
-
import { Framework, FileInfo, PiletsInfo, TemplateFileLocation } from '../types';
|
|
12
|
-
import { isGitPackage, isLocalPackage, makeGitUrl, makeFilePath, makeExternals } from './npm';
|
|
13
|
-
import { deepMerge } from './merge';
|
|
14
|
+
import { Framework, FileInfo, PiletsInfo, TemplateFileLocation, SharedDependency } from '../types';
|
|
14
15
|
|
|
15
16
|
function getDependencyVersion(
|
|
16
17
|
name: string,
|
|
@@ -86,10 +87,15 @@ async function getMatchingFiles(
|
|
|
86
87
|
}
|
|
87
88
|
|
|
88
89
|
export function getPiralPath(root: string, name: string) {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
90
|
+
try {
|
|
91
|
+
const path = require.resolve(`${name}/package.json`, {
|
|
92
|
+
paths: [root],
|
|
93
|
+
});
|
|
94
|
+
return dirname(path);
|
|
95
|
+
} catch (ex) {
|
|
96
|
+
log('generalDebug_0003', `Could not resolve the Piral path of "${name}" in "${root}": ${ex}.`);
|
|
97
|
+
fail('invalidPiralReference_0043');
|
|
98
|
+
}
|
|
93
99
|
}
|
|
94
100
|
|
|
95
101
|
export function findPackageRoot(pck: string, baseDir: string) {
|
|
@@ -528,6 +534,108 @@ export function checkAppShellPackage(appPackage: any) {
|
|
|
528
534
|
return false;
|
|
529
535
|
}
|
|
530
536
|
|
|
537
|
+
function tryResolve(baseDir: string, name: string) {
|
|
538
|
+
try {
|
|
539
|
+
return require.resolve(name, {
|
|
540
|
+
paths: [baseDir],
|
|
541
|
+
});
|
|
542
|
+
} catch (ex) {
|
|
543
|
+
log('generalDebug_0003', `Could not resolve the package "${name}" in "${baseDir}": ${ex}`);
|
|
544
|
+
return undefined;
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
interface Importmap {
|
|
549
|
+
imports: Record<string, string>;
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
function normalizeDepName(s: string) {
|
|
553
|
+
return (s.startsWith('@') ? s.substr(1) : s).replace(/[\/\.]/g, '-').replace(/(\-)+/, '-');
|
|
554
|
+
}
|
|
555
|
+
|
|
556
|
+
async function resolveImportmap(dir: string, importmap: Importmap) {
|
|
557
|
+
const dependencies: Array<SharedDependency> = [];
|
|
558
|
+
const sharedImports = importmap?.imports;
|
|
559
|
+
|
|
560
|
+
if (typeof sharedImports === 'object' && sharedImports) {
|
|
561
|
+
for (const depName of Object.keys(sharedImports)) {
|
|
562
|
+
const url = sharedImports[depName];
|
|
563
|
+
const assetName = normalizeDepName(depName);
|
|
564
|
+
|
|
565
|
+
if (typeof url !== 'string') {
|
|
566
|
+
} else if (/^https?:\/\//.test(url)) {
|
|
567
|
+
const hash = await getHashFromUrl(url);
|
|
568
|
+
|
|
569
|
+
dependencies.push({
|
|
570
|
+
id: `${depName}@${hash}`,
|
|
571
|
+
entry: url,
|
|
572
|
+
name: depName,
|
|
573
|
+
ref: url,
|
|
574
|
+
type: 'remote',
|
|
575
|
+
});
|
|
576
|
+
} else if (url === depName) {
|
|
577
|
+
const entry = tryResolve(dir, depName);
|
|
578
|
+
|
|
579
|
+
if (entry) {
|
|
580
|
+
const packageJson = await findFile(dirname(entry), 'package.json');
|
|
581
|
+
const details = require(packageJson);
|
|
582
|
+
|
|
583
|
+
dependencies.push({
|
|
584
|
+
id: `${depName}@${details.version}`,
|
|
585
|
+
entry,
|
|
586
|
+
ref: `${assetName}.js`,
|
|
587
|
+
name: depName,
|
|
588
|
+
type: 'local',
|
|
589
|
+
});
|
|
590
|
+
}
|
|
591
|
+
} else {
|
|
592
|
+
const entry = resolve(dir, url);
|
|
593
|
+
const exists = await checkExists(entry);
|
|
594
|
+
|
|
595
|
+
if (exists) {
|
|
596
|
+
const packageJson = await findFile(dirname(entry), 'package.json');
|
|
597
|
+
|
|
598
|
+
if (packageJson) {
|
|
599
|
+
const details = require(packageJson);
|
|
600
|
+
|
|
601
|
+
dependencies.push({
|
|
602
|
+
id: `${depName}@${details.version}`,
|
|
603
|
+
entry,
|
|
604
|
+
name: depName,
|
|
605
|
+
ref: `${assetName}.js`,
|
|
606
|
+
type: 'local',
|
|
607
|
+
});
|
|
608
|
+
} else {
|
|
609
|
+
const hash = await getHash(entry);
|
|
610
|
+
|
|
611
|
+
dependencies.push({
|
|
612
|
+
id: `${depName}@${hash}`,
|
|
613
|
+
entry,
|
|
614
|
+
name: depName,
|
|
615
|
+
ref: `${assetName}.js`,
|
|
616
|
+
type: 'local',
|
|
617
|
+
});
|
|
618
|
+
}
|
|
619
|
+
}
|
|
620
|
+
}
|
|
621
|
+
}
|
|
622
|
+
}
|
|
623
|
+
|
|
624
|
+
return dependencies;
|
|
625
|
+
}
|
|
626
|
+
|
|
627
|
+
export async function readImportmap(dir: string, packageDetails: any) {
|
|
628
|
+
const importmap = packageDetails.importmap;
|
|
629
|
+
|
|
630
|
+
if (typeof importmap === 'string') {
|
|
631
|
+
const content = await readJson(dir, importmap);
|
|
632
|
+
const baseDir = dirname(resolve(dir, importmap));
|
|
633
|
+
return resolveImportmap(baseDir, content);
|
|
634
|
+
}
|
|
635
|
+
|
|
636
|
+
return resolveImportmap(dir, importmap);
|
|
637
|
+
}
|
|
638
|
+
|
|
531
639
|
export async function retrievePiletData(target: string, app?: string) {
|
|
532
640
|
const packageJson = await findFile(target, 'package.json');
|
|
533
641
|
|
|
@@ -548,6 +656,7 @@ export async function retrievePiletData(target: string, app?: string) {
|
|
|
548
656
|
}
|
|
549
657
|
|
|
550
658
|
const emulator = checkAppShellPackage(appPackage);
|
|
659
|
+
const importmap = await readImportmap(root, piletPackage);
|
|
551
660
|
|
|
552
661
|
return {
|
|
553
662
|
dependencies: piletPackage.dependencies || {},
|
|
@@ -555,6 +664,7 @@ export async function retrievePiletData(target: string, app?: string) {
|
|
|
555
664
|
peerDependencies: piletPackage.peerDependencies || {},
|
|
556
665
|
peerModules: piletPackage.peerModules || [],
|
|
557
666
|
ignored: checkArrayOrUndefined(piletPackage, 'preservedDependencies'),
|
|
667
|
+
importmap,
|
|
558
668
|
appFile,
|
|
559
669
|
piletPackage,
|
|
560
670
|
appPackage,
|
package/src/helpers.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ForceOverwrite, SourceLanguage } from './common/enums';
|
|
2
2
|
import { Framework, NpmClientType, PiletSchemaVersion, PiletPublishSource, PiralBuildType } from './types';
|
|
3
3
|
|
|
4
|
-
export const schemaKeys: Array<PiletSchemaVersion> = ['v0', 'v1', 'none'];
|
|
4
|
+
export const schemaKeys: Array<PiletSchemaVersion> = ['v0', 'v1', 'v2', 'none'];
|
|
5
5
|
export const fromKeys: Array<PiletPublishSource> = ['local', 'remote', 'npm'];
|
|
6
6
|
export const buildTypeKeys: Array<PiralBuildType> = ['all', 'release', 'emulator', 'emulator-sources'];
|
|
7
7
|
export const clientTypeKeys: Array<NpmClientType> = ['npm', 'pnpm', 'yarn'];
|
package/src/injectors/pilet.ts
CHANGED
|
@@ -1,15 +1,17 @@
|
|
|
1
|
+
import { URL } from 'url';
|
|
1
2
|
import { join } from 'path';
|
|
2
3
|
import { EventEmitter } from 'events';
|
|
3
4
|
import { readFileSync, existsSync, statSync } from 'fs';
|
|
4
5
|
import { KrasInjector, KrasResponse, KrasRequest, KrasInjectorConfig, KrasConfiguration, KrasResult } from 'kras';
|
|
6
|
+
import { computeHash, computeIntegrity } from '../common/hash';
|
|
7
|
+
import { log } from '../common/log';
|
|
5
8
|
import { axios, mime } from '../external';
|
|
6
9
|
import { Bundler } from '../types';
|
|
7
|
-
import { log } from '../common/log';
|
|
8
10
|
|
|
9
11
|
interface Pilet {
|
|
10
12
|
bundler: Bundler;
|
|
11
13
|
root: string;
|
|
12
|
-
|
|
14
|
+
meta: PiletMetadata;
|
|
13
15
|
}
|
|
14
16
|
|
|
15
17
|
export interface PiletInjectorConfig extends KrasInjectorConfig {
|
|
@@ -24,6 +26,80 @@ interface PiletMetadata {
|
|
|
24
26
|
[key: string]: unknown;
|
|
25
27
|
}
|
|
26
28
|
|
|
29
|
+
const checkV1 = /^\/\/\s*@pilet\s+v:1\s*\(([A-Za-z0-9\_\:\-]+)\)/;
|
|
30
|
+
const checkV2 = /^\/\/\s*@pilet\s+v:2\s*(?:\(([A-Za-z0-9\_\:\-]+),\s*(.*)\))?/;
|
|
31
|
+
|
|
32
|
+
function getDependencies(deps: string, basePath: string) {
|
|
33
|
+
try {
|
|
34
|
+
const depMap = JSON.parse(deps);
|
|
35
|
+
|
|
36
|
+
if (depMap && typeof depMap === 'object') {
|
|
37
|
+
return Object.keys(depMap).reduce((obj, depName) => {
|
|
38
|
+
const depUrl = depMap[depName];
|
|
39
|
+
|
|
40
|
+
if (typeof depUrl === 'string') {
|
|
41
|
+
const url = new URL(depUrl, basePath);
|
|
42
|
+
obj[depName] = url.href;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return obj;
|
|
46
|
+
}, {});
|
|
47
|
+
}
|
|
48
|
+
} catch {}
|
|
49
|
+
|
|
50
|
+
return {};
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function getPiletSpecMeta(target: string, basePath: string) {
|
|
54
|
+
if (existsSync(target) && statSync(target).isFile()) {
|
|
55
|
+
const content = readFileSync(target, 'utf8');
|
|
56
|
+
|
|
57
|
+
if (checkV1.test(content)) {
|
|
58
|
+
// uses single argument; requireRef (required)
|
|
59
|
+
const [, requireRef] = checkV1.exec(content);
|
|
60
|
+
return {
|
|
61
|
+
spec: 'v1',
|
|
62
|
+
requireRef,
|
|
63
|
+
integrity: computeIntegrity(content),
|
|
64
|
+
};
|
|
65
|
+
} else if (checkV2.test(content)) {
|
|
66
|
+
// uses two arguments; requireRef and dependencies as JSON (required)
|
|
67
|
+
const [, requireRef, plainDependencies] = checkV2.exec(content);
|
|
68
|
+
return {
|
|
69
|
+
spec: 'v2',
|
|
70
|
+
requireRef,
|
|
71
|
+
dependencies: getDependencies(plainDependencies, basePath),
|
|
72
|
+
};
|
|
73
|
+
} else {
|
|
74
|
+
return {
|
|
75
|
+
spec: 'v0',
|
|
76
|
+
hash: computeHash(content),
|
|
77
|
+
noCache: true,
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
return {};
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
function fillPiletMeta(pilet: Pilet, basePath: string) {
|
|
86
|
+
const { root, bundler } = pilet;
|
|
87
|
+
const def = JSON.parse(readFileSync(join(root, 'package.json'), 'utf8'));
|
|
88
|
+
const file = bundler.bundle.name.replace(/^[\/\\]/, '');
|
|
89
|
+
const target = join(bundler.bundle.dir, file);
|
|
90
|
+
const url = new URL(file, basePath);
|
|
91
|
+
const meta = {
|
|
92
|
+
name: def.name,
|
|
93
|
+
version: def.version,
|
|
94
|
+
link: `${url.href}?updated=${Date.now()}`,
|
|
95
|
+
custom: def.custom,
|
|
96
|
+
...getPiletSpecMeta(target, basePath),
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
pilet.meta = meta;
|
|
100
|
+
return JSON.stringify(meta);
|
|
101
|
+
}
|
|
102
|
+
|
|
27
103
|
export default class PiletInjector implements KrasInjector {
|
|
28
104
|
public config: PiletInjectorConfig;
|
|
29
105
|
private piletApi: string;
|
|
@@ -49,9 +125,9 @@ export default class PiletInjector implements KrasInjector {
|
|
|
49
125
|
});
|
|
50
126
|
|
|
51
127
|
pilets.forEach((p, i) =>
|
|
52
|
-
p.bundler.on((
|
|
53
|
-
|
|
54
|
-
const meta =
|
|
128
|
+
p.bundler.on(() => {
|
|
129
|
+
const basePath = `${this.piletApi}/${i}/`;
|
|
130
|
+
const meta = fillPiletMeta(p, basePath);
|
|
55
131
|
|
|
56
132
|
for (const id of Object.keys(cbs)) {
|
|
57
133
|
cbs[id](meta);
|
|
@@ -77,25 +153,9 @@ export default class PiletInjector implements KrasInjector {
|
|
|
77
153
|
|
|
78
154
|
setOptions() {}
|
|
79
155
|
|
|
80
|
-
getMetaOf(index: number) {
|
|
81
|
-
const { api, pilets } = this.config;
|
|
82
|
-
const { bundler, root, requireRef } = pilets[index];
|
|
83
|
-
const def = JSON.parse(readFileSync(join(root, 'package.json'), 'utf8'));
|
|
84
|
-
const file = bundler.bundle.name.replace(/^\//, '');
|
|
85
|
-
return {
|
|
86
|
-
name: def.name,
|
|
87
|
-
version: def.version,
|
|
88
|
-
link: `${this.piletApi}/${index}/${file}`,
|
|
89
|
-
hash: bundler.bundle.hash,
|
|
90
|
-
requireRef,
|
|
91
|
-
noCache: true,
|
|
92
|
-
custom: def.custom,
|
|
93
|
-
};
|
|
94
|
-
}
|
|
95
|
-
|
|
96
156
|
async getMeta() {
|
|
97
157
|
const { pilets, feed } = this.config;
|
|
98
|
-
const localPilets = pilets.map((
|
|
158
|
+
const localPilets = pilets.map((pilet) => pilet.meta).filter(Boolean);
|
|
99
159
|
const mergedPilets = this.mergePilets(localPilets, await this.loadRemoteFeed(feed));
|
|
100
160
|
|
|
101
161
|
if (mergedPilets.length === 1) {
|
package/src/messages.ts
CHANGED
|
@@ -2010,13 +2010,18 @@ export function failedToOpenBrowser_0170(error: string): QuickMessage {
|
|
|
2010
2010
|
* the interpretation of compatible feed services slightly and has an impact of the usage
|
|
2011
2011
|
* of the pilet in the browser.
|
|
2012
2012
|
*
|
|
2013
|
-
* The selected schema version needs to be either "v0" or "
|
|
2013
|
+
* The selected schema version needs to be either "v0", "v1", or "v2".
|
|
2014
2014
|
*
|
|
2015
2015
|
* - v0: will download and evaluate the pilet explicitly
|
|
2016
|
-
* - v1: will use a script tag for integration of the pilet
|
|
2016
|
+
* - v1: will use a script tag for integration of the pilet
|
|
2017
|
+
* - v2: will use SystemJS for integration of the pilet (default)
|
|
2017
2018
|
*
|
|
2018
2019
|
* The v1 version has better support for older browsers, but requires a polyfill to work
|
|
2019
2020
|
* correctly. This polyfill is part of the standard Piral polyfills.
|
|
2021
|
+
*
|
|
2022
|
+
* The v2 version uses a SystemJS format for the pilet. It has the broadest browser support
|
|
2023
|
+
* but requires the custom format as output. Most bundlers support SystemJS directly or
|
|
2024
|
+
* indirectly, making it a quite broad choice.
|
|
2020
2025
|
*
|
|
2021
2026
|
* @see
|
|
2022
2027
|
* - [GitHub currentScript-polyfill](https://github.com/amiller-gh/currentScript-polyfill)
|
package/src/types/common.ts
CHANGED
|
@@ -76,6 +76,14 @@ export interface RuleContext {
|
|
|
76
76
|
peerDependencies: Record<string, string>;
|
|
77
77
|
}
|
|
78
78
|
|
|
79
|
+
export interface SharedDependency {
|
|
80
|
+
id: string;
|
|
81
|
+
name: string;
|
|
82
|
+
ref: string;
|
|
83
|
+
type: 'local' | 'remote';
|
|
84
|
+
entry: string;
|
|
85
|
+
}
|
|
86
|
+
|
|
79
87
|
export interface RuleRunner<T extends RuleContext> {
|
|
80
88
|
(context: T, options: any): void | Promise<void>;
|
|
81
89
|
}
|
|
@@ -92,6 +100,7 @@ export interface PiralRuleContext extends RuleContext {
|
|
|
92
100
|
export interface PiletRuleContext extends RuleContext {
|
|
93
101
|
data: PiralData;
|
|
94
102
|
peerModules: Array<string>;
|
|
103
|
+
importmap: Array<SharedDependency>;
|
|
95
104
|
}
|
|
96
105
|
|
|
97
106
|
export interface PiralData {
|
package/src/types/public.ts
CHANGED
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
Bundler,
|
|
7
7
|
BundleDetails,
|
|
8
8
|
LogLevels,
|
|
9
|
+
SharedDependency,
|
|
9
10
|
ReleaseProvider,
|
|
10
11
|
} from './common';
|
|
11
12
|
|
|
@@ -108,6 +109,7 @@ export interface DebugPiletParameters extends BaseBundleParameters {
|
|
|
108
109
|
piral: string;
|
|
109
110
|
hmr: boolean;
|
|
110
111
|
externals: Array<string>;
|
|
112
|
+
importmap: Array<SharedDependency>;
|
|
111
113
|
targetDir: string;
|
|
112
114
|
entryModule: string;
|
|
113
115
|
logLevel: LogLevels;
|
|
@@ -120,6 +122,7 @@ export interface BuildPiletParameters extends BaseBundleParameters {
|
|
|
120
122
|
contentHash: boolean;
|
|
121
123
|
minify: boolean;
|
|
122
124
|
externals: Array<string>;
|
|
125
|
+
importmap: Array<SharedDependency>;
|
|
123
126
|
targetDir: string;
|
|
124
127
|
outFile: string;
|
|
125
128
|
outDir: string;
|
|
@@ -160,7 +163,7 @@ export interface BundlerDefinition {
|
|
|
160
163
|
buildPilet: BuildPiletBundlerDefinition;
|
|
161
164
|
}
|
|
162
165
|
|
|
163
|
-
export type PiletSchemaVersion = 'none' | 'v0' | 'v1';
|
|
166
|
+
export type PiletSchemaVersion = 'none' | 'v0' | 'v1' | 'v2';
|
|
164
167
|
|
|
165
168
|
export type PiletPublishSource = 'local' | 'npm' | 'remote';
|
|
166
169
|
|