@stencil/core 2.17.1 → 2.17.3
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/cli/config-flags.d.ts +12 -4
- package/cli/index.cjs +110 -71
- package/cli/index.d.ts +1 -1
- package/cli/index.js +110 -71
- package/cli/package.json +1 -1
- package/compiler/package.json +1 -1
- package/compiler/stencil.js +343 -61
- package/compiler/stencil.min.js +2 -2
- package/dependencies.json +1 -1
- package/dev-server/client/index.js +1 -1
- package/dev-server/client/package.json +1 -1
- package/dev-server/connector.html +2 -2
- package/dev-server/index.js +1 -1
- package/dev-server/package.json +1 -1
- package/dev-server/server-process.js +2 -2
- package/internal/app-data/package.json +1 -1
- package/internal/client/css-shim.js +1 -1
- package/internal/client/dom.js +1 -1
- package/internal/client/index.js +1 -1
- package/internal/client/package.json +1 -1
- package/internal/client/patch-browser.js +1 -1
- package/internal/client/patch-esm.js +1 -1
- package/internal/client/shadow-css.js +1 -1
- package/internal/hydrate/package.json +1 -1
- package/internal/package.json +1 -1
- package/internal/stencil-private.d.ts +12 -2
- package/internal/stencil-public-compiler.d.ts +1 -1
- package/internal/testing/package.json +1 -1
- package/mock-doc/index.cjs +41 -3
- package/mock-doc/index.d.ts +15 -0
- package/mock-doc/index.js +41 -3
- package/mock-doc/package.json +1 -1
- package/package.json +1 -1
- package/screenshot/package.json +1 -1
- package/sys/node/index.js +1 -1
- package/sys/node/package.json +1 -1
- package/sys/node/worker.js +1 -1
- package/testing/index.js +37 -22
- package/testing/mocks.d.ts +7 -6
- package/testing/package.json +1 -1
package/cli/config-flags.d.ts
CHANGED
|
@@ -94,9 +94,17 @@ declare type LogLevelFlags = ObjectFromKeys<typeof LOG_LEVEL_CLI_ARGS, LogLevel>
|
|
|
94
94
|
* on actual flags passed by the user.
|
|
95
95
|
*/
|
|
96
96
|
export interface ConfigFlags extends BooleanConfigFlags, StringConfigFlags, NumberConfigFlags, StringNumberConfigFlags, LogLevelFlags {
|
|
97
|
-
task
|
|
98
|
-
args
|
|
99
|
-
knownArgs
|
|
100
|
-
unknownArgs
|
|
97
|
+
task: TaskCommand | null;
|
|
98
|
+
args: string[];
|
|
99
|
+
knownArgs: string[];
|
|
100
|
+
unknownArgs: string[];
|
|
101
101
|
}
|
|
102
|
+
/**
|
|
103
|
+
* Helper function for initializing a `ConfigFlags` object. Provide any overrides
|
|
104
|
+
* for default values and off you go!
|
|
105
|
+
*
|
|
106
|
+
* @param init an object with any overrides for default values
|
|
107
|
+
* @returns a complete CLI flag object
|
|
108
|
+
*/
|
|
109
|
+
export declare const createConfigFlags: (init?: Partial<ConfigFlags>) => ConfigFlags;
|
|
102
110
|
export {};
|
package/cli/index.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
Stencil CLI (CommonJS) v2.17.
|
|
2
|
+
Stencil CLI (CommonJS) v2.17.3 | MIT Licensed | https://stenciljs.com
|
|
3
3
|
*/
|
|
4
4
|
'use strict';
|
|
5
5
|
|
|
@@ -522,45 +522,53 @@ const CLI_ARG_ALIASES = {
|
|
|
522
522
|
port: 'p',
|
|
523
523
|
version: 'v',
|
|
524
524
|
};
|
|
525
|
-
|
|
526
525
|
/**
|
|
527
|
-
*
|
|
526
|
+
* Helper function for initializing a `ConfigFlags` object. Provide any overrides
|
|
527
|
+
* for default values and off you go!
|
|
528
528
|
*
|
|
529
|
-
* @param
|
|
530
|
-
* @
|
|
531
|
-
* @returns a structured ConfigFlags object
|
|
529
|
+
* @param init an object with any overrides for default values
|
|
530
|
+
* @returns a complete CLI flag object
|
|
532
531
|
*/
|
|
533
|
-
const
|
|
532
|
+
const createConfigFlags = (init = {}) => {
|
|
534
533
|
const flags = {
|
|
535
534
|
task: null,
|
|
536
535
|
args: [],
|
|
537
536
|
knownArgs: [],
|
|
538
537
|
unknownArgs: [],
|
|
538
|
+
...init,
|
|
539
539
|
};
|
|
540
|
+
return flags;
|
|
541
|
+
};
|
|
542
|
+
|
|
543
|
+
/**
|
|
544
|
+
* Parse command line arguments into a structured `ConfigFlags` object
|
|
545
|
+
*
|
|
546
|
+
* @param args an array of CLI flags
|
|
547
|
+
* @param _sys an optional compiler system
|
|
548
|
+
* @returns a structured ConfigFlags object
|
|
549
|
+
*/
|
|
550
|
+
const parseFlags = (args, _sys) => {
|
|
551
|
+
// TODO(STENCIL-509): remove the _sys parameter here ^^ (for v3)
|
|
552
|
+
const flags = createConfigFlags();
|
|
540
553
|
// cmd line has more priority over npm scripts cmd
|
|
541
554
|
flags.args = Array.isArray(args) ? args.slice() : [];
|
|
542
555
|
if (flags.args.length > 0 && flags.args[0] && !flags.args[0].startsWith('-')) {
|
|
543
556
|
flags.task = flags.args[0];
|
|
544
557
|
}
|
|
545
558
|
parseArgs(flags, flags.args);
|
|
546
|
-
if (sys && sys.name === 'node') {
|
|
547
|
-
const envArgs = getNpmConfigEnvArgs(sys);
|
|
548
|
-
parseArgs(flags, envArgs);
|
|
549
|
-
envArgs.forEach((envArg) => {
|
|
550
|
-
if (!flags.args.includes(envArg)) {
|
|
551
|
-
flags.args.push(envArg);
|
|
552
|
-
}
|
|
553
|
-
});
|
|
554
|
-
}
|
|
555
559
|
if (flags.task != null) {
|
|
556
560
|
const i = flags.args.indexOf(flags.task);
|
|
557
561
|
if (i > -1) {
|
|
558
562
|
flags.args.splice(i, 1);
|
|
559
563
|
}
|
|
560
564
|
}
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
565
|
+
// to find unknown / unrecognized arguments we filter `args`, including only
|
|
566
|
+
// arguments whose normalized form is not found in `knownArgs`. `knownArgs`
|
|
567
|
+
// is populated during the call to `parseArgs` above. For arguments like
|
|
568
|
+
// `--foobar` the string `"--foobar"` will be added, while for more
|
|
569
|
+
// complicated arguments like `--bizBoz=bop` or `--bizBoz bop` just the
|
|
570
|
+
// string `"--bizBoz"` will be added.
|
|
571
|
+
flags.unknownArgs = flags.args.filter((arg) => !flags.knownArgs.includes(parseEqualsArg(arg)[0]));
|
|
564
572
|
return flags;
|
|
565
573
|
};
|
|
566
574
|
/**
|
|
@@ -746,17 +754,17 @@ const getValue = (args, configCaseName) => {
|
|
|
746
754
|
let matchingArg;
|
|
747
755
|
args.forEach((arg, i) => {
|
|
748
756
|
if (arg.startsWith(`--${dashCaseName}=`) || arg.startsWith(`--${configCaseName}=`)) {
|
|
749
|
-
|
|
750
|
-
matchingArg = arg;
|
|
757
|
+
// our argument was passed at the command-line in the format --argName=arg-value
|
|
758
|
+
[matchingArg, value] = parseEqualsArg(arg);
|
|
751
759
|
}
|
|
752
760
|
else if (arg === `--${dashCaseName}` || arg === `--${configCaseName}`) {
|
|
761
|
+
// the next value in the array is assumed to be a value for this argument
|
|
753
762
|
value = args[i + 1];
|
|
754
763
|
matchingArg = arg;
|
|
755
764
|
}
|
|
756
765
|
else if (alias) {
|
|
757
766
|
if (arg.startsWith(`-${alias}=`)) {
|
|
758
|
-
value =
|
|
759
|
-
matchingArg = arg;
|
|
767
|
+
[matchingArg, value] = parseEqualsArg(arg);
|
|
760
768
|
}
|
|
761
769
|
else if (arg === `-${alias}`) {
|
|
762
770
|
value = args[i + 1];
|
|
@@ -767,13 +775,42 @@ const getValue = (args, configCaseName) => {
|
|
|
767
775
|
return { value, matchingArg };
|
|
768
776
|
};
|
|
769
777
|
/**
|
|
770
|
-
*
|
|
771
|
-
* `--foobar
|
|
778
|
+
* Parse an 'equals' argument, which is a CLI argument-value pair in the
|
|
779
|
+
* format `--foobar=12` (as opposed to a space-separated format like
|
|
780
|
+
* `--foobar 12`).
|
|
781
|
+
*
|
|
782
|
+
* To parse this we split on the `=`, returning the first part as the argument
|
|
783
|
+
* name and the second part as the value. We join the value on `"="` in case
|
|
784
|
+
* there is another `"="` in the argument.
|
|
785
|
+
*
|
|
786
|
+
* This function is safe to call with any arg, and can therefore be used as
|
|
787
|
+
* an argument 'normalizer'. If CLI argument is not an 'equals' argument then
|
|
788
|
+
* the return value will be a tuple of the original argument and an empty
|
|
789
|
+
* string `""` for the value.
|
|
790
|
+
*
|
|
791
|
+
* In code terms, if you do:
|
|
772
792
|
*
|
|
773
|
-
*
|
|
774
|
-
*
|
|
793
|
+
* ```ts
|
|
794
|
+
* const [arg, value] = parseEqualsArg("--myArgument")
|
|
795
|
+
* ```
|
|
796
|
+
*
|
|
797
|
+
* Then `arg` will be `"--myArgument"` and `value` will be `""`, whereas if
|
|
798
|
+
* you do:
|
|
799
|
+
*
|
|
800
|
+
*
|
|
801
|
+
* ```ts
|
|
802
|
+
* const [arg, value] = parseEqualsArg("--myArgument=myValue")
|
|
803
|
+
* ```
|
|
804
|
+
*
|
|
805
|
+
* Then `arg` will be `"--myArgument"` and `value` will be `"myValue"`.
|
|
806
|
+
*
|
|
807
|
+
* @param arg the arg in question
|
|
808
|
+
* @returns a tuple containing the arg name and the value (if present)
|
|
775
809
|
*/
|
|
776
|
-
const
|
|
810
|
+
const parseEqualsArg = (arg) => {
|
|
811
|
+
const [originalArg, ...value] = arg.split('=');
|
|
812
|
+
return [originalArg, value.join('=')];
|
|
813
|
+
};
|
|
777
814
|
/**
|
|
778
815
|
* Small helper for getting type-system-level assurance that a `string` can be
|
|
779
816
|
* narrowed to a `LogLevel`
|
|
@@ -788,27 +825,11 @@ const isLogLevel = (maybeLogLevel) =>
|
|
|
788
825
|
//
|
|
789
826
|
// see microsoft/TypeScript#31018 for some discussion of this
|
|
790
827
|
LOG_LEVELS.includes(maybeLogLevel);
|
|
791
|
-
const getNpmConfigEnvArgs = (sys) => {
|
|
792
|
-
// process.env.npm_config_argv
|
|
793
|
-
// {"remain":["4444"],"cooked":["run","serve","--port","4444"],"original":["run","serve","--port","4444"]}
|
|
794
|
-
let args = [];
|
|
795
|
-
try {
|
|
796
|
-
const npmConfigArgs = sys.getEnvironmentVar('npm_config_argv');
|
|
797
|
-
if (npmConfigArgs) {
|
|
798
|
-
args = JSON.parse(npmConfigArgs).original;
|
|
799
|
-
if (args[0] === 'run') {
|
|
800
|
-
args = args.slice(2);
|
|
801
|
-
}
|
|
802
|
-
}
|
|
803
|
-
}
|
|
804
|
-
catch (e) { }
|
|
805
|
-
return args;
|
|
806
|
-
};
|
|
807
828
|
|
|
808
829
|
const dependencies = [
|
|
809
830
|
{
|
|
810
831
|
name: "@stencil/core",
|
|
811
|
-
version: "2.17.
|
|
832
|
+
version: "2.17.3",
|
|
812
833
|
main: "compiler/stencil.js",
|
|
813
834
|
resources: [
|
|
814
835
|
"package.json",
|
|
@@ -1304,6 +1325,15 @@ async function telemetryAction(sys, config, coreCompiler, action) {
|
|
|
1304
1325
|
throw error;
|
|
1305
1326
|
}
|
|
1306
1327
|
}
|
|
1328
|
+
/**
|
|
1329
|
+
* Helper function to determine if a Stencil configuration builds an application.
|
|
1330
|
+
*
|
|
1331
|
+
* This function is a rough approximation whether an application is generated as a part of a Stencil build, based on
|
|
1332
|
+
* contents of the project's `stencil.config.ts` file.
|
|
1333
|
+
*
|
|
1334
|
+
* @param config the configuration used by the Stencil project
|
|
1335
|
+
* @returns true if we believe the project generates an application, false otherwise
|
|
1336
|
+
*/
|
|
1307
1337
|
function hasAppTarget(config) {
|
|
1308
1338
|
return config.outputTargets.some((target) => target.type === WWW && (!!target.serviceWorker || (!!target.baseUrl && target.baseUrl !== '/')));
|
|
1309
1339
|
}
|
|
@@ -1311,7 +1341,15 @@ function isUsingYarn(sys) {
|
|
|
1311
1341
|
var _a;
|
|
1312
1342
|
return ((_a = sys.getEnvironmentVar('npm_execpath')) === null || _a === void 0 ? void 0 : _a.includes('yarn')) || false;
|
|
1313
1343
|
}
|
|
1314
|
-
|
|
1344
|
+
/**
|
|
1345
|
+
* Build a list of the different types of output targets used in a Stencil configuration.
|
|
1346
|
+
*
|
|
1347
|
+
* Duplicate entries will not be returned from the list
|
|
1348
|
+
*
|
|
1349
|
+
* @param config the configuration used by the Stencil project
|
|
1350
|
+
* @returns a unique list of output target types found in the Stencil configuration
|
|
1351
|
+
*/
|
|
1352
|
+
function getActiveTargets(config) {
|
|
1315
1353
|
const result = config.outputTargets.map((t) => t.type);
|
|
1316
1354
|
return Array.from(new Set(result));
|
|
1317
1355
|
}
|
|
@@ -1328,7 +1366,7 @@ async function getActiveTargets(config) {
|
|
|
1328
1366
|
const prepareData = async (coreCompiler, config, sys, duration_ms, component_count = undefined) => {
|
|
1329
1367
|
const { typescript, rollup } = coreCompiler.versions || { typescript: 'unknown', rollup: 'unknown' };
|
|
1330
1368
|
const { packages, packagesNoVersions } = await getInstalledPackages(sys, config);
|
|
1331
|
-
const targets =
|
|
1369
|
+
const targets = getActiveTargets(config);
|
|
1332
1370
|
const yarn = isUsingYarn(sys);
|
|
1333
1371
|
const stencil = coreCompiler.version || 'unknown';
|
|
1334
1372
|
const system = `${sys.name} ${sys.version}`;
|
|
@@ -1391,14 +1429,13 @@ const CONFIG_PROPS_TO_DELETE = ['sys', 'logger', 'tsCompilerOptions', 'devServer
|
|
|
1391
1429
|
* @returns an anonymized copy of the same config
|
|
1392
1430
|
*/
|
|
1393
1431
|
const anonymizeConfigForTelemetry = (config) => {
|
|
1394
|
-
var _a;
|
|
1395
1432
|
const anonymizedConfig = { ...config };
|
|
1396
1433
|
for (const prop of CONFIG_PROPS_TO_ANONYMIZE) {
|
|
1397
1434
|
if (anonymizedConfig[prop] !== undefined) {
|
|
1398
1435
|
anonymizedConfig[prop] = 'omitted';
|
|
1399
1436
|
}
|
|
1400
1437
|
}
|
|
1401
|
-
anonymizedConfig.outputTargets =
|
|
1438
|
+
anonymizedConfig.outputTargets = config.outputTargets.map((target) => {
|
|
1402
1439
|
// Anonymize the outputTargets on our configuration, taking advantage of the
|
|
1403
1440
|
// optional 2nd argument to `JSON.stringify`. If anything is not a string
|
|
1404
1441
|
// we retain it so that any nested properties are handled, else we check
|
|
@@ -1619,7 +1656,7 @@ function getMajorVersion(version) {
|
|
|
1619
1656
|
return parts[0];
|
|
1620
1657
|
}
|
|
1621
1658
|
|
|
1622
|
-
const taskBuild = async (coreCompiler, config
|
|
1659
|
+
const taskBuild = async (coreCompiler, config) => {
|
|
1623
1660
|
if (config.flags.watch) {
|
|
1624
1661
|
// watch build
|
|
1625
1662
|
await taskWatch(coreCompiler, config);
|
|
@@ -1632,10 +1669,7 @@ const taskBuild = async (coreCompiler, config, sys) => {
|
|
|
1632
1669
|
const versionChecker = startCheckVersion(config, coreCompiler.version);
|
|
1633
1670
|
const compiler = await coreCompiler.createCompiler(config);
|
|
1634
1671
|
const results = await compiler.build();
|
|
1635
|
-
|
|
1636
|
-
if (sys) {
|
|
1637
|
-
await telemetryBuildFinishedAction(sys, config, coreCompiler, results);
|
|
1638
|
-
}
|
|
1672
|
+
await telemetryBuildFinishedAction(config.sys, config, coreCompiler, results);
|
|
1639
1673
|
await compiler.destroy();
|
|
1640
1674
|
if (results.hasError) {
|
|
1641
1675
|
exitCode = 1;
|
|
@@ -2001,10 +2035,7 @@ const taskHelp = async (flags, logger, sys) => {
|
|
|
2001
2035
|
${prompt} ${logger.green('stencil generate')} or ${logger.green('stencil g')}
|
|
2002
2036
|
|
|
2003
2037
|
`);
|
|
2004
|
-
|
|
2005
|
-
if (sys) {
|
|
2006
|
-
await taskTelemetry(flags, sys, logger);
|
|
2007
|
-
}
|
|
2038
|
+
await taskTelemetry(flags, sys, logger);
|
|
2008
2039
|
console.log(`
|
|
2009
2040
|
${logger.bold('Examples:')}
|
|
2010
2041
|
|
|
@@ -2202,7 +2233,7 @@ const BLUE = `#3498db`;
|
|
|
2202
2233
|
const run = async (init) => {
|
|
2203
2234
|
const { args, logger, sys } = init;
|
|
2204
2235
|
try {
|
|
2205
|
-
const flags = parseFlags(args
|
|
2236
|
+
const flags = parseFlags(args);
|
|
2206
2237
|
const task = flags.task;
|
|
2207
2238
|
if (flags.debug || flags.verbose) {
|
|
2208
2239
|
logger.setLevel('debug');
|
|
@@ -2214,7 +2245,7 @@ const run = async (init) => {
|
|
|
2214
2245
|
sys.applyGlobalPatch(sys.getCurrentDirectory());
|
|
2215
2246
|
}
|
|
2216
2247
|
if (task === 'help' || flags.help) {
|
|
2217
|
-
await taskHelp({ task: 'help', args }, logger, sys);
|
|
2248
|
+
await taskHelp(createConfigFlags({ task: 'help', args }), logger, sys);
|
|
2218
2249
|
return;
|
|
2219
2250
|
}
|
|
2220
2251
|
startupLog(logger, task);
|
|
@@ -2240,9 +2271,7 @@ const run = async (init) => {
|
|
|
2240
2271
|
startupLogVersion(logger, task, coreCompiler);
|
|
2241
2272
|
loadedCompilerLog(sys, logger, flags, coreCompiler);
|
|
2242
2273
|
if (task === 'info') {
|
|
2243
|
-
|
|
2244
|
-
await taskInfo(coreCompiler, sys, logger);
|
|
2245
|
-
});
|
|
2274
|
+
taskInfo(coreCompiler, sys, logger);
|
|
2246
2275
|
return;
|
|
2247
2276
|
}
|
|
2248
2277
|
const validated = await coreCompiler.loadConfig({
|
|
@@ -2275,14 +2304,27 @@ const run = async (init) => {
|
|
|
2275
2304
|
}
|
|
2276
2305
|
}
|
|
2277
2306
|
};
|
|
2307
|
+
/**
|
|
2308
|
+
* Run a specified task
|
|
2309
|
+
* @param coreCompiler an instance of a minimal, bootstrap compiler for running the specified task
|
|
2310
|
+
* @param config a configuration for the Stencil project to apply to the task run
|
|
2311
|
+
* @param task the task to run
|
|
2312
|
+
* @param sys the {@link CompilerSystem} for interacting with the operating system
|
|
2313
|
+
* @public
|
|
2314
|
+
*/
|
|
2278
2315
|
const runTask = async (coreCompiler, config, task, sys) => {
|
|
2279
|
-
var _a, _b;
|
|
2316
|
+
var _a, _b, _c;
|
|
2280
2317
|
const logger = (_a = config.logger) !== null && _a !== void 0 ? _a : createLogger();
|
|
2281
|
-
const strictConfig = {
|
|
2282
|
-
|
|
2318
|
+
const strictConfig = {
|
|
2319
|
+
...config,
|
|
2320
|
+
flags: createConfigFlags((_b = config.flags) !== null && _b !== void 0 ? _b : { task }),
|
|
2321
|
+
logger,
|
|
2322
|
+
outputTargets: (_c = config.outputTargets) !== null && _c !== void 0 ? _c : [],
|
|
2323
|
+
sys: sys !== null && sys !== void 0 ? sys : coreCompiler.createSystem({ logger }),
|
|
2324
|
+
};
|
|
2283
2325
|
switch (task) {
|
|
2284
2326
|
case 'build':
|
|
2285
|
-
await taskBuild(coreCompiler, strictConfig
|
|
2327
|
+
await taskBuild(coreCompiler, strictConfig);
|
|
2286
2328
|
break;
|
|
2287
2329
|
case 'docs':
|
|
2288
2330
|
await taskDocs(coreCompiler, strictConfig);
|
|
@@ -2301,10 +2343,7 @@ const runTask = async (coreCompiler, config, task, sys) => {
|
|
|
2301
2343
|
await taskServe(strictConfig);
|
|
2302
2344
|
break;
|
|
2303
2345
|
case 'telemetry':
|
|
2304
|
-
|
|
2305
|
-
if (sys) {
|
|
2306
|
-
await taskTelemetry(strictConfig.flags, sys, strictConfig.logger);
|
|
2307
|
-
}
|
|
2346
|
+
await taskTelemetry(strictConfig.flags, sys, strictConfig.logger);
|
|
2308
2347
|
break;
|
|
2309
2348
|
case 'test':
|
|
2310
2349
|
await taskTest(strictConfig);
|
package/cli/index.d.ts
CHANGED
|
@@ -12,5 +12,5 @@ export declare function run(init: CliInitOptions): Promise<void>;
|
|
|
12
12
|
* @param task The task command to run, such as `build`.
|
|
13
13
|
*/
|
|
14
14
|
export declare function runTask(coreCompiler: any, config: Config, task: TaskCommand): Promise<void>;
|
|
15
|
-
export declare function parseFlags(args: string[],
|
|
15
|
+
export declare function parseFlags(args: string[], _sys?: CompilerSystem): ConfigFlags;
|
|
16
16
|
export { CompilerSystem, Config, ConfigFlags, Logger, TaskCommand };
|