fix(core): make npm scope optional (#9966)
This commit is contained in:
parent
30a3f93c0c
commit
c3484c775e
@ -1,7 +1,7 @@
|
||||
import { Component } from '@angular/core';
|
||||
|
||||
@Component({
|
||||
selector: '<%= npmScope %>-<%= appName %>-entry',
|
||||
selector: '<%= appName %>-entry',
|
||||
template: `<div class="remote-entry"><h2><%= appName %>'s Remote Entry Component</h2></div>`,
|
||||
styles: [`
|
||||
.remote-entry {
|
||||
@ -10,4 +10,4 @@ import { Component } from '@angular/core';
|
||||
padding: 5px;
|
||||
}`]
|
||||
})
|
||||
export class RemoteEntryComponent {}
|
||||
export class RemoteEntryComponent {}
|
||||
|
||||
@ -12,7 +12,6 @@ export function addEntryModule(
|
||||
appRoot: string
|
||||
) {
|
||||
if (mfeType === 'remote') {
|
||||
const { npmScope } = readWorkspaceConfiguration(host);
|
||||
generateFiles(
|
||||
host,
|
||||
joinPathFragments(__dirname, '../files/entry-module-files'),
|
||||
@ -20,7 +19,6 @@ export function addEntryModule(
|
||||
{
|
||||
tmpl: '',
|
||||
appName,
|
||||
npmScope,
|
||||
routing,
|
||||
}
|
||||
);
|
||||
|
||||
@ -35,7 +35,7 @@ export interface NxJsonConfiguration<T = '*' | string[]> {
|
||||
/**
|
||||
* NPM Scope that the workspace uses
|
||||
*/
|
||||
npmScope: string;
|
||||
npmScope?: string;
|
||||
/**
|
||||
* Default options for `nx affected`
|
||||
*/
|
||||
|
||||
@ -587,10 +587,12 @@ function buildProjectConfigurationFromPackageJson(
|
||||
nxJson: NxJsonConfiguration
|
||||
): ProjectConfiguration & { name: string } {
|
||||
const directory = dirname(path).split('\\').join('/');
|
||||
const npmPrefix = `@${nxJson.npmScope}/`;
|
||||
let name = packageJson.name ?? toProjectName(directory, nxJson);
|
||||
if (name.startsWith(npmPrefix)) {
|
||||
name = name.replace(npmPrefix, '');
|
||||
if (nxJson.npmScope) {
|
||||
const npmPrefix = `@${nxJson.npmScope}/`;
|
||||
if (name.startsWith(npmPrefix)) {
|
||||
name = name.replace(npmPrefix, '');
|
||||
}
|
||||
}
|
||||
return {
|
||||
root: directory,
|
||||
|
||||
@ -490,7 +490,7 @@ class ProjectHasher {
|
||||
res.projects ??= {};
|
||||
return res;
|
||||
} catch {
|
||||
return { npmScope: '' };
|
||||
return {};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -38,7 +38,10 @@ function createPackageNameMap(w: Workspace) {
|
||||
const packageJson = parseJson(
|
||||
defaultFileRead(join(w.projects[projectName].root, 'package.json'))
|
||||
);
|
||||
res[packageJson.name || `@${w.npmScope}/${projectName}`] = projectName;
|
||||
res[
|
||||
packageJson.name ??
|
||||
(w.npmScope ? `@${w.npmScope}/${projectName}` : projectName)
|
||||
] = projectName;
|
||||
} catch (e) {}
|
||||
}
|
||||
return res;
|
||||
|
||||
@ -158,9 +158,6 @@ export function readNxJson(
|
||||
path: string = `${workspaceRoot}/nx.json`
|
||||
): NxJsonConfiguration {
|
||||
let config = readJsonFile<NxJsonConfiguration>(path);
|
||||
if (!config.npmScope) {
|
||||
throw new Error(`nx.json must define the npmScope property.`);
|
||||
}
|
||||
|
||||
if (config.extends) {
|
||||
config = {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user