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