-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(react): add format option for buildable libs
- Clean up @nrwl/web:package executor - Combine react package e2e tests to speed up test time
- Loading branch information
Showing
15 changed files
with
238 additions
and
195 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
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,55 @@ | ||
import { dirname } from 'path'; | ||
|
||
import { AssetGlobPattern } from '../../../utils/types'; | ||
import { normalizeAssets, normalizePluginPath } from '../../../utils/normalize'; | ||
import { WebPackageOptions } from '../schema'; | ||
|
||
export interface NormalizedWebPackageOptions extends WebPackageOptions { | ||
entryRoot: string; | ||
projectRoot: string; | ||
assets: AssetGlobPattern[]; | ||
rollupConfig: string[]; | ||
formats: string[]; | ||
} | ||
|
||
export function normalizePackageOptions( | ||
options: WebPackageOptions, | ||
root: string, | ||
sourceRoot: string | ||
): NormalizedWebPackageOptions { | ||
const entryFile = `${root}/${options.entryFile}`; | ||
const entryRoot = dirname(entryFile); | ||
const project = `${root}/${options.project}`; | ||
const projectRoot = dirname(project); | ||
const outputPath = `${root}/${options.outputPath}`; | ||
|
||
let formats = []; | ||
for (const format of options.format.split(',')) { | ||
if (format !== 'cjs' && format !== 'esm' && format !== 'umd') | ||
throw new Error(`Invalid format specified: ${format}`); | ||
formats.push(format); | ||
} | ||
// de-dupe formats | ||
formats = Array.from(new Set(formats)); | ||
|
||
if (options.buildableProjectDepsInPackageJsonType == undefined) { | ||
options.buildableProjectDepsInPackageJsonType = 'peerDependencies'; | ||
} | ||
|
||
return { | ||
...options, | ||
formats, | ||
rollupConfig: [] | ||
.concat(options.rollupConfig) | ||
.filter(Boolean) | ||
.map((p) => normalizePluginPath(p, root)), | ||
assets: options.assets | ||
? normalizeAssets(options.assets, root, sourceRoot) | ||
: undefined, | ||
entryFile, | ||
entryRoot, | ||
project, | ||
projectRoot, | ||
outputPath, | ||
}; | ||
} |
File renamed without changes.
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
Oops, something went wrong.