@stencil/core 2.15.1 → 2.15.2
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/index.cjs +83 -13
- package/cli/index.js +83 -13
- package/cli/package.json +1 -1
- package/compiler/package.json +1 -1
- package/compiler/stencil.js +192 -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 +39 -3
- package/internal/stencil-public-compiler.d.ts +3 -1
- package/internal/testing/package.json +1 -1
- package/mock-doc/index.cjs +1 -1
- package/mock-doc/index.js +1 -1
- package/mock-doc/package.json +1 -1
- package/package.json +1 -3
- package/screenshot/package.json +1 -1
- package/sys/node/autoprefixer.js +1 -1
- package/sys/node/index.js +2038 -1330
- package/sys/node/package.json +1 -1
- package/sys/node/worker.js +1 -1
- package/testing/index.js +2 -2
- package/testing/package.json +1 -1
package/cli/index.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
Stencil CLI (CommonJS) v2.15.
|
|
2
|
+
Stencil CLI (CommonJS) v2.15.2 | MIT Licensed | https://stenciljs.com
|
|
3
3
|
*/
|
|
4
4
|
'use strict';
|
|
5
5
|
|
|
@@ -530,7 +530,7 @@ const getNpmConfigEnvArgs = (sys) => {
|
|
|
530
530
|
const dependencies = [
|
|
531
531
|
{
|
|
532
532
|
name: "@stencil/core",
|
|
533
|
-
version: "2.15.
|
|
533
|
+
version: "2.15.2",
|
|
534
534
|
main: "compiler/stencil.js",
|
|
535
535
|
resources: [
|
|
536
536
|
"package.json",
|
|
@@ -1307,7 +1307,14 @@ const IS_NODE_ENV = typeof global !== 'undefined' &&
|
|
|
1307
1307
|
(!global.origin || typeof global.origin !== 'string');
|
|
1308
1308
|
|
|
1309
1309
|
/**
|
|
1310
|
-
* Task to generate component boilerplate.
|
|
1310
|
+
* Task to generate component boilerplate and write it to disk. This task can
|
|
1311
|
+
* cause the program to exit with an error under various circumstances, such as
|
|
1312
|
+
* being called in an inappropriate place, being asked to overwrite files that
|
|
1313
|
+
* already exist, etc.
|
|
1314
|
+
*
|
|
1315
|
+
* @param coreCompiler the CoreCompiler we're using currently, here we're
|
|
1316
|
+
* mainly accessing the `path` module
|
|
1317
|
+
* @param config the user-supplied config, which we need here to access `.sys`.
|
|
1311
1318
|
*/
|
|
1312
1319
|
const taskGenerate = async (coreCompiler, config) => {
|
|
1313
1320
|
if (!IS_NODE_ENV) {
|
|
@@ -1337,10 +1344,16 @@ const taskGenerate = async (coreCompiler, config) => {
|
|
|
1337
1344
|
const testFolder = extensionsToGenerate.some(isTest) ? 'test' : '';
|
|
1338
1345
|
const outDir = path.join(absoluteSrcDir, 'components', dir, componentName);
|
|
1339
1346
|
await config.sys.createDir(path.join(outDir, testFolder), { recursive: true });
|
|
1340
|
-
const
|
|
1347
|
+
const filesToGenerate = extensionsToGenerate.map((extension) => ({
|
|
1348
|
+
extension,
|
|
1349
|
+
path: getFilepathForFile(coreCompiler, outDir, componentName, extension),
|
|
1350
|
+
}));
|
|
1351
|
+
await checkForOverwrite(filesToGenerate, config);
|
|
1352
|
+
const writtenFiles = await Promise.all(filesToGenerate.map((file) => getBoilerplateAndWriteFile(config, componentName, extensionsToGenerate.includes('css'), file))).catch((error) => config.logger.error(error));
|
|
1341
1353
|
if (!writtenFiles) {
|
|
1342
1354
|
return config.sys.exit(1);
|
|
1343
1355
|
}
|
|
1356
|
+
// TODO(STENCIL-424): Investigate moving these console.log calls to config.logger.info
|
|
1344
1357
|
console.log();
|
|
1345
1358
|
console.log(`${config.logger.gray('$')} stencil generate ${input}`);
|
|
1346
1359
|
console.log();
|
|
@@ -1350,6 +1363,9 @@ const taskGenerate = async (coreCompiler, config) => {
|
|
|
1350
1363
|
};
|
|
1351
1364
|
/**
|
|
1352
1365
|
* Show a checkbox prompt to select the files to be generated.
|
|
1366
|
+
*
|
|
1367
|
+
* @returns a read-only array of `GenerableExtension`, the extensions that the user has decided
|
|
1368
|
+
* to generate
|
|
1353
1369
|
*/
|
|
1354
1370
|
const chooseFilesToGenerate = async () => {
|
|
1355
1371
|
const { prompt } = await Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require('../sys/node/prompts.js')); });
|
|
@@ -1365,22 +1381,76 @@ const chooseFilesToGenerate = async () => {
|
|
|
1365
1381
|
})).filesToGenerate;
|
|
1366
1382
|
};
|
|
1367
1383
|
/**
|
|
1368
|
-
* Get a
|
|
1384
|
+
* Get a filepath for a file we want to generate!
|
|
1385
|
+
*
|
|
1386
|
+
* The filepath for a given file depends on the path, the user-supplied
|
|
1387
|
+
* component name, the extension, and whether we're inside of a test directory.
|
|
1388
|
+
*
|
|
1389
|
+
* @param coreCompiler the compiler we're using, here to acces the `.path` module
|
|
1390
|
+
* @param path path to where we're going to generate the component
|
|
1391
|
+
* @param componentName the user-supplied name for the generated component
|
|
1392
|
+
* @param extension the file extension
|
|
1393
|
+
* @returns the full filepath to the component (with a possible `test` directory
|
|
1394
|
+
* added)
|
|
1395
|
+
*/
|
|
1396
|
+
const getFilepathForFile = (coreCompiler, path, componentName, extension) => isTest(extension)
|
|
1397
|
+
? coreCompiler.path.join(path, 'test', `${componentName}.${extension}`)
|
|
1398
|
+
: coreCompiler.path.join(path, `${componentName}.${extension}`);
|
|
1399
|
+
/**
|
|
1400
|
+
* Get the boilerplate for a file and write it to disk
|
|
1401
|
+
*
|
|
1402
|
+
* @param config the current config, needed for file operations
|
|
1403
|
+
* @param componentName the component name (user-supplied)
|
|
1404
|
+
* @param withCss are we generating CSS?
|
|
1405
|
+
* @param file the file we want to write
|
|
1406
|
+
* @returns a `Promise<string>` which holds the full filepath we've written to,
|
|
1407
|
+
* used to print out a little summary of our activity to the user.
|
|
1408
|
+
*/
|
|
1409
|
+
const getBoilerplateAndWriteFile = async (config, componentName, withCss, file) => {
|
|
1410
|
+
const boilerplate = getBoilerplateByExtension(componentName, file.extension, withCss);
|
|
1411
|
+
await config.sys.writeFile(file.path, boilerplate);
|
|
1412
|
+
return file.path;
|
|
1413
|
+
};
|
|
1414
|
+
/**
|
|
1415
|
+
* Check to see if any of the files we plan to write already exist and would
|
|
1416
|
+
* therefore be overwritten if we proceed, because we'd like to not overwrite
|
|
1417
|
+
* people's code!
|
|
1418
|
+
*
|
|
1419
|
+
* This function will check all the filepaths and if it finds any files log an
|
|
1420
|
+
* error and exit with an error code. If it doesn't find anything it will just
|
|
1421
|
+
* peacefully return `Promise<void>`.
|
|
1422
|
+
*
|
|
1423
|
+
* @param files the files we want to check
|
|
1424
|
+
* @param config the Config object, used here to get access to `sys.readFile`
|
|
1369
1425
|
*/
|
|
1370
|
-
const
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1426
|
+
const checkForOverwrite = async (files, config) => {
|
|
1427
|
+
const alreadyPresent = [];
|
|
1428
|
+
await Promise.all(files.map(async ({ path }) => {
|
|
1429
|
+
if ((await config.sys.readFile(path)) !== undefined) {
|
|
1430
|
+
alreadyPresent.push(path);
|
|
1431
|
+
}
|
|
1432
|
+
}));
|
|
1433
|
+
if (alreadyPresent.length > 0) {
|
|
1434
|
+
config.logger.error('Generating code would overwrite the following files:', ...alreadyPresent.map((path) => '\t' + path));
|
|
1435
|
+
await config.sys.exit(1);
|
|
1436
|
+
}
|
|
1378
1437
|
};
|
|
1438
|
+
/**
|
|
1439
|
+
* Check if an extension is for a test
|
|
1440
|
+
*
|
|
1441
|
+
* @param extension the extension we want to check
|
|
1442
|
+
* @returns a boolean indicating whether or not its a test
|
|
1443
|
+
*/
|
|
1379
1444
|
const isTest = (extension) => {
|
|
1380
1445
|
return extension === 'e2e.ts' || extension === 'spec.tsx';
|
|
1381
1446
|
};
|
|
1382
1447
|
/**
|
|
1383
1448
|
* Get the boilerplate for a file by its extension.
|
|
1449
|
+
*
|
|
1450
|
+
* @param tagName the name of the component we're generating
|
|
1451
|
+
* @param extension the file extension we want boilerplate for (.css, tsx, etc)
|
|
1452
|
+
* @param withCss a boolean indicating whether we're generating a CSS file
|
|
1453
|
+
* @returns a string container the file boilerplate for the supplied extension
|
|
1384
1454
|
*/
|
|
1385
1455
|
const getBoilerplateByExtension = (tagName, extension, withCss) => {
|
|
1386
1456
|
switch (extension) {
|
package/cli/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
Stencil CLI v2.15.
|
|
2
|
+
Stencil CLI v2.15.2 | MIT Licensed | https://stenciljs.com
|
|
3
3
|
*/
|
|
4
4
|
const toLowerCase = (str) => str.toLowerCase();
|
|
5
5
|
const dashToPascalCase = (str) => toLowerCase(str)
|
|
@@ -506,7 +506,7 @@ const getNpmConfigEnvArgs = (sys) => {
|
|
|
506
506
|
const dependencies = [
|
|
507
507
|
{
|
|
508
508
|
name: "@stencil/core",
|
|
509
|
-
version: "2.15.
|
|
509
|
+
version: "2.15.2",
|
|
510
510
|
main: "compiler/stencil.js",
|
|
511
511
|
resources: [
|
|
512
512
|
"package.json",
|
|
@@ -1283,7 +1283,14 @@ const IS_NODE_ENV = typeof global !== 'undefined' &&
|
|
|
1283
1283
|
(!global.origin || typeof global.origin !== 'string');
|
|
1284
1284
|
|
|
1285
1285
|
/**
|
|
1286
|
-
* Task to generate component boilerplate.
|
|
1286
|
+
* Task to generate component boilerplate and write it to disk. This task can
|
|
1287
|
+
* cause the program to exit with an error under various circumstances, such as
|
|
1288
|
+
* being called in an inappropriate place, being asked to overwrite files that
|
|
1289
|
+
* already exist, etc.
|
|
1290
|
+
*
|
|
1291
|
+
* @param coreCompiler the CoreCompiler we're using currently, here we're
|
|
1292
|
+
* mainly accessing the `path` module
|
|
1293
|
+
* @param config the user-supplied config, which we need here to access `.sys`.
|
|
1287
1294
|
*/
|
|
1288
1295
|
const taskGenerate = async (coreCompiler, config) => {
|
|
1289
1296
|
if (!IS_NODE_ENV) {
|
|
@@ -1313,10 +1320,16 @@ const taskGenerate = async (coreCompiler, config) => {
|
|
|
1313
1320
|
const testFolder = extensionsToGenerate.some(isTest) ? 'test' : '';
|
|
1314
1321
|
const outDir = path.join(absoluteSrcDir, 'components', dir, componentName);
|
|
1315
1322
|
await config.sys.createDir(path.join(outDir, testFolder), { recursive: true });
|
|
1316
|
-
const
|
|
1323
|
+
const filesToGenerate = extensionsToGenerate.map((extension) => ({
|
|
1324
|
+
extension,
|
|
1325
|
+
path: getFilepathForFile(coreCompiler, outDir, componentName, extension),
|
|
1326
|
+
}));
|
|
1327
|
+
await checkForOverwrite(filesToGenerate, config);
|
|
1328
|
+
const writtenFiles = await Promise.all(filesToGenerate.map((file) => getBoilerplateAndWriteFile(config, componentName, extensionsToGenerate.includes('css'), file))).catch((error) => config.logger.error(error));
|
|
1317
1329
|
if (!writtenFiles) {
|
|
1318
1330
|
return config.sys.exit(1);
|
|
1319
1331
|
}
|
|
1332
|
+
// TODO(STENCIL-424): Investigate moving these console.log calls to config.logger.info
|
|
1320
1333
|
console.log();
|
|
1321
1334
|
console.log(`${config.logger.gray('$')} stencil generate ${input}`);
|
|
1322
1335
|
console.log();
|
|
@@ -1326,6 +1339,9 @@ const taskGenerate = async (coreCompiler, config) => {
|
|
|
1326
1339
|
};
|
|
1327
1340
|
/**
|
|
1328
1341
|
* Show a checkbox prompt to select the files to be generated.
|
|
1342
|
+
*
|
|
1343
|
+
* @returns a read-only array of `GenerableExtension`, the extensions that the user has decided
|
|
1344
|
+
* to generate
|
|
1329
1345
|
*/
|
|
1330
1346
|
const chooseFilesToGenerate = async () => {
|
|
1331
1347
|
const { prompt } = await import('../sys/node/prompts.js');
|
|
@@ -1341,22 +1357,76 @@ const chooseFilesToGenerate = async () => {
|
|
|
1341
1357
|
})).filesToGenerate;
|
|
1342
1358
|
};
|
|
1343
1359
|
/**
|
|
1344
|
-
* Get a
|
|
1360
|
+
* Get a filepath for a file we want to generate!
|
|
1361
|
+
*
|
|
1362
|
+
* The filepath for a given file depends on the path, the user-supplied
|
|
1363
|
+
* component name, the extension, and whether we're inside of a test directory.
|
|
1364
|
+
*
|
|
1365
|
+
* @param coreCompiler the compiler we're using, here to acces the `.path` module
|
|
1366
|
+
* @param path path to where we're going to generate the component
|
|
1367
|
+
* @param componentName the user-supplied name for the generated component
|
|
1368
|
+
* @param extension the file extension
|
|
1369
|
+
* @returns the full filepath to the component (with a possible `test` directory
|
|
1370
|
+
* added)
|
|
1371
|
+
*/
|
|
1372
|
+
const getFilepathForFile = (coreCompiler, path, componentName, extension) => isTest(extension)
|
|
1373
|
+
? coreCompiler.path.join(path, 'test', `${componentName}.${extension}`)
|
|
1374
|
+
: coreCompiler.path.join(path, `${componentName}.${extension}`);
|
|
1375
|
+
/**
|
|
1376
|
+
* Get the boilerplate for a file and write it to disk
|
|
1377
|
+
*
|
|
1378
|
+
* @param config the current config, needed for file operations
|
|
1379
|
+
* @param componentName the component name (user-supplied)
|
|
1380
|
+
* @param withCss are we generating CSS?
|
|
1381
|
+
* @param file the file we want to write
|
|
1382
|
+
* @returns a `Promise<string>` which holds the full filepath we've written to,
|
|
1383
|
+
* used to print out a little summary of our activity to the user.
|
|
1384
|
+
*/
|
|
1385
|
+
const getBoilerplateAndWriteFile = async (config, componentName, withCss, file) => {
|
|
1386
|
+
const boilerplate = getBoilerplateByExtension(componentName, file.extension, withCss);
|
|
1387
|
+
await config.sys.writeFile(file.path, boilerplate);
|
|
1388
|
+
return file.path;
|
|
1389
|
+
};
|
|
1390
|
+
/**
|
|
1391
|
+
* Check to see if any of the files we plan to write already exist and would
|
|
1392
|
+
* therefore be overwritten if we proceed, because we'd like to not overwrite
|
|
1393
|
+
* people's code!
|
|
1394
|
+
*
|
|
1395
|
+
* This function will check all the filepaths and if it finds any files log an
|
|
1396
|
+
* error and exit with an error code. If it doesn't find anything it will just
|
|
1397
|
+
* peacefully return `Promise<void>`.
|
|
1398
|
+
*
|
|
1399
|
+
* @param files the files we want to check
|
|
1400
|
+
* @param config the Config object, used here to get access to `sys.readFile`
|
|
1345
1401
|
*/
|
|
1346
|
-
const
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1402
|
+
const checkForOverwrite = async (files, config) => {
|
|
1403
|
+
const alreadyPresent = [];
|
|
1404
|
+
await Promise.all(files.map(async ({ path }) => {
|
|
1405
|
+
if ((await config.sys.readFile(path)) !== undefined) {
|
|
1406
|
+
alreadyPresent.push(path);
|
|
1407
|
+
}
|
|
1408
|
+
}));
|
|
1409
|
+
if (alreadyPresent.length > 0) {
|
|
1410
|
+
config.logger.error('Generating code would overwrite the following files:', ...alreadyPresent.map((path) => '\t' + path));
|
|
1411
|
+
await config.sys.exit(1);
|
|
1412
|
+
}
|
|
1354
1413
|
};
|
|
1414
|
+
/**
|
|
1415
|
+
* Check if an extension is for a test
|
|
1416
|
+
*
|
|
1417
|
+
* @param extension the extension we want to check
|
|
1418
|
+
* @returns a boolean indicating whether or not its a test
|
|
1419
|
+
*/
|
|
1355
1420
|
const isTest = (extension) => {
|
|
1356
1421
|
return extension === 'e2e.ts' || extension === 'spec.tsx';
|
|
1357
1422
|
};
|
|
1358
1423
|
/**
|
|
1359
1424
|
* Get the boilerplate for a file by its extension.
|
|
1425
|
+
*
|
|
1426
|
+
* @param tagName the name of the component we're generating
|
|
1427
|
+
* @param extension the file extension we want boilerplate for (.css, tsx, etc)
|
|
1428
|
+
* @param withCss a boolean indicating whether we're generating a CSS file
|
|
1429
|
+
* @returns a string container the file boilerplate for the supplied extension
|
|
1360
1430
|
*/
|
|
1361
1431
|
const getBoilerplateByExtension = (tagName, extension, withCss) => {
|
|
1362
1432
|
switch (extension) {
|
package/cli/package.json
CHANGED