@stencil/core 2.17.2-0 → 2.17.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 +94 -67
- package/cli/index.d.ts +1 -1
- package/cli/index.js +94 -67
- package/cli/package.json +1 -1
- package/compiler/package.json +1 -1
- package/compiler/stencil.js +292 -54
- 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 +16 -1
- package/mock-doc/index.d.ts +5 -0
- package/mock-doc/index.js +16 -1
- 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 +28 -21
- package/testing/mocks.d.ts +7 -6
- package/testing/package.json +1 -1
package/compiler/stencil.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
Stencil Compiler v2.17.2
|
|
2
|
+
Stencil Compiler v2.17.2 | MIT Licensed | https://stenciljs.com
|
|
3
3
|
*/
|
|
4
4
|
(function(exports) {
|
|
5
5
|
'use strict';
|
|
@@ -898,24 +898,37 @@ const buildWarn = (diagnostics) => {
|
|
|
898
898
|
diagnostics.push(diagnostic);
|
|
899
899
|
return diagnostic;
|
|
900
900
|
};
|
|
901
|
-
|
|
901
|
+
/**
|
|
902
|
+
* Create a diagnostic message suited for representing an error in a JSON
|
|
903
|
+
* file. This includes information about the exact lines in the JSON file which
|
|
904
|
+
* caused the error and the path to the file.
|
|
905
|
+
*
|
|
906
|
+
* @param compilerCtx the current compiler context
|
|
907
|
+
* @param diagnostics a list of diagnostics used as a return param
|
|
908
|
+
* @param jsonFilePath the path to the JSON file where the error occurred
|
|
909
|
+
* @param msg the error message
|
|
910
|
+
* @param jsonField the key for the field which caused the error, used for finding
|
|
911
|
+
* the error line in the original JSON file
|
|
912
|
+
* @returns a reference to the newly-created diagnostic
|
|
913
|
+
*/
|
|
914
|
+
const buildJsonFileError = (compilerCtx, diagnostics, jsonFilePath, msg, jsonField) => {
|
|
902
915
|
const err = buildError(diagnostics);
|
|
903
916
|
err.messageText = msg;
|
|
904
917
|
err.absFilePath = jsonFilePath;
|
|
905
|
-
if (typeof
|
|
918
|
+
if (typeof jsonField === 'string') {
|
|
906
919
|
try {
|
|
907
920
|
const jsonStr = compilerCtx.fs.readFileSync(jsonFilePath);
|
|
908
921
|
const lines = jsonStr.replace(/\r/g, '\n').split('\n');
|
|
909
922
|
for (let i = 0; i < lines.length; i++) {
|
|
910
923
|
const txtLine = lines[i];
|
|
911
|
-
const txtIndex = txtLine.indexOf(
|
|
924
|
+
const txtIndex = txtLine.indexOf(jsonField);
|
|
912
925
|
if (txtIndex > -1) {
|
|
913
926
|
const warnLine = {
|
|
914
927
|
lineIndex: i,
|
|
915
928
|
lineNumber: i + 1,
|
|
916
929
|
text: txtLine,
|
|
917
930
|
errorCharStart: txtIndex,
|
|
918
|
-
errorLength:
|
|
931
|
+
errorLength: jsonField.length,
|
|
919
932
|
};
|
|
920
933
|
err.lineNumber = warnLine.lineNumber;
|
|
921
934
|
err.columnNumber = txtIndex + 1;
|
|
@@ -4052,7 +4065,7 @@ const createCustomResolverAsync = (sys, inMemoryFs, exts) => {
|
|
|
4052
4065
|
};
|
|
4053
4066
|
};
|
|
4054
4067
|
|
|
4055
|
-
const buildId = '
|
|
4068
|
+
const buildId = '20220801155719';
|
|
4056
4069
|
const minfyJsId = 'terser5.6.1_7';
|
|
4057
4070
|
const optimizeCssId = 'autoprefixer10.2.5_postcss8.2.13_7';
|
|
4058
4071
|
const parse5Version = '6.0.1';
|
|
@@ -4060,8 +4073,8 @@ const rollupVersion = '2.42.3';
|
|
|
4060
4073
|
const sizzleVersion = '2.42.3';
|
|
4061
4074
|
const terserVersion = '5.6.1';
|
|
4062
4075
|
const typescriptVersion = '4.5.4';
|
|
4063
|
-
const vermoji = '
|
|
4064
|
-
const version$3 = '2.17.2
|
|
4076
|
+
const vermoji = '🍤';
|
|
4077
|
+
const version$3 = '2.17.2';
|
|
4065
4078
|
const versions = {
|
|
4066
4079
|
stencil: version$3,
|
|
4067
4080
|
parse5: parse5Version,
|
|
@@ -16288,6 +16301,9 @@ class MockElement extends MockNode {
|
|
|
16288
16301
|
set title(value) {
|
|
16289
16302
|
this.setAttributeNS(null, 'title', value);
|
|
16290
16303
|
}
|
|
16304
|
+
animate() {
|
|
16305
|
+
/**/
|
|
16306
|
+
}
|
|
16291
16307
|
onanimationstart() {
|
|
16292
16308
|
/**/
|
|
16293
16309
|
}
|
|
@@ -16552,6 +16568,18 @@ class MockElement extends MockNode {
|
|
|
16552
16568
|
onwheel() {
|
|
16553
16569
|
/**/
|
|
16554
16570
|
}
|
|
16571
|
+
requestFullscreen() {
|
|
16572
|
+
/**/
|
|
16573
|
+
}
|
|
16574
|
+
scrollBy() {
|
|
16575
|
+
/**/
|
|
16576
|
+
}
|
|
16577
|
+
scrollTo() {
|
|
16578
|
+
/**/
|
|
16579
|
+
}
|
|
16580
|
+
scrollIntoView() {
|
|
16581
|
+
/**/
|
|
16582
|
+
}
|
|
16555
16583
|
toString(opts) {
|
|
16556
16584
|
return serializeNodeToHtml(this, opts);
|
|
16557
16585
|
}
|
|
@@ -54609,6 +54637,23 @@ const isMemberPrivate = (member) => {
|
|
|
54609
54637
|
}
|
|
54610
54638
|
return false;
|
|
54611
54639
|
};
|
|
54640
|
+
/**
|
|
54641
|
+
* Convert a JavaScript value to the TypeScript Intermediate Representation
|
|
54642
|
+
* (IR) for a literal Abstract Syntax Tree (AST) node with that same value. The
|
|
54643
|
+
* value to convert may be a primitive type like `string`, `boolean`, etc or
|
|
54644
|
+
* may be an `Object`, `Array`, etc.
|
|
54645
|
+
*
|
|
54646
|
+
* Note that this function takes a param (`refs`) with a default value,
|
|
54647
|
+
* normally a value should _not_ be passed for this parameter since it is
|
|
54648
|
+
* intended to be used for recursive calls.
|
|
54649
|
+
*
|
|
54650
|
+
* @param val the value to convert
|
|
54651
|
+
* @param refs a set of references, used in recursive calls to avoid
|
|
54652
|
+
* circular references when creating object literal IR instances. **note that
|
|
54653
|
+
* you shouldn't pass this parameter unless you know what you're doing!**
|
|
54654
|
+
* @returns TypeScript IR for a literal corresponding to the JavaScript value
|
|
54655
|
+
* with which the function was called
|
|
54656
|
+
*/
|
|
54612
54657
|
const convertValueToLiteral = (val, refs = null) => {
|
|
54613
54658
|
if (refs == null) {
|
|
54614
54659
|
refs = new WeakSet();
|
|
@@ -54639,12 +54684,39 @@ const convertValueToLiteral = (val, refs = null) => {
|
|
|
54639
54684
|
}
|
|
54640
54685
|
return t.createLiteral(val);
|
|
54641
54686
|
};
|
|
54687
|
+
/**
|
|
54688
|
+
* Convert a JavaScript Array instance to TypeScript's Intermediate
|
|
54689
|
+
* Representation (IR) for an array literal. This is done by recursively using
|
|
54690
|
+
* {@link convertValueToLiteral} to create a new array consisting of the
|
|
54691
|
+
* TypeScript IR of each element in the array to be converted, and then creating
|
|
54692
|
+
* the TypeScript IR for _that_ array.
|
|
54693
|
+
*
|
|
54694
|
+
* @param list the array instance to convert
|
|
54695
|
+
* @param refs a set of references to objects, used when converting objects to
|
|
54696
|
+
* avoid circular references
|
|
54697
|
+
* @returns TypeScript IR for the array we want to convert
|
|
54698
|
+
*/
|
|
54642
54699
|
const arrayToArrayLiteral = (list, refs) => {
|
|
54643
54700
|
const newList = list.map((l) => {
|
|
54644
54701
|
return convertValueToLiteral(l, refs);
|
|
54645
54702
|
});
|
|
54646
54703
|
return t.createArrayLiteral(newList);
|
|
54647
54704
|
};
|
|
54705
|
+
/**
|
|
54706
|
+
* Convert a JavaScript object (i.e. an object existing at runtime) to the
|
|
54707
|
+
* corresponding TypeScript Intermediate Representation (IR)
|
|
54708
|
+
* ({@see ts.ObjectLiteralExpression}) for an object literal. This function
|
|
54709
|
+
* takes an argument holding a `WeakSet` of references to objects which is
|
|
54710
|
+
* used to avoid circular references. Objects that are converted in this
|
|
54711
|
+
* function are added to the set, and if an object is already present then an
|
|
54712
|
+
* `undefined` literal (in TypeScript IR) is returned instead of another
|
|
54713
|
+
* object literal, as continuing to convert a circular reference would, well,
|
|
54714
|
+
* never end!
|
|
54715
|
+
*
|
|
54716
|
+
* @param obj the JavaScript object to convert to TypeScript IR
|
|
54717
|
+
* @param refs a set of references to objects, used to avoid circular references
|
|
54718
|
+
* @returns a TypeScript object literal expression
|
|
54719
|
+
*/
|
|
54648
54720
|
const objectToObjectLiteral = (obj, refs) => {
|
|
54649
54721
|
if (refs.has(obj)) {
|
|
54650
54722
|
return t.createIdentifier('undefined');
|
|
@@ -56012,17 +56084,16 @@ const KEEP_IMPORTS = new Set([
|
|
|
56012
56084
|
* which do actual work of generating the rollup configuration, creating an
|
|
56013
56085
|
* entry chunk, running, the build, etc.
|
|
56014
56086
|
*
|
|
56015
|
-
* @param config the
|
|
56087
|
+
* @param config the validated compiler configuration we're using
|
|
56016
56088
|
* @param compilerCtx the current compiler context
|
|
56017
56089
|
* @param buildCtx the current build context
|
|
56018
56090
|
* @returns an empty Promise which won't resolve until the work is done!
|
|
56019
56091
|
*/
|
|
56020
56092
|
const outputCustomElements = async (config, compilerCtx, buildCtx) => {
|
|
56021
|
-
var _a;
|
|
56022
56093
|
if (!config.buildDist) {
|
|
56023
56094
|
return;
|
|
56024
56095
|
}
|
|
56025
|
-
const outputTargets =
|
|
56096
|
+
const outputTargets = config.outputTargets.filter(isOutputTargetDistCustomElements);
|
|
56026
56097
|
if (outputTargets.length === 0) {
|
|
56027
56098
|
return;
|
|
56028
56099
|
}
|
|
@@ -56035,7 +56106,7 @@ const outputCustomElements = async (config, compilerCtx, buildCtx) => {
|
|
|
56035
56106
|
* Get bundle options for our current build and compiler context which we'll use
|
|
56036
56107
|
* to generate a Rollup build and so on.
|
|
56037
56108
|
*
|
|
56038
|
-
* @param config
|
|
56109
|
+
* @param config a validated Stencil configuration object
|
|
56039
56110
|
* @param buildCtx the current build context
|
|
56040
56111
|
* @param compilerCtx the current compiler context
|
|
56041
56112
|
* @param outputTarget the outputTarget we're currently dealing with
|
|
@@ -56066,9 +56137,10 @@ const getBundleOptions = (config, buildCtx, compilerCtx, outputTarget) => ({
|
|
|
56066
56137
|
/**
|
|
56067
56138
|
* Get bundle options for rollup, run the rollup build, optionally minify the
|
|
56068
56139
|
* output, and write files to disk.
|
|
56069
|
-
*
|
|
56070
|
-
* @param
|
|
56140
|
+
*
|
|
56141
|
+
* @param config the validated Stencil configuration we're using
|
|
56071
56142
|
* @param compilerCtx the current compiler context
|
|
56143
|
+
* @param buildCtx the current build context
|
|
56072
56144
|
* @param outputTarget the outputTarget we're currently dealing with
|
|
56073
56145
|
* @returns an empty promise
|
|
56074
56146
|
*/
|
|
@@ -60192,8 +60264,7 @@ const relDts$1 = (fromPath, dtsPath) => {
|
|
|
60192
60264
|
* @param typesDir the path to the directory where type declarations are saved
|
|
60193
60265
|
*/
|
|
60194
60266
|
const generateCustomElementsTypes = async (config, compilerCtx, buildCtx, typesDir) => {
|
|
60195
|
-
|
|
60196
|
-
const outputTargets = ((_a = config.outputTargets) !== null && _a !== void 0 ? _a : []).filter(isOutputTargetDistCustomElements);
|
|
60267
|
+
const outputTargets = config.outputTargets.filter(isOutputTargetDistCustomElements);
|
|
60197
60268
|
await Promise.all(outputTargets.map((outputTarget) => generateCustomElementsTypesOutput(config, compilerCtx, buildCtx, typesDir, outputTarget)));
|
|
60198
60269
|
};
|
|
60199
60270
|
/**
|
|
@@ -62128,6 +62199,16 @@ const parseModuleImport = (config, compilerCtx, buildCtx, moduleFile, dirPath, i
|
|
|
62128
62199
|
}
|
|
62129
62200
|
};
|
|
62130
62201
|
|
|
62202
|
+
/**
|
|
62203
|
+
* Update an instance of TypeScript's Intermediate Representation (IR) for a
|
|
62204
|
+
* class declaration ({@link ts.ClassDeclaration}) with a static getter for the
|
|
62205
|
+
* compiler metadata that we produce as part of the compilation process.
|
|
62206
|
+
*
|
|
62207
|
+
* @param cmpNode an instance of the TypeScript IR for a class declaration (i.e.
|
|
62208
|
+
* a stencil component) to be updated
|
|
62209
|
+
* @param cmpMeta the component metadata corresponding to that component
|
|
62210
|
+
* @returns the updated typescript class declaration
|
|
62211
|
+
*/
|
|
62131
62212
|
const addComponentMetaStatic = (cmpNode, cmpMeta) => {
|
|
62132
62213
|
const publicCompilerMeta = getPublicCompilerMeta(cmpMeta);
|
|
62133
62214
|
const cmpMetaStaticProp = createStaticGetter('COMPILER_META', convertValueToLiteral(publicCompilerMeta));
|
|
@@ -62259,6 +62340,14 @@ const parseStaticEvents = (staticMembers) => {
|
|
|
62259
62340
|
});
|
|
62260
62341
|
};
|
|
62261
62342
|
|
|
62343
|
+
/**
|
|
62344
|
+
* Parse a list of {@link ts.ClassElement} objects representing static props
|
|
62345
|
+
* into a list of our own Intermediate Representation (IR) of properties on
|
|
62346
|
+
* components.
|
|
62347
|
+
*
|
|
62348
|
+
* @param staticMembers TypeScript IR for the properties on our component
|
|
62349
|
+
* @returns a manifest of compiler properties in our own Stencil IR
|
|
62350
|
+
*/
|
|
62262
62351
|
const parseStaticProps = (staticMembers) => {
|
|
62263
62352
|
const parsedProps = getStaticValue(staticMembers, 'properties');
|
|
62264
62353
|
if (!parsedProps) {
|
|
@@ -62495,7 +62584,22 @@ const setComponentBuildConditionals = (cmpMeta) => {
|
|
|
62495
62584
|
!cmpMeta.hasMember && !cmpMeta.hasStyle && !cmpMeta.hasLifecycle && !cmpMeta.hasListener && !cmpMeta.hasVdomRender;
|
|
62496
62585
|
};
|
|
62497
62586
|
|
|
62498
|
-
|
|
62587
|
+
/**
|
|
62588
|
+
* Given an instance of TypeScript's Intermediate Representation (IR) for a
|
|
62589
|
+
* class declaration ({@see ts.ClassDeclaration}) which represents a Stencil
|
|
62590
|
+
* component class declaration, parse and format various pieces of data about
|
|
62591
|
+
* static class members which we use in the compilation process
|
|
62592
|
+
*
|
|
62593
|
+
* @param compilerCtx the current compiler context
|
|
62594
|
+
* @param typeChecker a TypeScript type checker instance
|
|
62595
|
+
* @param cmpNode the TypeScript class declaration for the component
|
|
62596
|
+
* @param moduleFile Stencil's IR for a module, used here as an out param
|
|
62597
|
+
* @param transformOpts options which control various aspects of the
|
|
62598
|
+
* transformation
|
|
62599
|
+
* @returns the TypeScript class declaration IR instance with which the
|
|
62600
|
+
* function was called
|
|
62601
|
+
*/
|
|
62602
|
+
const parseStaticComponentMeta = (compilerCtx, typeChecker, cmpNode, moduleFile, transformOpts) => {
|
|
62499
62603
|
if (cmpNode.members == null) {
|
|
62500
62604
|
return cmpNode;
|
|
62501
62605
|
}
|
|
@@ -62612,7 +62716,7 @@ const parseStaticComponentMeta = (compilerCtx, typeChecker, cmpNode, moduleFile,
|
|
|
62612
62716
|
// add to module map
|
|
62613
62717
|
moduleFile.cmps.push(cmp);
|
|
62614
62718
|
// add to node map
|
|
62615
|
-
nodeMap.set(cmpNode, cmp);
|
|
62719
|
+
compilerCtx.nodeMap.set(cmpNode, cmp);
|
|
62616
62720
|
return cmpNode;
|
|
62617
62721
|
};
|
|
62618
62722
|
const parseVirtualProps = (docs) => {
|
|
@@ -62680,7 +62784,7 @@ const updateModule = (config, compilerCtx, buildCtx, tsSourceFile, sourceFileTex
|
|
|
62680
62784
|
compilerCtx.changedModules.add(moduleFile.sourceFilePath);
|
|
62681
62785
|
const visitNode = (node) => {
|
|
62682
62786
|
if (t.isClassDeclaration(node)) {
|
|
62683
|
-
parseStaticComponentMeta(compilerCtx, typeChecker, node, moduleFile
|
|
62787
|
+
parseStaticComponentMeta(compilerCtx, typeChecker, node, moduleFile);
|
|
62684
62788
|
return;
|
|
62685
62789
|
}
|
|
62686
62790
|
else if (t.isImportDeclaration(node)) {
|
|
@@ -62841,6 +62945,15 @@ const outputServiceWorkers = async (config, buildCtx) => {
|
|
|
62841
62945
|
}
|
|
62842
62946
|
};
|
|
62843
62947
|
|
|
62948
|
+
/**
|
|
62949
|
+
* Validate the package.json file for a project, checking that various fields
|
|
62950
|
+
* are set correctly for the currently-configured output targets.
|
|
62951
|
+
*
|
|
62952
|
+
* @param config the user-supplied Stencil config
|
|
62953
|
+
* @param compilerCtx the compiler context
|
|
62954
|
+
* @param buildCtx the build context
|
|
62955
|
+
* @returns an empty Promise
|
|
62956
|
+
*/
|
|
62844
62957
|
const validateBuildPackageJson = async (config, compilerCtx, buildCtx) => {
|
|
62845
62958
|
if (config.watch) {
|
|
62846
62959
|
return;
|
|
@@ -62848,26 +62961,41 @@ const validateBuildPackageJson = async (config, compilerCtx, buildCtx) => {
|
|
|
62848
62961
|
if (buildCtx.packageJson == null) {
|
|
62849
62962
|
return;
|
|
62850
62963
|
}
|
|
62851
|
-
const
|
|
62964
|
+
const distCollectionOutputTargets = config.outputTargets.filter(isOutputTargetDistCollection);
|
|
62852
62965
|
const typesOutputTargets = config.outputTargets.filter(isOutputTargetDistTypes);
|
|
62853
62966
|
await Promise.all([
|
|
62854
|
-
...
|
|
62855
|
-
|
|
62856
|
-
|
|
62857
|
-
...typesOutputTargets.map((outputTarget) => {
|
|
62858
|
-
return validateTypes(config, compilerCtx, buildCtx, outputTarget);
|
|
62859
|
-
}),
|
|
62967
|
+
...distCollectionOutputTargets.map((distCollectionOT) => validateDistCollectionPkgJson(config, compilerCtx, buildCtx, distCollectionOT)),
|
|
62968
|
+
...typesOutputTargets.map((typesOT) => validateTypes(config, compilerCtx, buildCtx, typesOT)),
|
|
62969
|
+
validateModule(config, compilerCtx, buildCtx),
|
|
62860
62970
|
]);
|
|
62861
62971
|
};
|
|
62862
|
-
|
|
62972
|
+
/**
|
|
62973
|
+
* Validate package.json contents for the `DIST_COLLECTION` output target,
|
|
62974
|
+
* checking that various fields like `files`, `main`, and so on are set
|
|
62975
|
+
* correctly.
|
|
62976
|
+
*
|
|
62977
|
+
* @param config the stencil config
|
|
62978
|
+
* @param compilerCtx the current compiler context
|
|
62979
|
+
* @param buildCtx the current build context
|
|
62980
|
+
* @param outputTarget a DIST_COLLECTION output target
|
|
62981
|
+
*/
|
|
62982
|
+
const validateDistCollectionPkgJson = async (config, compilerCtx, buildCtx, outputTarget) => {
|
|
62863
62983
|
await Promise.all([
|
|
62864
62984
|
validatePackageFiles(config, compilerCtx, buildCtx, outputTarget),
|
|
62865
62985
|
validateMain(config, compilerCtx, buildCtx, outputTarget),
|
|
62866
|
-
validateModule(config, compilerCtx, buildCtx, outputTarget),
|
|
62867
62986
|
validateCollection$1(config, compilerCtx, buildCtx, outputTarget),
|
|
62868
62987
|
validateBrowser(config, compilerCtx, buildCtx),
|
|
62869
62988
|
]);
|
|
62870
62989
|
};
|
|
62990
|
+
/**
|
|
62991
|
+
* Validate that the `files` field in `package.json` contains directories and
|
|
62992
|
+
* files that are necessary for the `DIST_COLLECTION` output target.
|
|
62993
|
+
*
|
|
62994
|
+
* @param config the stencil config
|
|
62995
|
+
* @param compilerCtx the current compiler context
|
|
62996
|
+
* @param buildCtx the current build context
|
|
62997
|
+
* @param outputTarget a DIST_COLLECTION output target
|
|
62998
|
+
*/
|
|
62871
62999
|
const validatePackageFiles = async (config, compilerCtx, buildCtx, outputTarget) => {
|
|
62872
63000
|
if (!config.devMode && Array.isArray(buildCtx.packageJson.files)) {
|
|
62873
63001
|
const actualDistDir = normalizePath$1(relative$1(config.rootDir, outputTarget.dir));
|
|
@@ -62891,6 +63019,15 @@ const validatePackageFiles = async (config, compilerCtx, buildCtx, outputTarget)
|
|
|
62891
63019
|
}));
|
|
62892
63020
|
}
|
|
62893
63021
|
};
|
|
63022
|
+
/**
|
|
63023
|
+
* Check that the `main` field is set correctly in `package.json` for the
|
|
63024
|
+
* `DIST_COLLECTION` output target.
|
|
63025
|
+
*
|
|
63026
|
+
* @param config the stencil config
|
|
63027
|
+
* @param compilerCtx the current compiler context
|
|
63028
|
+
* @param buildCtx the current build context
|
|
63029
|
+
* @param outputTarget a DIST_COLLECTION output target
|
|
63030
|
+
*/
|
|
62894
63031
|
const validateMain = (config, compilerCtx, buildCtx, outputTarget) => {
|
|
62895
63032
|
const mainAbs = join(outputTarget.dir, 'index.cjs.js');
|
|
62896
63033
|
const mainRel = relative$1(config.rootDir, mainAbs);
|
|
@@ -62903,26 +63040,76 @@ const validateMain = (config, compilerCtx, buildCtx, outputTarget) => {
|
|
|
62903
63040
|
packageJsonWarn(config, compilerCtx, buildCtx, msg, `"main"`);
|
|
62904
63041
|
}
|
|
62905
63042
|
};
|
|
62906
|
-
|
|
62907
|
-
|
|
63043
|
+
/**
|
|
63044
|
+
* Validate the package.json 'module' field, taking into account output targets
|
|
63045
|
+
* and other configuration details. This will look for a value for the `module`
|
|
63046
|
+
* field. If not present it will set a relevant warning message with an
|
|
63047
|
+
* output-target specific recommended value. If it is present and is not equal
|
|
63048
|
+
* to that recommended value it will set a different warning message.
|
|
63049
|
+
*
|
|
63050
|
+
* @param config the current user-supplied configuration
|
|
63051
|
+
* @param compilerCtx the compiler context
|
|
63052
|
+
* @param buildCtx the build context
|
|
63053
|
+
* @returns an empty Promise
|
|
63054
|
+
*/
|
|
63055
|
+
const validateModule = async (config, compilerCtx, buildCtx) => {
|
|
62908
63056
|
const currentModule = buildCtx.packageJson.module;
|
|
62909
|
-
const
|
|
62910
|
-
const distRel = relative$1(config.rootDir, distAbs);
|
|
62911
|
-
let recommendedRelPath = distRel;
|
|
62912
|
-
if (customElementsOutput) {
|
|
62913
|
-
const customElementsAbs = join(customElementsOutput.dir, 'index.js');
|
|
62914
|
-
recommendedRelPath = relative$1(config.rootDir, customElementsAbs);
|
|
62915
|
-
}
|
|
63057
|
+
const recommendedRelPath = recommendedModulePath(config);
|
|
62916
63058
|
if (!isString$1(currentModule)) {
|
|
62917
|
-
|
|
63059
|
+
let msg = 'package.json "module" property is required when generating a distribution.';
|
|
63060
|
+
if (recommendedRelPath !== null) {
|
|
63061
|
+
msg += ` It's recommended to set the "module" property to: ${normalizePath$1(recommendedRelPath)}`;
|
|
63062
|
+
}
|
|
62918
63063
|
packageJsonWarn(config, compilerCtx, buildCtx, msg, `"module"`);
|
|
63064
|
+
return;
|
|
62919
63065
|
}
|
|
62920
|
-
|
|
62921
|
-
|
|
62922
|
-
const msg = `package.json "module" property is set to "${currentModule}". It's recommended to set the "module" property to: ${recommendedRelPath}`;
|
|
63066
|
+
if (recommendedRelPath !== null && normalizePath$1(recommendedRelPath) !== normalizePath$1(currentModule)) {
|
|
63067
|
+
const msg = `package.json "module" property is set to "${currentModule}". It's recommended to set the "module" property to: ${normalizePath$1(recommendedRelPath)}`;
|
|
62923
63068
|
packageJsonWarn(config, compilerCtx, buildCtx, msg, `"module"`);
|
|
62924
63069
|
}
|
|
62925
63070
|
};
|
|
63071
|
+
/**
|
|
63072
|
+
* Get the recommended `"module"` path for `package.json` given the output
|
|
63073
|
+
* targets that a user has set on their config.
|
|
63074
|
+
*
|
|
63075
|
+
* @param config the user-supplied Stencil configuration
|
|
63076
|
+
* @returns a recommended module path or a null value to indicate no default
|
|
63077
|
+
* value is supplied
|
|
63078
|
+
*/
|
|
63079
|
+
function recommendedModulePath(config) {
|
|
63080
|
+
const customElementsBundleOT = config.outputTargets.find(isOutputTargetDistCustomElementsBundle);
|
|
63081
|
+
const customElementsOT = config.outputTargets.find(isOutputTargetDistCustomElements);
|
|
63082
|
+
const distCollectionOT = config.outputTargets.find(isOutputTargetDistCollection);
|
|
63083
|
+
// If we're using `dist-custom-elements` then the preferred "module" field
|
|
63084
|
+
// value is `$OUTPUT_DIR/components/index.js`
|
|
63085
|
+
//
|
|
63086
|
+
// Additionally, the `DIST_CUSTOM_ELEMENTS` output target should override
|
|
63087
|
+
// `DIST_CUSTOM_ELEMENTS_BUNDLE` and `DIST_COLLECTION` output targets if
|
|
63088
|
+
// they're also set, so we return first with this one.
|
|
63089
|
+
if (customElementsOT) {
|
|
63090
|
+
const componentsIndexAbs = join(customElementsOT.dir, 'components', 'index.js');
|
|
63091
|
+
return relative$1(config.rootDir, componentsIndexAbs);
|
|
63092
|
+
}
|
|
63093
|
+
if (customElementsBundleOT) {
|
|
63094
|
+
const customElementsAbs = join(customElementsBundleOT.dir, 'index.js');
|
|
63095
|
+
return relative$1(config.rootDir, customElementsAbs);
|
|
63096
|
+
}
|
|
63097
|
+
if (distCollectionOT) {
|
|
63098
|
+
return relative$1(config.rootDir, join(distCollectionOT.dir, 'index.js'));
|
|
63099
|
+
}
|
|
63100
|
+
// if no output target for which we define a recommended output target is set
|
|
63101
|
+
// we return `null`
|
|
63102
|
+
return null;
|
|
63103
|
+
}
|
|
63104
|
+
/**
|
|
63105
|
+
* Check that the `types` field is set correctly in `package.json` for the
|
|
63106
|
+
* `DIST_COLLECTION` output target.
|
|
63107
|
+
*
|
|
63108
|
+
* @param config the stencil config
|
|
63109
|
+
* @param compilerCtx the current compiler context
|
|
63110
|
+
* @param buildCtx the current build context
|
|
63111
|
+
* @param outputTarget a DIST_COLLECTION output target
|
|
63112
|
+
*/
|
|
62926
63113
|
const validateTypes = async (config, compilerCtx, buildCtx, outputTarget) => {
|
|
62927
63114
|
const typesAbs = getComponentsDtsTypesFilePath(outputTarget);
|
|
62928
63115
|
const recommendedPath = relative$1(config.rootDir, typesAbs);
|
|
@@ -62946,6 +63133,15 @@ const validateTypes = async (config, compilerCtx, buildCtx, outputTarget) => {
|
|
|
62946
63133
|
}
|
|
62947
63134
|
}
|
|
62948
63135
|
};
|
|
63136
|
+
/**
|
|
63137
|
+
* Check that the `collection` field is set correctly in `package.json` for the
|
|
63138
|
+
* `DIST_COLLECTION` output target.
|
|
63139
|
+
*
|
|
63140
|
+
* @param config the stencil config
|
|
63141
|
+
* @param compilerCtx the current compiler context
|
|
63142
|
+
* @param buildCtx the current build context
|
|
63143
|
+
* @param outputTarget a DIST_COLLECTION output target
|
|
63144
|
+
*/
|
|
62949
63145
|
const validateCollection$1 = (config, compilerCtx, buildCtx, outputTarget) => {
|
|
62950
63146
|
if (outputTarget.collectionDir) {
|
|
62951
63147
|
const collectionRel = join(relative$1(config.rootDir, outputTarget.collectionDir), COLLECTION_MANIFEST_FILE_NAME);
|
|
@@ -62955,19 +63151,51 @@ const validateCollection$1 = (config, compilerCtx, buildCtx, outputTarget) => {
|
|
|
62955
63151
|
}
|
|
62956
63152
|
}
|
|
62957
63153
|
};
|
|
63154
|
+
/**
|
|
63155
|
+
* Check that the `browser` field is set correctly in `package.json` for the
|
|
63156
|
+
* `DIST_COLLECTION` output target.
|
|
63157
|
+
*
|
|
63158
|
+
* @param config the stencil config
|
|
63159
|
+
* @param compilerCtx the current compiler context
|
|
63160
|
+
* @param buildCtx the current build context
|
|
63161
|
+
*/
|
|
62958
63162
|
const validateBrowser = (config, compilerCtx, buildCtx) => {
|
|
62959
63163
|
if (isString$1(buildCtx.packageJson.browser)) {
|
|
62960
63164
|
const msg = `package.json "browser" property is set to "${buildCtx.packageJson.browser}". However, for maximum compatibility with all bundlers it's recommended to not set the "browser" property and instead ensure both "module" and "main" properties are set.`;
|
|
62961
63165
|
packageJsonWarn(config, compilerCtx, buildCtx, msg, `"browser"`);
|
|
62962
63166
|
}
|
|
62963
63167
|
};
|
|
62964
|
-
|
|
62965
|
-
|
|
63168
|
+
/**
|
|
63169
|
+
* Build a diagnostic for an error resulting from a particular field in a
|
|
63170
|
+
* package.json file
|
|
63171
|
+
*
|
|
63172
|
+
* @param config the stencil config
|
|
63173
|
+
* @param compilerCtx the current compiler context
|
|
63174
|
+
* @param buildCtx the current build context
|
|
63175
|
+
* @param msg an error string
|
|
63176
|
+
* @param jsonField the key for the field which caused the error, used for
|
|
63177
|
+
* finding the error line in the original JSON file
|
|
63178
|
+
* @returns a diagnostic object
|
|
63179
|
+
*/
|
|
63180
|
+
const packageJsonError = (config, compilerCtx, buildCtx, msg, jsonField) => {
|
|
63181
|
+
const err = buildJsonFileError(compilerCtx, buildCtx.diagnostics, config.packageJsonFilePath, msg, jsonField);
|
|
62966
63182
|
err.header = `Package Json`;
|
|
62967
63183
|
return err;
|
|
62968
63184
|
};
|
|
62969
|
-
|
|
62970
|
-
|
|
63185
|
+
/**
|
|
63186
|
+
* Build a diagnostic for a warning resulting from a particular field in a
|
|
63187
|
+
* package.json file
|
|
63188
|
+
*
|
|
63189
|
+
* @param config the stencil config
|
|
63190
|
+
* @param compilerCtx the current compiler context
|
|
63191
|
+
* @param buildCtx the current build context
|
|
63192
|
+
* @param msg an error string
|
|
63193
|
+
* @param jsonField the key for the field which caused the error, used for
|
|
63194
|
+
* finding the error line in the original JSON file
|
|
63195
|
+
* @returns a diagnostic object
|
|
63196
|
+
*/
|
|
63197
|
+
const packageJsonWarn = (config, compilerCtx, buildCtx, msg, jsonField) => {
|
|
63198
|
+
const warn = buildJsonFileError(compilerCtx, buildCtx.diagnostics, config.packageJsonFilePath, msg, jsonField);
|
|
62971
63199
|
warn.header = `Package Json`;
|
|
62972
63200
|
warn.level = 'warn';
|
|
62973
63201
|
return warn;
|
|
@@ -64448,12 +64676,15 @@ const createConfigFlags = (init = {}) => {
|
|
|
64448
64676
|
};
|
|
64449
64677
|
|
|
64450
64678
|
const getConfig = (userConfig) => {
|
|
64451
|
-
var _a, _b;
|
|
64679
|
+
var _a, _b, _c, _d;
|
|
64452
64680
|
const logger = (_a = userConfig.logger) !== null && _a !== void 0 ? _a : createLogger();
|
|
64453
|
-
const config = {
|
|
64454
|
-
|
|
64455
|
-
|
|
64456
|
-
|
|
64681
|
+
const config = {
|
|
64682
|
+
...userConfig,
|
|
64683
|
+
flags: createConfigFlags((_b = userConfig.flags) !== null && _b !== void 0 ? _b : {}),
|
|
64684
|
+
logger,
|
|
64685
|
+
outputTargets: (_c = userConfig.outputTargets) !== null && _c !== void 0 ? _c : [],
|
|
64686
|
+
sys: (_d = userConfig.sys) !== null && _d !== void 0 ? _d : createSystem({ logger }),
|
|
64687
|
+
};
|
|
64457
64688
|
setPlatformPath(config.sys.platformPath);
|
|
64458
64689
|
if (config.flags.debug || config.flags.verbose) {
|
|
64459
64690
|
config.logLevel = 'debug';
|
|
@@ -65159,7 +65390,7 @@ const getComponentPathContent = (componentGraph, outputTarget) => {
|
|
|
65159
65390
|
const dependencies = [
|
|
65160
65391
|
{
|
|
65161
65392
|
name: "@stencil/core",
|
|
65162
|
-
version: "2.17.2
|
|
65393
|
+
version: "2.17.2",
|
|
65163
65394
|
main: "compiler/stencil.js",
|
|
65164
65395
|
resources: [
|
|
65165
65396
|
"package.json",
|
|
@@ -66512,7 +66743,8 @@ const validateWorkers = (config) => {
|
|
|
66512
66743
|
* @returns an object with config and diagnostics props
|
|
66513
66744
|
*/
|
|
66514
66745
|
const validateConfig = (userConfig = {}, bootstrapConfig) => {
|
|
66515
|
-
|
|
66746
|
+
var _a, _b, _c;
|
|
66747
|
+
const config = Object.assign({}, userConfig); // not positive it's json safe
|
|
66516
66748
|
const diagnostics = [];
|
|
66517
66749
|
const logger = bootstrapConfig.logger || config.logger || createLogger();
|
|
66518
66750
|
const validatedConfig = {
|
|
@@ -66520,6 +66752,8 @@ const validateConfig = (userConfig = {}, bootstrapConfig) => {
|
|
|
66520
66752
|
// flags _should_ be JSON safe
|
|
66521
66753
|
flags: JSON.parse(JSON.stringify(config.flags || {})),
|
|
66522
66754
|
logger,
|
|
66755
|
+
outputTargets: (_a = config.outputTargets) !== null && _a !== void 0 ? _a : [],
|
|
66756
|
+
sys: (_c = (_b = config.sys) !== null && _b !== void 0 ? _b : bootstrapConfig.sys) !== null && _c !== void 0 ? _c : createSystem({ logger }),
|
|
66523
66757
|
};
|
|
66524
66758
|
// default devMode false
|
|
66525
66759
|
if (validatedConfig.flags.prod) {
|
|
@@ -66786,6 +67020,7 @@ const hasStencilConfigInclude = (includeProp) => Array.isArray(includeProp) && i
|
|
|
66786
67020
|
* @public
|
|
66787
67021
|
*/
|
|
66788
67022
|
const loadConfig = async (init = {}) => {
|
|
67023
|
+
var _a;
|
|
66789
67024
|
const results = {
|
|
66790
67025
|
config: null,
|
|
66791
67026
|
diagnostics: [],
|
|
@@ -66800,9 +67035,12 @@ const loadConfig = async (init = {}) => {
|
|
|
66800
67035
|
};
|
|
66801
67036
|
const unknownConfig = {};
|
|
66802
67037
|
try {
|
|
66803
|
-
const sys = init.sys || createSystem();
|
|
66804
67038
|
const config = init.config || {};
|
|
66805
67039
|
let configPath = init.configPath || config.configPath;
|
|
67040
|
+
// Pull the {@link CompilerSystem} out of the initialization object, or create one if it does not exist.
|
|
67041
|
+
// This entity is needed to load the project's configuration (and therefore needs to be created before it can be
|
|
67042
|
+
// attached to a configuration entity, validated or otherwise)
|
|
67043
|
+
const sys = (_a = init.sys) !== null && _a !== void 0 ? _a : createSystem();
|
|
66806
67044
|
const loadedConfigFile = await loadConfigFile(sys, results.diagnostics, configPath);
|
|
66807
67045
|
if (hasError(results.diagnostics)) {
|
|
66808
67046
|
return results;
|
|
@@ -67094,7 +67332,7 @@ const convertStaticToMeta = (config, compilerCtx, buildCtx, typeChecker, collect
|
|
|
67094
67332
|
let moduleFile;
|
|
67095
67333
|
const visitNode = (node) => {
|
|
67096
67334
|
if (t.isClassDeclaration(node)) {
|
|
67097
|
-
return parseStaticComponentMeta(compilerCtx, typeChecker, node, moduleFile,
|
|
67335
|
+
return parseStaticComponentMeta(compilerCtx, typeChecker, node, moduleFile, transformOpts);
|
|
67098
67336
|
}
|
|
67099
67337
|
else if (t.isImportDeclaration(node)) {
|
|
67100
67338
|
parseModuleImport(config, compilerCtx, buildCtx, moduleFile, dirPath, node, !transformOpts.isolatedModules);
|