@stencil/core 2.20.0 → 3.0.0-alpha.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/bin/stencil +3 -3
- package/cli/index.cjs +3 -5
- package/cli/index.d.ts +3 -3
- package/cli/index.js +3 -5
- package/cli/package.json +1 -1
- package/compiler/package.json +1 -1
- package/compiler/stencil.js +190 -308
- 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 +1 -0
- package/internal/stencil-public-compiler.d.ts +31 -17
- package/internal/stencil-public-runtime.d.ts +12 -12
- 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 +3 -3
- package/screenshot/package.json +1 -1
- package/sys/node/index.js +11 -11
- package/sys/node/package.json +1 -1
- package/sys/node/worker.js +1 -1
- package/testing/index.js +597 -410
- package/testing/package.json +1 -1
- package/testing/puppeteer/puppeteer-declarations.d.ts +1 -27
- package/testing/puppeteer/puppeteer-element.d.ts +3 -3
package/compiler/stencil.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
Stencil Compiler
|
|
2
|
+
Stencil Compiler v3.0.0-alpha.1 | MIT Licensed | https://stenciljs.com
|
|
3
3
|
*/
|
|
4
4
|
(function(exports) {
|
|
5
5
|
'use strict';
|
|
@@ -34,7 +34,7 @@ if (!process.platform) {
|
|
|
34
34
|
process.platform = 'stencil';
|
|
35
35
|
}
|
|
36
36
|
if (!process.version) {
|
|
37
|
-
process.version = '
|
|
37
|
+
process.version = 'v14.0.0';
|
|
38
38
|
}
|
|
39
39
|
process.browser = !!globalThis.location;
|
|
40
40
|
|
|
@@ -2039,7 +2039,7 @@ const process$3 = /*#__PURE__*/Object.assign(/*#__PURE__*/Object.create(null), p
|
|
|
2039
2039
|
'default': process_1
|
|
2040
2040
|
});
|
|
2041
2041
|
|
|
2042
|
-
const buildId = '
|
|
2042
|
+
const buildId = '20221205181830';
|
|
2043
2043
|
const minfyJsId = 'terser5.6.1_7';
|
|
2044
2044
|
const optimizeCssId = 'autoprefixer10.4.13_postcss8.4.19_7';
|
|
2045
2045
|
const parse5Version = '7.1.2';
|
|
@@ -2047,8 +2047,8 @@ const rollupVersion = '2.42.3';
|
|
|
2047
2047
|
const sizzleVersion = '2.42.3';
|
|
2048
2048
|
const terserVersion = '5.6.1';
|
|
2049
2049
|
const typescriptVersion = '4.8.4';
|
|
2050
|
-
const vermoji = '
|
|
2051
|
-
const version$3 = '
|
|
2050
|
+
const vermoji = '🎷';
|
|
2051
|
+
const version$3 = '3.0.0-alpha.1';
|
|
2052
2052
|
const versions = {
|
|
2053
2053
|
stencil: version$3,
|
|
2054
2054
|
parse5: parse5Version,
|
|
@@ -4149,8 +4149,8 @@ const createSystem = (c) => {
|
|
|
4149
4149
|
const logger = (_a = c === null || c === void 0 ? void 0 : c.logger) !== null && _a !== void 0 ? _a : createLogger();
|
|
4150
4150
|
const items = new Map();
|
|
4151
4151
|
const destroys = new Set();
|
|
4152
|
-
const
|
|
4153
|
-
const
|
|
4152
|
+
const addDestroy = (cb) => destroys.add(cb);
|
|
4153
|
+
const removeDestroy = (cb) => destroys.delete(cb);
|
|
4154
4154
|
const events = buildEvents();
|
|
4155
4155
|
const hardwareConcurrency = (IS_BROWSER_ENV && navigator.hardwareConcurrency) || 1;
|
|
4156
4156
|
const destroy = async () => {
|
|
@@ -4377,10 +4377,10 @@ const createSystem = (c) => {
|
|
|
4377
4377
|
removedFiles: [],
|
|
4378
4378
|
error: null,
|
|
4379
4379
|
};
|
|
4380
|
-
|
|
4380
|
+
removeDirSyncRecursive(p, opts, results);
|
|
4381
4381
|
return results;
|
|
4382
4382
|
};
|
|
4383
|
-
const
|
|
4383
|
+
const removeDirSyncRecursive = (p, opts, results) => {
|
|
4384
4384
|
if (!results.error) {
|
|
4385
4385
|
p = normalize(p);
|
|
4386
4386
|
const dirItemPaths = readDirSync(p);
|
|
@@ -4389,7 +4389,7 @@ const createSystem = (c) => {
|
|
|
4389
4389
|
const item = items.get(dirItemPath);
|
|
4390
4390
|
if (item) {
|
|
4391
4391
|
if (item.isDirectory) {
|
|
4392
|
-
|
|
4392
|
+
removeDirSyncRecursive(dirItemPath, opts, results);
|
|
4393
4393
|
}
|
|
4394
4394
|
else if (item.isFile) {
|
|
4395
4395
|
const removeFileResults = removeFileSync(dirItemPath);
|
|
@@ -4469,7 +4469,7 @@ const createSystem = (c) => {
|
|
|
4469
4469
|
}
|
|
4470
4470
|
}
|
|
4471
4471
|
};
|
|
4472
|
-
|
|
4472
|
+
addDestroy(close);
|
|
4473
4473
|
if (item) {
|
|
4474
4474
|
item.isDirectory = true;
|
|
4475
4475
|
item.isFile = false;
|
|
@@ -4488,7 +4488,7 @@ const createSystem = (c) => {
|
|
|
4488
4488
|
}
|
|
4489
4489
|
return {
|
|
4490
4490
|
close() {
|
|
4491
|
-
|
|
4491
|
+
removeDestroy(close);
|
|
4492
4492
|
close();
|
|
4493
4493
|
},
|
|
4494
4494
|
};
|
|
@@ -4505,7 +4505,7 @@ const createSystem = (c) => {
|
|
|
4505
4505
|
}
|
|
4506
4506
|
}
|
|
4507
4507
|
};
|
|
4508
|
-
|
|
4508
|
+
addDestroy(close);
|
|
4509
4509
|
if (item) {
|
|
4510
4510
|
item.isDirectory = false;
|
|
4511
4511
|
item.isFile = true;
|
|
@@ -4524,7 +4524,7 @@ const createSystem = (c) => {
|
|
|
4524
4524
|
}
|
|
4525
4525
|
return {
|
|
4526
4526
|
close() {
|
|
4527
|
-
|
|
4527
|
+
removeDestroy(close);
|
|
4528
4528
|
close();
|
|
4529
4529
|
},
|
|
4530
4530
|
};
|
|
@@ -4625,7 +4625,7 @@ const createSystem = (c) => {
|
|
|
4625
4625
|
events,
|
|
4626
4626
|
access,
|
|
4627
4627
|
accessSync,
|
|
4628
|
-
|
|
4628
|
+
addDestroy,
|
|
4629
4629
|
copyFile,
|
|
4630
4630
|
createDir,
|
|
4631
4631
|
createDirSync,
|
|
@@ -4650,7 +4650,7 @@ const createSystem = (c) => {
|
|
|
4650
4650
|
readFileSync,
|
|
4651
4651
|
realpath,
|
|
4652
4652
|
realpathSync,
|
|
4653
|
-
|
|
4653
|
+
removeDestroy,
|
|
4654
4654
|
rename,
|
|
4655
4655
|
fetch,
|
|
4656
4656
|
resolvePath,
|
|
@@ -12315,15 +12315,15 @@ const relativeImport = (pathFrom, pathTo, ext, addPrefix = true) => {
|
|
|
12315
12315
|
}
|
|
12316
12316
|
return normalizePath$1(`${relativePath}/${basename(pathTo, ext)}`);
|
|
12317
12317
|
};
|
|
12318
|
-
const getComponentsDtsSrcFilePath = (config) => join(config.srcDir, GENERATED_DTS
|
|
12319
|
-
const getComponentsDtsTypesFilePath = (outputTarget) => join(outputTarget.typesDir, GENERATED_DTS
|
|
12318
|
+
const getComponentsDtsSrcFilePath = (config) => join(config.srcDir, GENERATED_DTS);
|
|
12319
|
+
const getComponentsDtsTypesFilePath = (outputTarget) => join(outputTarget.typesDir, GENERATED_DTS);
|
|
12320
12320
|
const isOutputTargetDist = (o) => o.type === DIST;
|
|
12321
12321
|
const isOutputTargetDistCollection = (o) => o.type === DIST_COLLECTION;
|
|
12322
12322
|
const isOutputTargetDistCustomElements = (o) => o.type === DIST_CUSTOM_ELEMENTS;
|
|
12323
|
+
// TODO(STENCIL-561): fully delete dist-custom-elements-bundle code
|
|
12323
12324
|
const isOutputTargetDistCustomElementsBundle = (o) => o.type === DIST_CUSTOM_ELEMENTS_BUNDLE;
|
|
12324
12325
|
const isOutputTargetCopy = (o) => o.type === COPY;
|
|
12325
12326
|
const isOutputTargetDistLazy = (o) => o.type === DIST_LAZY;
|
|
12326
|
-
const isOutputTargetAngular = (o) => o.type === ANGULAR;
|
|
12327
12327
|
const isOutputTargetDistLazyLoader = (o) => o.type === DIST_LAZY_LOADER;
|
|
12328
12328
|
const isOutputTargetDistGlobalStyles = (o) => o.type === DIST_GLOBAL_STYLES;
|
|
12329
12329
|
const isOutputTargetHydrate = (o) => o.type === DIST_HYDRATE_SCRIPT;
|
|
@@ -12337,12 +12337,12 @@ const isOutputTargetWww = (o) => o.type === WWW;
|
|
|
12337
12337
|
const isOutputTargetStats = (o) => o.type === STATS;
|
|
12338
12338
|
const isOutputTargetDistTypes = (o) => o.type === DIST_TYPES;
|
|
12339
12339
|
const getComponentsFromModules = (moduleFiles) => sortBy(flatOne(moduleFiles.map((m) => m.cmps)), (c) => c.tagName);
|
|
12340
|
-
const ANGULAR = 'angular';
|
|
12341
12340
|
const COPY = 'copy';
|
|
12342
12341
|
const CUSTOM = 'custom';
|
|
12343
12342
|
const DIST = 'dist';
|
|
12344
12343
|
const DIST_COLLECTION = 'dist-collection';
|
|
12345
12344
|
const DIST_CUSTOM_ELEMENTS = 'dist-custom-elements';
|
|
12345
|
+
// TODO(STENCIL-561): fully delete dist-custom-elements-bundle code
|
|
12346
12346
|
const DIST_CUSTOM_ELEMENTS_BUNDLE = 'dist-custom-elements-bundle';
|
|
12347
12347
|
const DIST_TYPES = 'dist-types';
|
|
12348
12348
|
const DIST_HYDRATE_SCRIPT = 'dist-hydrate-script';
|
|
@@ -12369,7 +12369,6 @@ const VALID_CONFIG_OUTPUT_TARGETS = [
|
|
|
12369
12369
|
DIST,
|
|
12370
12370
|
DIST_COLLECTION,
|
|
12371
12371
|
DIST_CUSTOM_ELEMENTS,
|
|
12372
|
-
DIST_CUSTOM_ELEMENTS_BUNDLE,
|
|
12373
12372
|
DIST_LAZY,
|
|
12374
12373
|
DIST_HYDRATE_SCRIPT,
|
|
12375
12374
|
// DOCS
|
|
@@ -12378,7 +12377,6 @@ const VALID_CONFIG_OUTPUT_TARGETS = [
|
|
|
12378
12377
|
DOCS_VSCODE,
|
|
12379
12378
|
DOCS_CUSTOM,
|
|
12380
12379
|
// MISC
|
|
12381
|
-
ANGULAR,
|
|
12382
12380
|
COPY,
|
|
12383
12381
|
CUSTOM,
|
|
12384
12382
|
STATS,
|
|
@@ -12397,7 +12395,7 @@ function isValidConfigOutputTarget(targetType) {
|
|
|
12397
12395
|
// see microsoft/TypeScript#31018 for some discussion of this
|
|
12398
12396
|
return VALID_CONFIG_OUTPUT_TARGETS.includes(targetType);
|
|
12399
12397
|
}
|
|
12400
|
-
const GENERATED_DTS
|
|
12398
|
+
const GENERATED_DTS = 'components.d.ts';
|
|
12401
12399
|
|
|
12402
12400
|
const getTsOptionsToExtend = (config) => {
|
|
12403
12401
|
const tsOptions = {
|
|
@@ -12473,7 +12471,7 @@ const createTsBuildProgram = async (config, buildCallback) => {
|
|
|
12473
12471
|
clearInterval(timeoutId);
|
|
12474
12472
|
},
|
|
12475
12473
|
};
|
|
12476
|
-
config.sys.
|
|
12474
|
+
config.sys.addDestroy(() => tsWatchSys.clearTimeout(currentBuildTimeoutId));
|
|
12477
12475
|
/**
|
|
12478
12476
|
* Create a {@link ts.WatchCompilerHost}. A CompilerHost allows a {@link ts.Program} to interact with the
|
|
12479
12477
|
* {@link ts.System}, by acting as an intermediary:
|
|
@@ -18972,6 +18970,15 @@ const getTypeReferenceLocation = (typeName, tsNode) => {
|
|
|
18972
18970
|
if (isExported) {
|
|
18973
18971
|
return {
|
|
18974
18972
|
location: 'local',
|
|
18973
|
+
// If this is a local import, we know the path to the type
|
|
18974
|
+
// is the same as the current source file path
|
|
18975
|
+
//
|
|
18976
|
+
// We need to explicitly include the path here because
|
|
18977
|
+
// future logic for generating app types will use this resolved reference
|
|
18978
|
+
// to ensure that type name collisions do no occur in the output type
|
|
18979
|
+
// declaration file. If this path is omitted, the correct aliased type names
|
|
18980
|
+
// will not be used for component event definitions
|
|
18981
|
+
path: sourceFileObj.fileName,
|
|
18975
18982
|
};
|
|
18976
18983
|
}
|
|
18977
18984
|
// This is most likely a global type, if it is a local that is not exported then typescript will inform the dev
|
|
@@ -55031,7 +55038,7 @@ const addDefineCustomElementFunctions = (compilerCtx, components, outputTarget)
|
|
|
55031
55038
|
caseStatements.push(createCustomElementsDefineCase(principalComponent.tagName, customElementsDefineCallExpression));
|
|
55032
55039
|
setupComponentDependencies(moduleFile, components, newStatements, caseStatements, tagNames);
|
|
55033
55040
|
addDefineCustomElementFunction(tagNames, newStatements, caseStatements);
|
|
55034
|
-
if (outputTarget.
|
|
55041
|
+
if (outputTarget.customElementsExportBehavior === 'auto-define-custom-elements') {
|
|
55035
55042
|
const conditionalDefineCustomElementCall = createAutoDefinitionExpression(principalComponent.componentClassName);
|
|
55036
55043
|
newStatements.push(conditionalDefineCustomElementCall);
|
|
55037
55044
|
}
|
|
@@ -56131,9 +56138,7 @@ const getBundleOptions = (config, buildCtx, compilerCtx, outputTarget) => ({
|
|
|
56131
56138
|
// @see {@link https://rollupjs.org/guide/en/#conventions} for more info.
|
|
56132
56139
|
index: '\0core',
|
|
56133
56140
|
},
|
|
56134
|
-
loader: {
|
|
56135
|
-
'\0core': generateEntryPoint$1(outputTarget),
|
|
56136
|
-
},
|
|
56141
|
+
loader: {},
|
|
56137
56142
|
inlineDynamicImports: outputTarget.inlineDynamicImports,
|
|
56138
56143
|
preserveEntrySignatures: 'allow-extension',
|
|
56139
56144
|
});
|
|
@@ -56150,7 +56155,7 @@ const getBundleOptions = (config, buildCtx, compilerCtx, outputTarget) => ({
|
|
|
56150
56155
|
const bundleCustomElements$1 = async (config, compilerCtx, buildCtx, outputTarget) => {
|
|
56151
56156
|
try {
|
|
56152
56157
|
const bundleOpts = getBundleOptions(config, buildCtx, compilerCtx, outputTarget);
|
|
56153
|
-
addCustomElementInputs(buildCtx, bundleOpts);
|
|
56158
|
+
addCustomElementInputs(buildCtx, bundleOpts, outputTarget);
|
|
56154
56159
|
const build = await bundleOutput(config, compilerCtx, buildCtx, bundleOpts);
|
|
56155
56160
|
if (build) {
|
|
56156
56161
|
const rollupOutput = await build.generate({
|
|
@@ -56212,11 +56217,17 @@ const bundleCustomElements$1 = async (config, compilerCtx, buildCtx, outputTarge
|
|
|
56212
56217
|
* Create the virtual modules/input modules for the `dist-custom-elements` output target.
|
|
56213
56218
|
* @param buildCtx the context for the current build
|
|
56214
56219
|
* @param bundleOpts the bundle options to store the virtual modules under. acts as an output parameter
|
|
56220
|
+
* @param outputTarget the configuration for the custom element output target
|
|
56215
56221
|
*/
|
|
56216
|
-
const addCustomElementInputs = (buildCtx, bundleOpts) => {
|
|
56222
|
+
const addCustomElementInputs = (buildCtx, bundleOpts, outputTarget) => {
|
|
56217
56223
|
const components = buildCtx.components;
|
|
56218
|
-
//
|
|
56224
|
+
// An array to store the imports of these modules that we're going to add to our entry chunk
|
|
56219
56225
|
const indexImports = [];
|
|
56226
|
+
// An array to store the export declarations that we're going to add to our entry chunk
|
|
56227
|
+
const indexExports = [];
|
|
56228
|
+
// An array to store the exported component names that will be used for the `defineCustomElements`
|
|
56229
|
+
// function on the `bundle` export behavior option
|
|
56230
|
+
const exportNames = [];
|
|
56220
56231
|
components.forEach((cmp) => {
|
|
56221
56232
|
const exp = [];
|
|
56222
56233
|
const exportName = dashToPascalCase$1(cmp.tagName);
|
|
@@ -56225,7 +56236,7 @@ const addCustomElementInputs = (buildCtx, bundleOpts) => {
|
|
|
56225
56236
|
const coreKey = `\0${exportName}`;
|
|
56226
56237
|
if (cmp.isPlain) {
|
|
56227
56238
|
exp.push(`export { ${importName} as ${exportName} } from '${cmp.sourceFilePath}';`);
|
|
56228
|
-
|
|
56239
|
+
indexExports.push(`export { {${exportName} } from '${coreKey}';`);
|
|
56229
56240
|
}
|
|
56230
56241
|
else {
|
|
56231
56242
|
// the `importName` may collide with the `exportName`, alias it just in case it does with `importAs`
|
|
@@ -56238,25 +56249,55 @@ const addCustomElementInputs = (buildCtx, bundleOpts) => {
|
|
|
56238
56249
|
// correct virtual module, if we instead referenced, for instance,
|
|
56239
56250
|
// `cmp.sourceFilePath`, we would end up with duplicated modules in our
|
|
56240
56251
|
// output.
|
|
56241
|
-
|
|
56252
|
+
indexExports.push(`export { ${exportName}, defineCustomElement as defineCustomElement${exportName} } from '${coreKey}';`);
|
|
56242
56253
|
}
|
|
56254
|
+
indexImports.push(`import { ${exportName} } from '${coreKey}';`);
|
|
56255
|
+
exportNames.push(exportName);
|
|
56243
56256
|
bundleOpts.inputs[cmp.tagName] = coreKey;
|
|
56244
56257
|
bundleOpts.loader[coreKey] = exp.join('\n');
|
|
56245
56258
|
});
|
|
56246
|
-
|
|
56259
|
+
// Generate the contents of the entry file to be created by the bundler
|
|
56260
|
+
bundleOpts.loader['\0core'] = generateEntryPoint$1(outputTarget, indexImports, indexExports, exportNames);
|
|
56247
56261
|
};
|
|
56248
56262
|
/**
|
|
56249
56263
|
* Generate the entrypoint (`index.ts` file) contents for the `dist-custom-elements` output target
|
|
56250
56264
|
* @param outputTarget the output target's configuration
|
|
56265
|
+
* @param cmpImports The import declarations for local component modules.
|
|
56266
|
+
* @param cmpExports The export declarations for local component modules.
|
|
56267
|
+
* @param cmpNames The exported component names (could be aliased) from local component modules.
|
|
56251
56268
|
* @returns the stringified contents to be placed in the entrypoint
|
|
56252
56269
|
*/
|
|
56253
|
-
const generateEntryPoint$1 = (outputTarget) => {
|
|
56254
|
-
const
|
|
56255
|
-
|
|
56270
|
+
const generateEntryPoint$1 = (outputTarget, cmpImports = [], cmpExports = [], cmpNames = []) => {
|
|
56271
|
+
const body = [];
|
|
56272
|
+
const imports = [];
|
|
56273
|
+
const exports = [];
|
|
56274
|
+
// Exports that are always present
|
|
56275
|
+
exports.push(`export { setAssetPath, setPlatformOptions } from '${STENCIL_INTERNAL_CLIENT_ID}';`, `export * from '${USER_INDEX_ENTRY_ID}';`);
|
|
56276
|
+
// Content related to global scripts
|
|
56256
56277
|
if (outputTarget.includeGlobalScripts !== false) {
|
|
56257
|
-
|
|
56258
|
-
|
|
56259
|
-
|
|
56278
|
+
imports.push(`import { globalScripts } from '${STENCIL_APP_GLOBALS_ID}';`);
|
|
56279
|
+
body.push(`globalScripts();`);
|
|
56280
|
+
}
|
|
56281
|
+
// Content related to the `bundle` export behavior
|
|
56282
|
+
if (outputTarget.customElementsExportBehavior === 'bundle') {
|
|
56283
|
+
imports.push(...cmpImports);
|
|
56284
|
+
body.push('export const defineCustomElements = (opts) => {', " if (typeof customElements !== 'undefined') {", ' [', ...cmpNames.map((cmp) => ` ${cmp},`), ' ].forEach(cmp => {', ' if (!customElements.get(cmp.is)) {', ' customElements.define(cmp.is, cmp, opts);', ' }', ' });', ' }', '};');
|
|
56285
|
+
}
|
|
56286
|
+
// Content related to the `single-export-module` export behavior
|
|
56287
|
+
if (outputTarget.customElementsExportBehavior === 'single-export-module') {
|
|
56288
|
+
exports.push(...cmpExports);
|
|
56289
|
+
}
|
|
56290
|
+
// Generate the contents of the file based on the parts
|
|
56291
|
+
// defined above. This keeps the file structure consistent as
|
|
56292
|
+
// new export behaviors may be added
|
|
56293
|
+
let content = '';
|
|
56294
|
+
// Add imports to file content
|
|
56295
|
+
content += imports.length ? imports.join('\n') + '\n' : '';
|
|
56296
|
+
// Add exports to file content
|
|
56297
|
+
content += exports.length ? exports.join('\n') + '\n' : '';
|
|
56298
|
+
// Add body to file content
|
|
56299
|
+
content += body.length ? '\n' + body.join('\n') + '\n' : '';
|
|
56300
|
+
return content;
|
|
56260
56301
|
};
|
|
56261
56302
|
/**
|
|
56262
56303
|
* Get the series of custom transformers that will be applied to a Stencil project's source code during the TypeScript
|
|
@@ -56287,6 +56328,7 @@ const getCustomElementCustomTransformer = (config, compilerCtx, components, outp
|
|
|
56287
56328
|
];
|
|
56288
56329
|
};
|
|
56289
56330
|
|
|
56331
|
+
// TODO(STENCIL-561): fully delete dist-custom-elements-bundle code
|
|
56290
56332
|
const outputCustomElementsBundle = async (config, compilerCtx, buildCtx) => {
|
|
56291
56333
|
if (!config.buildDist) {
|
|
56292
56334
|
return;
|
|
@@ -58057,195 +58099,6 @@ const getLazyEntry = (isBrowser) => {
|
|
|
58057
58099
|
return s.toString();
|
|
58058
58100
|
};
|
|
58059
58101
|
|
|
58060
|
-
const outputAngular = async (config, compilerCtx, buildCtx) => {
|
|
58061
|
-
if (!config.buildDist) {
|
|
58062
|
-
return;
|
|
58063
|
-
}
|
|
58064
|
-
const angularOutputTargets = config.outputTargets.filter(isOutputTargetAngular);
|
|
58065
|
-
if (angularOutputTargets.length === 0) {
|
|
58066
|
-
return;
|
|
58067
|
-
}
|
|
58068
|
-
const timespan = buildCtx.createTimeSpan(`generate angular proxies started`, true);
|
|
58069
|
-
await Promise.all(angularOutputTargets.map((outputTarget) => angularDirectiveProxyOutput(config, compilerCtx, buildCtx, outputTarget)));
|
|
58070
|
-
timespan.finish(`generate angular proxies finished`);
|
|
58071
|
-
};
|
|
58072
|
-
const angularDirectiveProxyOutput = (config, compilerCtx, buildCtx, outputTarget) => {
|
|
58073
|
-
const filteredComponents = getFilteredComponents(outputTarget.excludeComponents, buildCtx.components);
|
|
58074
|
-
return Promise.all([
|
|
58075
|
-
generateProxies(config, compilerCtx, buildCtx, filteredComponents, outputTarget),
|
|
58076
|
-
generateAngularArray(compilerCtx, filteredComponents, outputTarget),
|
|
58077
|
-
generateAngularUtils(compilerCtx, outputTarget),
|
|
58078
|
-
]);
|
|
58079
|
-
};
|
|
58080
|
-
const getFilteredComponents = (excludeComponents = [], cmps) => {
|
|
58081
|
-
return sortBy(cmps, (cmp) => cmp.tagName).filter((c) => !excludeComponents.includes(c.tagName) && !c.internal);
|
|
58082
|
-
};
|
|
58083
|
-
const generateProxies = async (config, compilerCtx, buildCtx, components, outputTarget) => {
|
|
58084
|
-
const proxies = getProxies(components);
|
|
58085
|
-
const distTypesDir = dirname(buildCtx.packageJson.types);
|
|
58086
|
-
const dtsFilePath = join(config.rootDir, distTypesDir, GENERATED_DTS);
|
|
58087
|
-
const componentsTypeFile = relativeImport(outputTarget.directivesProxyFile, dtsFilePath, '.d.ts');
|
|
58088
|
-
const imports = `/* eslint-disable */
|
|
58089
|
-
/* tslint:disable */
|
|
58090
|
-
/* auto-generated angular directive proxies */
|
|
58091
|
-
import { ChangeDetectionStrategy, ChangeDetectorRef, Component, ElementRef, EventEmitter, NgZone } from '@angular/core';`;
|
|
58092
|
-
const sourceImports = !outputTarget.componentCorePackage
|
|
58093
|
-
? `import { Components } from '${componentsTypeFile}';`
|
|
58094
|
-
: `import { Components } from '${outputTarget.componentCorePackage}';`;
|
|
58095
|
-
const final = [imports, getProxyUtils(outputTarget), sourceImports, proxies];
|
|
58096
|
-
const finalText = final.join('\n') + '\n';
|
|
58097
|
-
const tsSourceFile = t.createSourceFile(GENERATED_DTS, finalText, t.ScriptTarget.Latest, false);
|
|
58098
|
-
const tsPrinter = t.createPrinter({
|
|
58099
|
-
newLine: t.NewLineKind.LineFeed,
|
|
58100
|
-
});
|
|
58101
|
-
const formattedCode = tsPrinter.printFile(tsSourceFile);
|
|
58102
|
-
return compilerCtx.fs.writeFile(outputTarget.directivesProxyFile, formattedCode);
|
|
58103
|
-
};
|
|
58104
|
-
const getProxies = (components) => {
|
|
58105
|
-
return components.map(getProxy).join('\n');
|
|
58106
|
-
};
|
|
58107
|
-
const getProxyCmp = (inputs, methods) => {
|
|
58108
|
-
const hasInputs = inputs.length > 0;
|
|
58109
|
-
const hasMethods = methods.length > 0;
|
|
58110
|
-
const proxMeta = [];
|
|
58111
|
-
if (!hasInputs && !hasMethods) {
|
|
58112
|
-
return '';
|
|
58113
|
-
}
|
|
58114
|
-
if (hasInputs)
|
|
58115
|
-
proxMeta.push(`inputs: ['${inputs.join(`', '`)}']`);
|
|
58116
|
-
if (hasMethods)
|
|
58117
|
-
proxMeta.push(`'methods': ['${methods.join(`', '`)}']`);
|
|
58118
|
-
return `@ProxyCmp({${proxMeta.join(', ')}})`;
|
|
58119
|
-
};
|
|
58120
|
-
const getProxy = (cmpMeta) => {
|
|
58121
|
-
// Collect component meta
|
|
58122
|
-
const inputs = getInputs(cmpMeta);
|
|
58123
|
-
const outputs = getOutputs(cmpMeta);
|
|
58124
|
-
const methods = getMethods(cmpMeta);
|
|
58125
|
-
const hasOutputs = outputs.length > 0;
|
|
58126
|
-
// Generate Angular @Directive
|
|
58127
|
-
const directiveOpts = [
|
|
58128
|
-
`selector: \'${cmpMeta.tagName}\'`,
|
|
58129
|
-
`changeDetection: ChangeDetectionStrategy.OnPush`,
|
|
58130
|
-
`template: '<ng-content></ng-content>'`,
|
|
58131
|
-
];
|
|
58132
|
-
if (inputs.length > 0) {
|
|
58133
|
-
directiveOpts.push(`inputs: ['${inputs.join(`', '`)}']`);
|
|
58134
|
-
}
|
|
58135
|
-
const tagNameAsPascal = dashToPascalCase$1(cmpMeta.tagName);
|
|
58136
|
-
const lines = [
|
|
58137
|
-
`
|
|
58138
|
-
export declare interface ${tagNameAsPascal} extends Components.${tagNameAsPascal} {}
|
|
58139
|
-
${getProxyCmp(inputs, methods)}
|
|
58140
|
-
@Component({ ${directiveOpts.join(', ')} })
|
|
58141
|
-
export class ${tagNameAsPascal} {`,
|
|
58142
|
-
];
|
|
58143
|
-
// Generate outputs
|
|
58144
|
-
outputs.forEach((output) => {
|
|
58145
|
-
lines.push(` ${output}!: EventEmitter<CustomEvent>;`);
|
|
58146
|
-
});
|
|
58147
|
-
lines.push(' protected el: HTMLElement;');
|
|
58148
|
-
lines.push(` constructor(c: ChangeDetectorRef, r: ElementRef, protected z: NgZone) {
|
|
58149
|
-
c.detach();
|
|
58150
|
-
this.el = r.nativeElement;`);
|
|
58151
|
-
if (hasOutputs) {
|
|
58152
|
-
lines.push(` proxyOutputs(this, this.el, ['${outputs.join(`', '`)}']);`);
|
|
58153
|
-
}
|
|
58154
|
-
lines.push(` }`);
|
|
58155
|
-
lines.push(`}`);
|
|
58156
|
-
return lines.join('\n');
|
|
58157
|
-
};
|
|
58158
|
-
const getInputs = (cmpMeta) => {
|
|
58159
|
-
return [
|
|
58160
|
-
...cmpMeta.properties.filter((prop) => !prop.internal).map((prop) => prop.name),
|
|
58161
|
-
...cmpMeta.virtualProperties.map((prop) => prop.name),
|
|
58162
|
-
].sort();
|
|
58163
|
-
};
|
|
58164
|
-
const getOutputs = (cmpMeta) => {
|
|
58165
|
-
return cmpMeta.events.filter((ev) => !ev.internal).map((prop) => prop.name);
|
|
58166
|
-
};
|
|
58167
|
-
const getMethods = (cmpMeta) => {
|
|
58168
|
-
return cmpMeta.methods.filter((method) => !method.internal).map((prop) => prop.name);
|
|
58169
|
-
};
|
|
58170
|
-
const getProxyUtils = (outputTarget) => {
|
|
58171
|
-
if (!outputTarget.directivesUtilsFile) {
|
|
58172
|
-
return PROXY_UTILS.replace(/export function/g, 'function');
|
|
58173
|
-
}
|
|
58174
|
-
else {
|
|
58175
|
-
const utilsPath = relativeImport(outputTarget.directivesProxyFile, outputTarget.directivesUtilsFile, '.ts');
|
|
58176
|
-
return `import { ProxyCmp, proxyOutputs } from '${utilsPath}';\n`;
|
|
58177
|
-
}
|
|
58178
|
-
};
|
|
58179
|
-
const generateAngularArray = (compilerCtx, components, outputTarget) => {
|
|
58180
|
-
if (!outputTarget.directivesArrayFile) {
|
|
58181
|
-
return Promise.resolve();
|
|
58182
|
-
}
|
|
58183
|
-
const proxyPath = relativeImport(outputTarget.directivesArrayFile, outputTarget.directivesProxyFile, '.ts');
|
|
58184
|
-
const directives = components
|
|
58185
|
-
.map((cmpMeta) => dashToPascalCase$1(cmpMeta.tagName))
|
|
58186
|
-
.map((className) => ` d.${className}`)
|
|
58187
|
-
.join(',\n');
|
|
58188
|
-
const c = `
|
|
58189
|
-
import type * as d from '${proxyPath}';
|
|
58190
|
-
|
|
58191
|
-
export const DIRECTIVES = [
|
|
58192
|
-
${directives}
|
|
58193
|
-
];
|
|
58194
|
-
`;
|
|
58195
|
-
return compilerCtx.fs.writeFile(outputTarget.directivesArrayFile, c);
|
|
58196
|
-
};
|
|
58197
|
-
const generateAngularUtils = async (compilerCtx, outputTarget) => {
|
|
58198
|
-
if (outputTarget.directivesUtilsFile) {
|
|
58199
|
-
await compilerCtx.fs.writeFile(outputTarget.directivesUtilsFile, '/* eslint-disable */\n/* tslint:disable */\n' + PROXY_UTILS);
|
|
58200
|
-
}
|
|
58201
|
-
};
|
|
58202
|
-
const PROXY_UTILS = `import { fromEvent } from 'rxjs';
|
|
58203
|
-
|
|
58204
|
-
export const proxyInputs = (Cmp: any, inputs: string[]) => {
|
|
58205
|
-
const Prototype = Cmp.prototype;
|
|
58206
|
-
inputs.forEach(item => {
|
|
58207
|
-
Object.defineProperty(Prototype, item, {
|
|
58208
|
-
get() {
|
|
58209
|
-
return this.el[item];
|
|
58210
|
-
},
|
|
58211
|
-
set(val: any) {
|
|
58212
|
-
this.z.runOutsideAngular(() => (this.el[item] = val));
|
|
58213
|
-
}
|
|
58214
|
-
});
|
|
58215
|
-
});
|
|
58216
|
-
};
|
|
58217
|
-
|
|
58218
|
-
export const proxyMethods = (Cmp: any, methods: string[]) => {
|
|
58219
|
-
const Prototype = Cmp.prototype;
|
|
58220
|
-
methods.forEach(methodName => {
|
|
58221
|
-
Prototype[methodName] = function () {
|
|
58222
|
-
const args = arguments;
|
|
58223
|
-
return this.z.runOutsideAngular(() =>
|
|
58224
|
-
this.el[methodName].apply(this.el, args)
|
|
58225
|
-
);
|
|
58226
|
-
};
|
|
58227
|
-
});
|
|
58228
|
-
};
|
|
58229
|
-
|
|
58230
|
-
export const proxyOutputs = (instance: any, el: any, events: string[]) => {
|
|
58231
|
-
events.forEach(eventName => instance[eventName] = fromEvent(el, eventName));
|
|
58232
|
-
}
|
|
58233
|
-
|
|
58234
|
-
export function ProxyCmp(opts: { inputs?: any; methods?: any }) {
|
|
58235
|
-
const decorator = function(cls: any){
|
|
58236
|
-
if (opts.inputs) {
|
|
58237
|
-
proxyInputs(cls, opts.inputs);
|
|
58238
|
-
}
|
|
58239
|
-
if (opts.methods) {
|
|
58240
|
-
proxyMethods(cls, opts.methods);
|
|
58241
|
-
}
|
|
58242
|
-
return cls;
|
|
58243
|
-
};
|
|
58244
|
-
return decorator;
|
|
58245
|
-
}
|
|
58246
|
-
`;
|
|
58247
|
-
const GENERATED_DTS = 'components.d.ts';
|
|
58248
|
-
|
|
58249
58102
|
const generateCustomDocs = async (config, docsData, outputTargets) => {
|
|
58250
58103
|
const customOutputTargets = outputTargets.filter(isOutputTargetDocsCustom);
|
|
58251
58104
|
if (customOutputTargets.length === 0) {
|
|
@@ -59559,29 +59412,38 @@ const generateCustomElementsTypes = async (config, compilerCtx, buildCtx, typesD
|
|
|
59559
59412
|
* @param outputTarget the output target for which types are being currently generated
|
|
59560
59413
|
*/
|
|
59561
59414
|
const generateCustomElementsTypesOutput$1 = async (config, compilerCtx, buildCtx, typesDir, outputTarget) => {
|
|
59415
|
+
const isBarrelExport = outputTarget.customElementsExportBehavior === 'single-export-module';
|
|
59416
|
+
const isBundleExport = outputTarget.customElementsExportBehavior === 'bundle';
|
|
59562
59417
|
// the path where we're going to write the typedef for the whole dist-custom-elements output
|
|
59563
59418
|
const customElementsDtsPath = join(outputTarget.dir, 'index.d.ts');
|
|
59564
59419
|
// the directory where types for the individual components are written
|
|
59565
59420
|
const componentsTypeDirectoryRelPath = relative$1(outputTarget.dir, typesDir);
|
|
59566
59421
|
const components = buildCtx.components.filter((m) => !m.isCollectionDependency);
|
|
59567
59422
|
const code = [
|
|
59568
|
-
|
|
59569
|
-
|
|
59570
|
-
|
|
59571
|
-
|
|
59572
|
-
|
|
59573
|
-
|
|
59574
|
-
|
|
59575
|
-
|
|
59576
|
-
|
|
59577
|
-
|
|
59578
|
-
|
|
59579
|
-
|
|
59580
|
-
|
|
59581
|
-
|
|
59582
|
-
|
|
59583
|
-
|
|
59584
|
-
|
|
59423
|
+
// To mirror the index.js file and only export the typedefs for the
|
|
59424
|
+
// entities exported there, we will re-export the typedefs iff
|
|
59425
|
+
// the `customElementsExportBehavior` is set to barrel component exports
|
|
59426
|
+
...(isBarrelExport
|
|
59427
|
+
? [
|
|
59428
|
+
`/* ${config.namespace} custom elements */`,
|
|
59429
|
+
...components.map((component) => {
|
|
59430
|
+
const exportName = dashToPascalCase$1(component.tagName);
|
|
59431
|
+
const importName = component.componentClassName;
|
|
59432
|
+
// typedefs for individual components can be found under paths like
|
|
59433
|
+
// $TYPES_DIR/components/my-component/my-component.d.ts
|
|
59434
|
+
//
|
|
59435
|
+
// To construct this path we:
|
|
59436
|
+
//
|
|
59437
|
+
// - get the relative path to the component's source file from the source directory
|
|
59438
|
+
// - join that relative path to the relative path from the `index.d.ts` file to the
|
|
59439
|
+
// directory where typedefs are saved
|
|
59440
|
+
const componentSourceRelPath = relative$1(config.srcDir, component.sourceFilePath).replace('.tsx', '');
|
|
59441
|
+
const componentDTSPath = join(componentsTypeDirectoryRelPath, componentSourceRelPath);
|
|
59442
|
+
return `export { ${importName} as ${exportName} } from '${componentDTSPath}';`;
|
|
59443
|
+
}),
|
|
59444
|
+
``,
|
|
59445
|
+
]
|
|
59446
|
+
: []),
|
|
59585
59447
|
`/**`,
|
|
59586
59448
|
` * Used to manually set the base path where assets can be found.`,
|
|
59587
59449
|
` * If the script is used as "module", it's recommended to use "import.meta.url",`,
|
|
@@ -59600,16 +59462,41 @@ const generateCustomElementsTypesOutput$1 = async (config, compilerCtx, buildCtx
|
|
|
59600
59462
|
` rel?: (el: EventTarget, eventName: string, listener: EventListenerOrEventListenerObject, options: boolean | AddEventListenerOptions) => void;`,
|
|
59601
59463
|
`}`,
|
|
59602
59464
|
`export declare const setPlatformOptions: (opts: SetPlatformOptions) => void;`,
|
|
59465
|
+
...(isBundleExport
|
|
59466
|
+
? [
|
|
59467
|
+
``,
|
|
59468
|
+
`/**`,
|
|
59469
|
+
` * Utility to define all custom elements within this package using the tag name provided in the component's source.`,
|
|
59470
|
+
` * When defining each custom element, it will also check it's safe to define by:`,
|
|
59471
|
+
` *`,
|
|
59472
|
+
` * 1. Ensuring the "customElements" registry is available in the global context (window).`,
|
|
59473
|
+
` * 2. Ensuring that the component tag name is not already defined.`,
|
|
59474
|
+
` *`,
|
|
59475
|
+
` * Use the standard [customElements.define()](https://developer.mozilla.org/en-US/docs/Web/API/CustomElementRegistry/define)`,
|
|
59476
|
+
` * method instead to define custom elements individually, or to provide a different tag name.`,
|
|
59477
|
+
` */`,
|
|
59478
|
+
`export declare const defineCustomElements: (opts?: any) => void;`,
|
|
59479
|
+
]
|
|
59480
|
+
: []),
|
|
59603
59481
|
];
|
|
59604
59482
|
const componentsDtsRelPath = relDts$1(outputTarget.dir, join(typesDir, 'components.d.ts'));
|
|
59605
|
-
|
|
59606
|
-
|
|
59607
|
-
|
|
59608
|
-
|
|
59609
|
-
|
|
59610
|
-
|
|
59611
|
-
|
|
59612
|
-
|
|
59483
|
+
// To mirror the index.js file and only export the typedefs for the
|
|
59484
|
+
// entities exported there, we will re-export the typedefs iff
|
|
59485
|
+
// the `customElementsExportBehavior` is set to barrel component exports
|
|
59486
|
+
if (isBarrelExport) {
|
|
59487
|
+
// If there is an `index.ts` file in the src directory, we'll re-export anything
|
|
59488
|
+
// exported from that file
|
|
59489
|
+
// Otherwise, we'll export everything from the auto-generated `components.d.ts`
|
|
59490
|
+
// file in the output directory
|
|
59491
|
+
const usersIndexJsPath = join(config.srcDir, 'index.ts');
|
|
59492
|
+
const hasUserIndex = await compilerCtx.fs.access(usersIndexJsPath);
|
|
59493
|
+
if (hasUserIndex) {
|
|
59494
|
+
const userIndexRelPath = normalizePath$1(dirname(componentsDtsRelPath));
|
|
59495
|
+
code.push(`export * from '${userIndexRelPath}';`);
|
|
59496
|
+
}
|
|
59497
|
+
else {
|
|
59498
|
+
code.push(`export * from '${componentsDtsRelPath}';`);
|
|
59499
|
+
}
|
|
59613
59500
|
}
|
|
59614
59501
|
await compilerCtx.fs.writeFile(customElementsDtsPath, code.join('\n') + `\n`, {
|
|
59615
59502
|
outputTargetType: outputTarget.type,
|
|
@@ -59661,6 +59548,7 @@ const relDts$1 = (fromPath, dtsPath) => {
|
|
|
59661
59548
|
return normalizePath$1(dtsPath.replace('.d.ts', ''));
|
|
59662
59549
|
};
|
|
59663
59550
|
|
|
59551
|
+
// TODO(STENCIL-561): fully delete dist-custom-elements-bundle code
|
|
59664
59552
|
const generateCustomElementsBundleTypes = async (config, compilerCtx, buildCtx, distDtsFilePath) => {
|
|
59665
59553
|
const outputTargets = config.outputTargets.filter(isOutputTargetDistCustomElementsBundle);
|
|
59666
59554
|
await Promise.all(outputTargets.map((outputTarget) => generateCustomElementsTypesOutput(config, compilerCtx, buildCtx, distDtsFilePath, outputTarget)));
|
|
@@ -60154,10 +60042,10 @@ const generateAppTypes = async (config, compilerCtx, buildCtx, destination) => {
|
|
|
60154
60042
|
// immediately write the components.d.ts file to disk and put it into fs memory
|
|
60155
60043
|
let componentsDtsFilePath = getComponentsDtsSrcFilePath(config);
|
|
60156
60044
|
if (!areTypesInternal) {
|
|
60157
|
-
componentsDtsFilePath = resolve$1(destination, GENERATED_DTS
|
|
60045
|
+
componentsDtsFilePath = resolve$1(destination, GENERATED_DTS);
|
|
60158
60046
|
componentTypesFileContent = updateStencilTypesImports(destination, componentsDtsFilePath, componentTypesFileContent);
|
|
60159
60047
|
}
|
|
60160
|
-
const writeResults = await compilerCtx.fs.writeFile(componentsDtsFilePath, componentTypesFileContent, {
|
|
60048
|
+
const writeResults = await compilerCtx.fs.writeFile(normalizePath$1(componentsDtsFilePath), componentTypesFileContent, {
|
|
60161
60049
|
immediateWrite: true,
|
|
60162
60050
|
});
|
|
60163
60051
|
const hasComponentsDtsChanged = writeResults.changedContent;
|
|
@@ -60199,17 +60087,15 @@ const generateComponentTypesFile = (config, buildCtx, areTypesInternal) => {
|
|
|
60199
60087
|
});
|
|
60200
60088
|
c.push(COMPONENTS_DTS_HEADER);
|
|
60201
60089
|
c.push(`import { HTMLStencilElement, JSXBase } from "@stencil/core/internal";`);
|
|
60202
|
-
//
|
|
60203
|
-
|
|
60090
|
+
// Map event type metadata to partial expressions (omitting import/export keywords)
|
|
60091
|
+
// e.g. { TestEvent } from '../path/to/event/test-event.interface';
|
|
60092
|
+
const expressions = Object.keys(typeImportData).map((filePath) => {
|
|
60204
60093
|
const typeData = typeImportData[filePath];
|
|
60205
|
-
let importFilePath;
|
|
60094
|
+
let importFilePath = filePath;
|
|
60206
60095
|
if (isAbsolute$1(filePath)) {
|
|
60207
60096
|
importFilePath = normalizePath$1('./' + relative$1(config.srcDir, filePath)).replace(/\.(tsx|ts)$/, '');
|
|
60208
60097
|
}
|
|
60209
|
-
|
|
60210
|
-
importFilePath = filePath;
|
|
60211
|
-
}
|
|
60212
|
-
return `import { ${typeData
|
|
60098
|
+
return `{ ${typeData
|
|
60213
60099
|
.sort(sortImportNames)
|
|
60214
60100
|
.map((td) => {
|
|
60215
60101
|
if (td.localName === td.importName) {
|
|
@@ -60220,7 +60106,9 @@ const generateComponentTypesFile = (config, buildCtx, areTypesInternal) => {
|
|
|
60220
60106
|
}
|
|
60221
60107
|
})
|
|
60222
60108
|
.join(`, `)} } from "${importFilePath}";`;
|
|
60223
|
-
})
|
|
60109
|
+
});
|
|
60110
|
+
// Write all import and export statements for event types
|
|
60111
|
+
c.push(...expressions.map((ref) => `import ${ref}`), ...expressions.map((ref) => `export ${ref}`));
|
|
60224
60112
|
c.push(`export namespace Components {`);
|
|
60225
60113
|
c.push(...modules.map((m) => `${m.component}`));
|
|
60226
60114
|
c.push(`}`);
|
|
@@ -60850,7 +60738,6 @@ const generateOutputTargets = async (config, compilerCtx, buildCtx) => {
|
|
|
60850
60738
|
compilerCtx.changedModules.clear();
|
|
60851
60739
|
invalidateRollupCaches(compilerCtx);
|
|
60852
60740
|
await Promise.all([
|
|
60853
|
-
outputAngular(config, compilerCtx, buildCtx),
|
|
60854
60741
|
outputCopy(config, compilerCtx, buildCtx),
|
|
60855
60742
|
outputCollection(config, compilerCtx, buildCtx, changedModuleFiles),
|
|
60856
60743
|
outputCustomElements(config, compilerCtx, buildCtx),
|
|
@@ -61225,12 +61112,6 @@ const componentDecoratorToStatic = (config, typeChecker, diagnostics, cmpNode, n
|
|
|
61225
61112
|
}
|
|
61226
61113
|
styleToStatic(newMembers, componentOptions);
|
|
61227
61114
|
const assetsDirs = componentOptions.assetsDirs || [];
|
|
61228
|
-
if (isString$1(componentOptions.assetsDir)) {
|
|
61229
|
-
assetsDirs.push(componentOptions.assetsDir);
|
|
61230
|
-
const warn = buildWarn(diagnostics);
|
|
61231
|
-
warn.messageText = `@Component option "assetsDir" should be renamed to "assetsDirs" and the value should be an array of strings.`;
|
|
61232
|
-
augmentDiagnosticWithNode(warn, componentDecorator);
|
|
61233
|
-
}
|
|
61234
61115
|
if (assetsDirs.length > 0) {
|
|
61235
61116
|
newMembers.push(createStaticGetter('assetsDirs', convertValueToLiteral(assetsDirs)));
|
|
61236
61117
|
}
|
|
@@ -65151,7 +65032,7 @@ const createTsWatchProgram = async (config, buildCallback) => {
|
|
|
65151
65032
|
return clearInterval(id);
|
|
65152
65033
|
},
|
|
65153
65034
|
};
|
|
65154
|
-
config.sys.
|
|
65035
|
+
config.sys.addDestroy(() => tsWatchSys.clearTimeout(timeoutId));
|
|
65155
65036
|
const tsWatchHost = t.createWatchCompilerHost(config.tsconfig, optionsToExtend, tsWatchSys, t.createEmitAndSemanticDiagnosticsBuilderProgram, (reportDiagnostic) => {
|
|
65156
65037
|
config.logger.debug('watch reportDiagnostic:' + reportDiagnostic.messageText);
|
|
65157
65038
|
}, (reportWatchStatus) => {
|
|
@@ -65276,7 +65157,7 @@ const createWatchBuild = async (config, compilerCtx) => {
|
|
|
65276
65157
|
watchingDirs.set(dirPath, config.sys.watchDirectory(dirPath, onDirChange, recursive));
|
|
65277
65158
|
}
|
|
65278
65159
|
};
|
|
65279
|
-
config.sys.
|
|
65160
|
+
config.sys.addDestroy(close);
|
|
65280
65161
|
return {
|
|
65281
65162
|
start,
|
|
65282
65163
|
close,
|
|
@@ -66635,7 +66516,7 @@ const createSysWorker = (config) => {
|
|
|
66635
66516
|
config.maxConcurrentWorkers > 0 &&
|
|
66636
66517
|
config.sys.hardwareConcurrency > 1) {
|
|
66637
66518
|
const workerCtrl = config.sys.createWorkerController(config.maxConcurrentWorkers);
|
|
66638
|
-
config.sys.
|
|
66519
|
+
config.sys.addDestroy(() => workerCtrl.destroy());
|
|
66639
66520
|
config.logger.debug(`create workers, maxWorkers: ${workerCtrl.maxWorkers}`);
|
|
66640
66521
|
return createWorkerMainContext(workerCtrl);
|
|
66641
66522
|
}
|
|
@@ -66893,32 +66774,6 @@ const getUserConfigName = (config, correctConfigName) => {
|
|
|
66893
66774
|
return correctConfigName;
|
|
66894
66775
|
};
|
|
66895
66776
|
|
|
66896
|
-
const validateAngular = (config, userOutputs) => {
|
|
66897
|
-
const angularOutputTargets = userOutputs.filter(isOutputTargetAngular);
|
|
66898
|
-
return angularOutputTargets.map((outputTarget) => {
|
|
66899
|
-
let directivesProxyFile = outputTarget.directivesProxyFile;
|
|
66900
|
-
if (directivesProxyFile && !isAbsolute$1(directivesProxyFile)) {
|
|
66901
|
-
directivesProxyFile = join(config.rootDir, directivesProxyFile);
|
|
66902
|
-
}
|
|
66903
|
-
let directivesArrayFile = outputTarget.directivesArrayFile;
|
|
66904
|
-
if (directivesArrayFile && !isAbsolute$1(directivesArrayFile)) {
|
|
66905
|
-
directivesArrayFile = join(config.rootDir, directivesArrayFile);
|
|
66906
|
-
}
|
|
66907
|
-
let directivesUtilsFile = outputTarget.directivesUtilsFile;
|
|
66908
|
-
if (directivesUtilsFile && !isAbsolute$1(directivesUtilsFile)) {
|
|
66909
|
-
directivesUtilsFile = join(config.rootDir, directivesUtilsFile);
|
|
66910
|
-
}
|
|
66911
|
-
return {
|
|
66912
|
-
type: 'angular',
|
|
66913
|
-
componentCorePackage: outputTarget.componentCorePackage,
|
|
66914
|
-
directivesProxyFile,
|
|
66915
|
-
directivesArrayFile,
|
|
66916
|
-
directivesUtilsFile,
|
|
66917
|
-
excludeComponents: outputTarget.excludeComponents || [],
|
|
66918
|
-
};
|
|
66919
|
-
});
|
|
66920
|
-
};
|
|
66921
|
-
|
|
66922
66777
|
/**
|
|
66923
66778
|
* Validate and return DIST_COLLECTION output targets, ensuring that the `dir`
|
|
66924
66779
|
* property is set on them.
|
|
@@ -66938,6 +66793,29 @@ const validateCollection = (config, userOutputs) => {
|
|
|
66938
66793
|
});
|
|
66939
66794
|
};
|
|
66940
66795
|
|
|
66796
|
+
/**
|
|
66797
|
+
* The collection of valid export behaviors.
|
|
66798
|
+
* Used to generate a type for typed configs as well as output target validation
|
|
66799
|
+
* for the `dist-custom-elements` output target.
|
|
66800
|
+
*
|
|
66801
|
+
* Adding a value to this const array will automatically add it as a valid option on the
|
|
66802
|
+
* output target configuration for `customElementsExportBehavior`.
|
|
66803
|
+
*
|
|
66804
|
+
* - `default`: No additional export or definition behavior will happen.
|
|
66805
|
+
* - `auto-define-custom-elements`: Enables the auto-definition of a component and its children (recursively) in the custom elements registry. This
|
|
66806
|
+
* functionality allows consumers to bypass the explicit call to define a component, its children, its children's
|
|
66807
|
+
* children, etc. Users of this flag should be aware that enabling this functionality may increase bundle size.
|
|
66808
|
+
* - `bundle`: A `defineCustomElements` function will be exported from the distribution directory. This behavior was added to allow easy migration
|
|
66809
|
+
* from `dist-custom-elements-bundle` to `dist-custom-elements`.
|
|
66810
|
+
* - `single-export-module`: All components will be re-exported from the specified directory's root `index.js` file.
|
|
66811
|
+
*/
|
|
66812
|
+
const CustomElementsExportBehaviorOptions = [
|
|
66813
|
+
'default',
|
|
66814
|
+
'auto-define-custom-elements',
|
|
66815
|
+
'bundle',
|
|
66816
|
+
'single-export-module',
|
|
66817
|
+
];
|
|
66818
|
+
|
|
66941
66819
|
/**
|
|
66942
66820
|
* Validate a series of {@link d.CopyTask}s
|
|
66943
66821
|
* @param copy the copy tasks to validate, or a boolean to specify if copy tasks are enabled
|
|
@@ -66981,6 +66859,15 @@ const validateCustomElement = (config, userOutputs) => {
|
|
|
66981
66859
|
if (!isBoolean$1(outputTarget.externalRuntime)) {
|
|
66982
66860
|
outputTarget.externalRuntime = true;
|
|
66983
66861
|
}
|
|
66862
|
+
if (!isBoolean$1(outputTarget.generateTypeDeclarations)) {
|
|
66863
|
+
outputTarget.generateTypeDeclarations = true;
|
|
66864
|
+
}
|
|
66865
|
+
// Export behavior must be defined on the validated target config and must
|
|
66866
|
+
// be one of the export behavior valid values
|
|
66867
|
+
if (outputTarget.customElementsExportBehavior == null ||
|
|
66868
|
+
!CustomElementsExportBehaviorOptions.includes(outputTarget.customElementsExportBehavior)) {
|
|
66869
|
+
outputTarget.customElementsExportBehavior = 'default';
|
|
66870
|
+
}
|
|
66984
66871
|
// unlike other output targets, Stencil does not allow users to define the output location of types at this time
|
|
66985
66872
|
if (outputTarget.generateTypeDeclarations) {
|
|
66986
66873
|
const typesDirectory = getAbsolutePath(config, join(defaultDir, 'types'));
|
|
@@ -67003,6 +66890,7 @@ const validateCustomElement = (config, userOutputs) => {
|
|
|
67003
66890
|
}, []);
|
|
67004
66891
|
};
|
|
67005
66892
|
|
|
66893
|
+
// TODO(STENCIL-561): fully delete dist-custom-elements-bundle code
|
|
67006
66894
|
const validateCustomElementBundle = (config, userOutputs) => {
|
|
67007
66895
|
return userOutputs.filter(isOutputTargetDistCustomElementsBundle).reduce((arr, o) => {
|
|
67008
66896
|
const outputTarget = {
|
|
@@ -67528,11 +67416,6 @@ const validateOutputTargets = (config, diagnostics) => {
|
|
|
67528
67416
|
const err = buildError(diagnostics);
|
|
67529
67417
|
err.messageText = `Invalid outputTarget type "${outputTarget.type}". Valid outputTarget types include: ${VALID_CONFIG_OUTPUT_TARGETS.map((t) => `"${t}"`).join(', ')}`;
|
|
67530
67418
|
}
|
|
67531
|
-
else if (outputTarget.type === DIST_CUSTOM_ELEMENTS_BUNDLE) {
|
|
67532
|
-
// TODO(STENCIL-260): Remove this check when the 'dist-custom-elements-bundle' is removed
|
|
67533
|
-
const warning = buildWarn(diagnostics);
|
|
67534
|
-
warning.messageText = `dist-custom-elements-bundle is deprecated and will be removed in a future major version release. Use "dist-custom-elements" instead. If "dist-custom-elements" does not meet your needs, please add a comment to https://github.com/ionic-team/stencil/issues/3136.`;
|
|
67535
|
-
}
|
|
67536
67419
|
});
|
|
67537
67420
|
config.outputTargets = [
|
|
67538
67421
|
...validateCollection(config, userOutputs),
|
|
@@ -67543,7 +67426,6 @@ const validateOutputTargets = (config, diagnostics) => {
|
|
|
67543
67426
|
...validateWww(config, diagnostics, userOutputs),
|
|
67544
67427
|
...validateDist(config, userOutputs),
|
|
67545
67428
|
...validateDocs(config, diagnostics, userOutputs),
|
|
67546
|
-
...validateAngular(config, userOutputs),
|
|
67547
67429
|
...validateStats(config, userOutputs),
|
|
67548
67430
|
];
|
|
67549
67431
|
// hydrate also gets info from the www output
|
|
@@ -68132,7 +68014,7 @@ const validateConfig = (userConfig = {}, bootstrapConfig) => {
|
|
|
68132
68014
|
validatedConfig.buildEs5 === true || (!validatedConfig.devMode && validatedConfig.buildEs5 === 'prod');
|
|
68133
68015
|
setBooleanConfig(validatedConfig, 'minifyCss', null, !validatedConfig.devMode);
|
|
68134
68016
|
setBooleanConfig(validatedConfig, 'minifyJs', null, !validatedConfig.devMode);
|
|
68135
|
-
setBooleanConfig(validatedConfig, 'sourceMap', null, typeof validatedConfig.sourceMap === 'undefined' ?
|
|
68017
|
+
setBooleanConfig(validatedConfig, 'sourceMap', null, typeof validatedConfig.sourceMap === 'undefined' ? true : validatedConfig.sourceMap);
|
|
68136
68018
|
setBooleanConfig(validatedConfig, 'watch', 'watch', false);
|
|
68137
68019
|
setBooleanConfig(validatedConfig, 'buildDocs', 'docs', !validatedConfig.devMode);
|
|
68138
68020
|
setBooleanConfig(validatedConfig, 'buildDist', 'esm', !validatedConfig.devMode || validatedConfig.buildEs5);
|
|
@@ -69035,7 +68917,7 @@ const getComponentPathContent = (componentGraph, outputTarget) => {
|
|
|
69035
68917
|
const dependencies = [
|
|
69036
68918
|
{
|
|
69037
68919
|
name: "@stencil/core",
|
|
69038
|
-
version: "
|
|
68920
|
+
version: "3.0.0-alpha.1",
|
|
69039
68921
|
main: "compiler/stencil.js",
|
|
69040
68922
|
resources: [
|
|
69041
68923
|
"package.json",
|