Skip to content

Commit c78dd20

Browse files
tanner-reitsrwaskiewicz
authored andcommitted
feat(cli): update flag defaults for V3 (#3502)
update the following configuration defaults: - the root-level `sourceMaps` flag now defaults to `true`. - `dist-custom-elements` config `generateTypeDeclarations` flag now defaults to `true` STENCIL-396: Implement New Sensible Defaults for V3 BREAKING CHANGE: sourcemaps are enabled by default for all output targets, and type declarations are automatically created for the `dist-custom-elements` output target
1 parent 3b480c6 commit c78dd20

File tree

6 files changed

+79
-6
lines changed

6 files changed

+79
-6
lines changed

BREAKING_CHANGES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -652,6 +652,7 @@ Stencil v3.0.0 is in development at this time and has not been released. The lis
652652
change. Further details on each of these items will be included prior to the release.
653653

654654
- [fix(testing): puppeteer v10 support #2934](https://github.com/ionic-team/stencil/pull/2934)
655+
- [feat(cli): update flag defaults for V3 #3502](https://github.com/ionic-team/stencil/pull/3502)
655656

656657
## DEPRECATIONS
657658

src/compiler/config/outputs/validate-custom-element.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ export const validateCustomElement = (
3737
if (!isBoolean(outputTarget.externalRuntime)) {
3838
outputTarget.externalRuntime = true;
3939
}
40+
if (!isBoolean(outputTarget.generateTypeDeclarations)) {
41+
outputTarget.generateTypeDeclarations = true;
42+
}
4043

4144
// unlike other output targets, Stencil does not allow users to define the output location of types at this time
4245
if (outputTarget.generateTypeDeclarations) {

src/compiler/config/test/validate-config-sourcemap.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,13 @@ describe('stencil config - sourceMap option', () => {
5454
expect(inlineSources).toBe(false);
5555
});
5656

57-
it('sets the sourceMap options to false in tsconfig by default', async () => {
57+
it('sets the sourceMap options to true in tsconfig by default', async () => {
5858
const testConfig = getLoadConfigForTests();
5959

6060
const loadConfigResults = await loadConfig(testConfig);
6161

6262
const { sourceMap, inlineSources } = loadConfigResults.config.tsCompilerOptions;
63-
expect(sourceMap).toBe(false);
64-
expect(inlineSources).toBe(false);
63+
expect(sourceMap).toBe(true);
64+
expect(inlineSources).toBe(true);
6565
});
6666
});

src/compiler/config/test/validate-config.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -430,9 +430,9 @@ describe('validation', () => {
430430
expect(config.sourceMap).toBe(false);
431431
});
432432

433-
it('defaults the field to false when not set in the config', () => {
433+
it('defaults the field to true when not set in the config', () => {
434434
const { config } = validateConfig(userConfig, bootstrapConfig);
435-
expect(config.sourceMap).toBe(false);
435+
expect(config.sourceMap).toBe(true);
436436
});
437437
});
438438

src/compiler/config/test/validate-output-dist-custom-element.spec.ts

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,18 @@ describe('validate-output-dist-custom-element', () => {
2424

2525
const { config } = validateConfig(userConfig, mockLoadConfigInit());
2626
expect(config.outputTargets).toEqual([
27+
{
28+
type: DIST_TYPES,
29+
dir: defaultDistDir,
30+
typesDir: path.join(rootDir, 'dist', 'types'),
31+
},
2732
{
2833
type: DIST_CUSTOM_ELEMENTS,
2934
copy: [],
3035
dir: defaultDistDir,
3136
empty: true,
3237
externalRuntime: true,
38+
generateTypeDeclarations: true,
3339
},
3440
]);
3541
});
@@ -38,6 +44,7 @@ describe('validate-output-dist-custom-element', () => {
3844
const outputTarget: d.OutputTargetDistCustomElements = {
3945
type: DIST_CUSTOM_ELEMENTS,
4046
dir: distCustomElementsDir,
47+
generateTypeDeclarations: false,
4148
};
4249
userConfig.outputTargets = [outputTarget];
4350

@@ -49,6 +56,7 @@ describe('validate-output-dist-custom-element', () => {
4956
dir: path.join(rootDir, distCustomElementsDir),
5057
empty: true,
5158
externalRuntime: true,
59+
generateTypeDeclarations: false,
5260
},
5361
]);
5462
});
@@ -58,6 +66,7 @@ describe('validate-output-dist-custom-element', () => {
5866
const outputTarget: d.OutputTargetDistCustomElements = {
5967
type: DIST_CUSTOM_ELEMENTS,
6068
externalRuntime: false,
69+
generateTypeDeclarations: false,
6170
};
6271
userConfig.outputTargets = [outputTarget];
6372

@@ -69,6 +78,7 @@ describe('validate-output-dist-custom-element', () => {
6978
dir: defaultDistDir,
7079
empty: true,
7180
externalRuntime: false,
81+
generateTypeDeclarations: false,
7282
},
7383
]);
7484
});
@@ -78,6 +88,7 @@ describe('validate-output-dist-custom-element', () => {
7888
type: DIST_CUSTOM_ELEMENTS,
7989
empty: undefined,
8090
externalRuntime: false,
91+
generateTypeDeclarations: false,
8192
};
8293
userConfig.outputTargets = [outputTarget];
8394

@@ -89,6 +100,7 @@ describe('validate-output-dist-custom-element', () => {
89100
dir: defaultDistDir,
90101
empty: true,
91102
externalRuntime: false,
103+
generateTypeDeclarations: false,
92104
},
93105
]);
94106
});
@@ -99,6 +111,7 @@ describe('validate-output-dist-custom-element', () => {
99111
const outputTarget: d.OutputTargetDistCustomElements = {
100112
type: DIST_CUSTOM_ELEMENTS,
101113
empty: false,
114+
generateTypeDeclarations: false,
102115
};
103116
userConfig.outputTargets = [outputTarget];
104117

@@ -110,6 +123,7 @@ describe('validate-output-dist-custom-element', () => {
110123
dir: defaultDistDir,
111124
empty: false,
112125
externalRuntime: true,
126+
generateTypeDeclarations: false,
113127
},
114128
]);
115129
});
@@ -119,6 +133,7 @@ describe('validate-output-dist-custom-element', () => {
119133
type: DIST_CUSTOM_ELEMENTS,
120134
empty: false,
121135
externalRuntime: undefined,
136+
generateTypeDeclarations: false,
122137
};
123138
userConfig.outputTargets = [outputTarget];
124139

@@ -130,12 +145,64 @@ describe('validate-output-dist-custom-element', () => {
130145
dir: defaultDistDir,
131146
empty: false,
132147
externalRuntime: true,
148+
generateTypeDeclarations: false,
133149
},
134150
]);
135151
});
136152
});
137153

138154
describe('"generateTypeDeclarations" field', () => {
155+
it('defaults the "generateTypeDeclarations" field to true if not provided', () => {
156+
const outputTarget: d.OutputTargetDistCustomElements = {
157+
type: DIST_CUSTOM_ELEMENTS,
158+
empty: false,
159+
};
160+
userConfig.outputTargets = [outputTarget];
161+
162+
const { config } = validateConfig(userConfig, mockLoadConfigInit());
163+
expect(config.outputTargets).toEqual([
164+
{
165+
type: DIST_TYPES,
166+
dir: defaultDistDir,
167+
typesDir: path.join(rootDir, 'dist', 'types'),
168+
},
169+
{
170+
type: DIST_CUSTOM_ELEMENTS,
171+
copy: [],
172+
dir: defaultDistDir,
173+
empty: false,
174+
externalRuntime: true,
175+
generateTypeDeclarations: true,
176+
},
177+
]);
178+
});
179+
180+
it('defaults the "generateTypeDeclarations" field to true it\'s not a boolean', () => {
181+
const outputTarget: d.OutputTargetDistCustomElements = {
182+
type: DIST_CUSTOM_ELEMENTS,
183+
empty: false,
184+
generateTypeDeclarations: undefined,
185+
};
186+
userConfig.outputTargets = [outputTarget];
187+
188+
const { config } = validateConfig(userConfig, mockLoadConfigInit());
189+
expect(config.outputTargets).toEqual([
190+
{
191+
type: DIST_TYPES,
192+
dir: defaultDistDir,
193+
typesDir: path.join(rootDir, 'dist', 'types'),
194+
},
195+
{
196+
type: DIST_CUSTOM_ELEMENTS,
197+
copy: [],
198+
dir: defaultDistDir,
199+
empty: false,
200+
externalRuntime: true,
201+
generateTypeDeclarations: true,
202+
},
203+
]);
204+
});
205+
139206
it('creates a types directory when "generateTypeDeclarations" is true', () => {
140207
const outputTarget: d.OutputTargetDistCustomElements = {
141208
type: DIST_CUSTOM_ELEMENTS,
@@ -231,6 +298,7 @@ describe('validate-output-dist-custom-element', () => {
231298
dir: distCustomElementsDir,
232299
empty: false,
233300
externalRuntime: false,
301+
generateTypeDeclarations: false,
234302
};
235303
userConfig.outputTargets = [outputTarget];
236304

@@ -247,6 +315,7 @@ describe('validate-output-dist-custom-element', () => {
247315
dir: path.join(rootDir, distCustomElementsDir),
248316
empty: false,
249317
externalRuntime: false,
318+
generateTypeDeclarations: false,
250319
},
251320
]);
252321
});

src/compiler/config/validate-config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ export const validateConfig = (
9090
validatedConfig,
9191
'sourceMap',
9292
null,
93-
typeof validatedConfig.sourceMap === 'undefined' ? false : validatedConfig.sourceMap
93+
typeof validatedConfig.sourceMap === 'undefined' ? true : validatedConfig.sourceMap
9494
);
9595
setBooleanConfig(validatedConfig, 'watch', 'watch', false);
9696
setBooleanConfig(validatedConfig, 'buildDocs', 'docs', !validatedConfig.devMode);

0 commit comments

Comments
 (0)