Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(cli): update flag defaults for V3 #3502

Merged
merged 3 commits into from
Aug 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions BREAKING_CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -652,6 +652,7 @@ Stencil v3.0.0 is in development at this time and has not been released. The lis
change. Further details on each of these items will be included prior to the release.

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

## DEPRECATIONS

Expand Down
3 changes: 3 additions & 0 deletions src/compiler/config/outputs/validate-custom-element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ export const validateCustomElement = (
if (!isBoolean(outputTarget.externalRuntime)) {
outputTarget.externalRuntime = true;
}
if (!isBoolean(outputTarget.generateTypeDeclarations)) {
outputTarget.generateTypeDeclarations = true;
}

// unlike other output targets, Stencil does not allow users to define the output location of types at this time
if (outputTarget.generateTypeDeclarations) {
Expand Down
6 changes: 3 additions & 3 deletions src/compiler/config/test/validate-config-sourcemap.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,13 @@ describe('stencil config - sourceMap option', () => {
expect(inlineSources).toBe(false);
});

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

const loadConfigResults = await loadConfig(testConfig);

const { sourceMap, inlineSources } = loadConfigResults.config.tsCompilerOptions;
expect(sourceMap).toBe(false);
expect(inlineSources).toBe(false);
expect(sourceMap).toBe(true);
expect(inlineSources).toBe(true);
});
});
4 changes: 2 additions & 2 deletions src/compiler/config/test/validate-config.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -429,9 +429,9 @@ describe('validation', () => {
expect(config.sourceMap).toBe(false);
});

it('defaults the field to false when not set in the config', () => {
it('defaults the field to true when not set in the config', () => {
const { config } = validateConfig(userConfig, bootstrapConfig);
expect(config.sourceMap).toBe(false);
expect(config.sourceMap).toBe(true);
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,18 @@ describe('validate-output-dist-custom-element', () => {

const { config } = validateConfig(userConfig, mockLoadConfigInit());
expect(config.outputTargets).toEqual([
{
type: DIST_TYPES,
dir: defaultDistDir,
typesDir: path.join(rootDir, 'dist', 'types'),
},
{
type: DIST_CUSTOM_ELEMENTS,
copy: [],
dir: defaultDistDir,
empty: true,
externalRuntime: true,
generateTypeDeclarations: true,
},
]);
});
Expand All @@ -37,6 +43,7 @@ describe('validate-output-dist-custom-element', () => {
const outputTarget: d.OutputTargetDistCustomElements = {
type: DIST_CUSTOM_ELEMENTS,
dir: distCustomElementsDir,
generateTypeDeclarations: false,
};
userConfig.outputTargets = [outputTarget];

Expand All @@ -48,6 +55,7 @@ describe('validate-output-dist-custom-element', () => {
dir: path.join(rootDir, distCustomElementsDir),
empty: true,
externalRuntime: true,
generateTypeDeclarations: false,
},
]);
});
Expand All @@ -57,6 +65,7 @@ describe('validate-output-dist-custom-element', () => {
const outputTarget: d.OutputTargetDistCustomElements = {
type: DIST_CUSTOM_ELEMENTS,
externalRuntime: false,
generateTypeDeclarations: false,
};
userConfig.outputTargets = [outputTarget];

Expand All @@ -68,6 +77,7 @@ describe('validate-output-dist-custom-element', () => {
dir: defaultDistDir,
empty: true,
externalRuntime: false,
generateTypeDeclarations: false,
},
]);
});
Expand All @@ -77,6 +87,7 @@ describe('validate-output-dist-custom-element', () => {
type: DIST_CUSTOM_ELEMENTS,
empty: undefined,
externalRuntime: false,
generateTypeDeclarations: false,
};
userConfig.outputTargets = [outputTarget];

Expand All @@ -88,6 +99,7 @@ describe('validate-output-dist-custom-element', () => {
dir: defaultDistDir,
empty: true,
externalRuntime: false,
generateTypeDeclarations: false,
},
]);
});
Expand All @@ -98,6 +110,7 @@ describe('validate-output-dist-custom-element', () => {
const outputTarget: d.OutputTargetDistCustomElements = {
type: DIST_CUSTOM_ELEMENTS,
empty: false,
generateTypeDeclarations: false,
};
userConfig.outputTargets = [outputTarget];

Expand All @@ -109,6 +122,7 @@ describe('validate-output-dist-custom-element', () => {
dir: defaultDistDir,
empty: false,
externalRuntime: true,
generateTypeDeclarations: false,
},
]);
});
Expand All @@ -118,6 +132,7 @@ describe('validate-output-dist-custom-element', () => {
type: DIST_CUSTOM_ELEMENTS,
empty: false,
externalRuntime: undefined,
generateTypeDeclarations: false,
};
userConfig.outputTargets = [outputTarget];

Expand All @@ -129,12 +144,64 @@ describe('validate-output-dist-custom-element', () => {
dir: defaultDistDir,
empty: false,
externalRuntime: true,
generateTypeDeclarations: false,
},
]);
});
});

describe('"generateTypeDeclarations" field', () => {
it('defaults the "generateTypeDeclarations" field to true if not provided', () => {
const outputTarget: d.OutputTargetDistCustomElements = {
type: DIST_CUSTOM_ELEMENTS,
empty: false,
};
userConfig.outputTargets = [outputTarget];

const { config } = validateConfig(userConfig, mockLoadConfigInit());
expect(config.outputTargets).toEqual([
{
type: DIST_TYPES,
dir: defaultDistDir,
typesDir: path.join(rootDir, 'dist', 'types'),
},
{
type: DIST_CUSTOM_ELEMENTS,
copy: [],
dir: defaultDistDir,
empty: false,
externalRuntime: true,
generateTypeDeclarations: true,
},
]);
});

it('defaults the "generateTypeDeclarations" field to true it\'s not a boolean', () => {
const outputTarget: d.OutputTargetDistCustomElements = {
type: DIST_CUSTOM_ELEMENTS,
empty: false,
generateTypeDeclarations: undefined,
};
userConfig.outputTargets = [outputTarget];

const { config } = validateConfig(userConfig, mockLoadConfigInit());
expect(config.outputTargets).toEqual([
{
type: DIST_TYPES,
dir: defaultDistDir,
typesDir: path.join(rootDir, 'dist', 'types'),
},
{
type: DIST_CUSTOM_ELEMENTS,
copy: [],
dir: defaultDistDir,
empty: false,
externalRuntime: true,
generateTypeDeclarations: true,
},
]);
});

it('creates a types directory when "generateTypeDeclarations" is true', () => {
const outputTarget: d.OutputTargetDistCustomElements = {
type: DIST_CUSTOM_ELEMENTS,
Expand Down Expand Up @@ -230,6 +297,7 @@ describe('validate-output-dist-custom-element', () => {
dir: distCustomElementsDir,
empty: false,
externalRuntime: false,
generateTypeDeclarations: false,
};
userConfig.outputTargets = [outputTarget];

Expand All @@ -246,6 +314,7 @@ describe('validate-output-dist-custom-element', () => {
dir: path.join(rootDir, distCustomElementsDir),
empty: false,
externalRuntime: false,
generateTypeDeclarations: false,
},
]);
});
Expand Down
2 changes: 1 addition & 1 deletion src/compiler/config/validate-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export const validateConfig = (
validatedConfig,
'sourceMap',
null,
typeof validatedConfig.sourceMap === 'undefined' ? false : validatedConfig.sourceMap
typeof validatedConfig.sourceMap === 'undefined' ? true : validatedConfig.sourceMap
);
setBooleanConfig(validatedConfig, 'watch', 'watch', false);
setBooleanConfig(validatedConfig, 'buildDocs', 'docs', !validatedConfig.devMode);
Expand Down