mirror of
https://github.com/angular/angular-cli.git
synced 2025-05-22 06:41:45 +08:00
The checks on existence of @angular/service-worker used the node_modules relative to the project root directly, but those don't exist when using yarn workspaces or lerna. Use resolve.sync instead, which looks up the tree to parent node_modules folders. A similar change is required when loading the service worker script from the @angular/service-worker package. Switch to require.resolve here as well. Fixes #8300
12 lines
400 B
TypeScript
12 lines
400 B
TypeScript
const resolve = require('resolve');
|
|
|
|
// resolve dependencies within the target project
|
|
export function resolveProjectModule(root: string, moduleName: string) {
|
|
return resolve.sync(moduleName, { basedir: root });
|
|
}
|
|
|
|
// require dependencies within the target project
|
|
export function requireProjectModule(root: string, moduleName: string) {
|
|
return require(resolveProjectModule(root, moduleName));
|
|
}
|