-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
11000d9
commit 72f6cda
Showing
11 changed files
with
156 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
--- | ||
'@backstage/cli': minor | ||
--- | ||
|
||
Adds a new `BACKSTAGE_CLI_BUILD_PARELLEL` environment variable to control | ||
parallelism for some build steps. | ||
|
||
This is useful in CI to help avoid out of memory issues when using `terser`. The | ||
`BACKSTAGE_CLI_BUILD_PARELLEL` environment variable can be set to | ||
`true | false | [integer]` to override the default behaviour. See | ||
[terser-webpack-plugin](https://github.com/webpack-contrib/terser-webpack-plugin#parallel) | ||
for more details. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -196,6 +196,7 @@ validators | |
Voi | ||
Wealthsimple | ||
Weaveworks | ||
Webpack | ||
xyz | ||
yaml | ||
Zalando | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/* | ||
* Copyright 2020 Spotify AB | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import { isParallelDefault, parseParallel } from './parallel'; | ||
|
||
describe('parallel', () => { | ||
describe(parseParallel, () => { | ||
it('coerces "false" string to boolean', () => { | ||
expect(parseParallel('false')).toBeFalsy(); | ||
}); | ||
|
||
it('coerces "true" to boolean', () => { | ||
expect(parseParallel('true')).toBeTruthy(); | ||
}); | ||
|
||
it('coerces number string to number', () => { | ||
expect(parseParallel('2')).toBe(2); | ||
}); | ||
it.each([[true], [false], [2]])('returns itself for %p', value => { | ||
expect(parseParallel(value as any)).toEqual(value); | ||
}); | ||
|
||
it.each([[undefined], [null]])('returns true for %p', value => { | ||
expect(parseParallel(value as any)).toBe(true); | ||
}); | ||
|
||
it.each([['on'], [2.5], ['2.5']])('throws error for %p', value => { | ||
expect(() => parseParallel(value as any)).toThrowError( | ||
`Parallel option value '${value}' is not a boolean or integer`, | ||
); | ||
}); | ||
}); | ||
|
||
describe(isParallelDefault, () => { | ||
it('returns true if default value', () => { | ||
expect(isParallelDefault(undefined)).toBeTruthy(); | ||
expect(isParallelDefault(true)).toBeTruthy(); | ||
}); | ||
|
||
it('returns false if not default value', () => { | ||
expect(isParallelDefault(false)).toBeFalsy(); | ||
expect(isParallelDefault(2)).toBeFalsy(); | ||
expect(isParallelDefault('true' as any)).toBeFalsy(); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* | ||
* Copyright 2020 Spotify AB | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
export const PARALLEL_ENV_VAR = 'BACKSTAGE_CLI_BUILD_PARALLEL'; | ||
|
||
export type ParallelOption = boolean | number | undefined; | ||
|
||
export function isParallelDefault(parallel: ParallelOption) { | ||
return parallel === undefined || parallel === true; | ||
} | ||
|
||
export function parseParallel( | ||
parallel: boolean | string | number | undefined, | ||
): ParallelOption { | ||
if (parallel === undefined || parallel === null) { | ||
return true; | ||
} else if (typeof parallel === 'boolean') { | ||
return parallel; | ||
} else if (typeof parallel === 'number' && Number.isInteger(parallel)) { | ||
return parallel; | ||
} else if (typeof parallel === 'string') { | ||
if (parallel === 'true') { | ||
return true; | ||
} else if (parallel === 'false') { | ||
return false; | ||
} else if (Number.isInteger(parseFloat(parallel.toString()))) { | ||
return Number(parallel); | ||
} | ||
} | ||
|
||
throw Error( | ||
`Parallel option value '${parallel}' is not a boolean or integer`, | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,3 +29,5 @@ declare module '@svgr/rollup' { | |
} | ||
|
||
declare module '@rollup/plugin-yaml'; | ||
|
||
declare module 'terser-webpack-plugin'; |