single-spa-angular
Advanced tools
Comparing version 6.1.0 to 6.2.0
import { AppProps } from 'single-spa'; | ||
import { NgModuleRef } from '@angular/core'; | ||
export declare type DomElementGetter = () => HTMLElement; | ||
export declare type DomElementGetter = (props: any) => HTMLElement; | ||
export interface BaseSingleSpaAngularOptions { | ||
template: string; | ||
domElementGetter?(): HTMLElement; | ||
domElementGetter?: DomElementGetter; | ||
bootstrapFunction(props: AppProps): Promise<NgModuleRef<any>>; | ||
} |
@@ -12,3 +12,3 @@ "use strict"; | ||
var _a, _b, _c, _d; | ||
const libraryName = getLibraryName(options); | ||
const libraryName = getLibraryName(config, options); | ||
extraOptions = Object.assign(Object.assign({}, defaultExtraOptions), extraOptions); | ||
@@ -91,3 +91,3 @@ const singleSpaConfig = { | ||
} | ||
function getLibraryName(options) { | ||
function getLibraryName(config, options) { | ||
var _a; | ||
@@ -97,11 +97,11 @@ if ((_a = options === null || options === void 0 ? void 0 : options.customWebpackConfig) === null || _a === void 0 ? void 0 : _a.libraryName) { | ||
} | ||
const projectName = getProjectNameFromAngularJson(options); | ||
const projectName = getProjectNameFromAngularJson(options) || getProjectNameFromWorkspaceJson(config); | ||
if (projectName) | ||
return projectName; | ||
console.warn('Warning: single-spa-angular could not determine a library name to use and has used a default value.'); | ||
console.info('This may cause issues if this app uses code-splitting or lazy loading.'); | ||
console.warn('This may cause issues if this app uses code-splitting or lazy loading.'); | ||
if (!options) { | ||
console.info('You may also need to update extra-webpack.config.json.'); | ||
console.warn('You may also need to update extra-webpack.config.json.'); | ||
} | ||
console.info('See <https://single-spa.js.org/docs/ecosystem-angular/#use-custom-webpack> for information on how to resolve this.'); | ||
console.warn('See <https://single-spa.js.org/docs/ecosystem-angular/#use-custom-webpack> for information on how to resolve this.'); | ||
return 'angular_single_spa_project'; | ||
@@ -137,2 +137,36 @@ } | ||
} | ||
/** | ||
* https://nx.dev/configuration/projectjson#project-configuration | ||
*/ | ||
function getProjectNameFromWorkspaceJson(config) { | ||
// Ensure this is an Nrwl Nx workspace. | ||
const nxJsonPath = (0, find_up_1.findUp)('nx.json', process.cwd()); | ||
if (!nxJsonPath) | ||
return null; | ||
try { | ||
// E.g. `/Users/username/single-spa-angular/apps/shop`. | ||
const [root] = config.resolve.roots; | ||
const workspaceJsonPath = (0, find_up_1.findUp)('workspace.json', process.cwd()); | ||
// The `workspace.json` structure might be as follows: | ||
// { | ||
// "version": 2, | ||
// "projects": { | ||
// "chat": "apps/chat", | ||
// "shop": "apps/shop", | ||
// "my-lib": "libs/my-lib" | ||
// } | ||
// } | ||
const { projects } = JSON.parse(fs.readFileSync(workspaceJsonPath, 'utf8')); | ||
for (const [projectName, projectPath] of Object.entries(projects)) { | ||
// If `/Users/username/single-spa-angular/apps/shop` includes `apps/shop` then return `shop`. | ||
if (root.includes(projectPath)) { | ||
return projectName; | ||
} | ||
} | ||
return null; | ||
} | ||
catch (_a) { | ||
return null; | ||
} | ||
} | ||
function resolveDevtool(options) { | ||
@@ -139,0 +173,0 @@ // If `options.sourceMap = true` or `options.sourceMap.scripts = true` then |
{ | ||
"$schema": "../node_modules/ng-packagr/ng-package.schema.json", | ||
"name": "single-spa-angular", | ||
"version": "6.1.0", | ||
"version": "6.2.0", | ||
"description": "Helpers for building single-spa applications which use Angular 2", | ||
@@ -6,0 +6,0 @@ "schematics": "./schematics/schematics.json", |
@@ -0,2 +1,3 @@ | ||
export { enableProdMode } from './prod-mode'; | ||
export { singleSpaAngular } from './single-spa-angular'; | ||
export { getSingleSpaExtraProviders } from './extra-providers'; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
242223
95
2314