From 4b0e8dededa223276836ddbcd916dddc39e767f7 Mon Sep 17 00:00:00 2001 From: Olivier Combe Date: Wed, 6 Sep 2023 16:25:59 +0200 Subject: [PATCH] fix linting errors --- .../angular-elements.compiler.ts | 4 ++-- .../angular-elements/preview/mount.tsx | 2 +- .../rollup/ngc-plugin/index.ts | 2 +- .../rollup/rollup.compiler.ts | 6 ++--- .../angular-elements/rollup/utils/fs.ts | 6 +---- .../ng-multi-compiler.task.ts | 2 +- .../ng-multi-compiler/ng-multi-compiler.ts | 15 ++++++------ .../ng-packagr/ng-packagr.compiler.ts | 14 +++++------ .../compiler/ngcc/ngcc-processor.ts | 4 ++-- .../compiler/webpack/ng-webpack-bundler.ts | 4 ++-- .../compiler/webpack/ng-webpack-dev-server.ts | 4 ++-- .../webpack-plugins/angular-resolver.ts | 6 ++--- .../webpack-plugins/nodejs-file-system.ts | 21 +++++++++++++++++ .../preview/angular-runtime/loader.ts | 23 ++++++++++--------- .../preview/angular-runtime/main.ts | 9 ++++---- .../preview/angular-runtime/native-shim.js | 2 +- .../dev-services/preview/preview/mounter.ts | 1 + .../my-angular-env.bit-env.ts | 7 +++--- .../angular-env-default/preview/mounter.ts | 1 + .../angular-env-v12/my-angular-env.bit-env.ts | 7 +++--- .../forks/angular-env-v12/preview/mounter.ts | 1 + .../angular-env-v13/my-angular-env.bit-env.ts | 7 +++--- .../forks/angular-env-v13/preview/mounter.ts | 1 + .../angular-env-v14/my-angular-env.bit-env.ts | 7 +++--- .../forks/angular-env-v14/preview/mounter.ts | 1 + .../angular-env-v15/my-angular-env.bit-env.ts | 7 +++--- .../forks/angular-env-v15/preview/mounter.ts | 1 + .../angular-env-v16/my-angular-env.bit-env.ts | 7 +++--- .../forks/angular-env-v16/preview/mounter.ts | 1 + .../angular-starters/design-system/index.ts | 4 ++-- scopes/generators/angular-starters/index.ts | 1 + .../material-design-system/index.ts | 4 ++-- .../ng-app/template-files/index.ts | 4 ++-- .../src/app/app.component-html.ts | 1 - .../src/app/app.component-scss.ts | 1 - .../src/app/app.component-spec.ts | 2 +- .../template-files/src/app/app.component.ts | 2 +- .../template-files/src/app/app.module.ts | 1 - .../template-files/src/assets/gitkeep.ts | 1 - .../src/environments/environment.prod.ts | 1 - .../src/environments/environment.ts | 1 - .../ng-app/template-files/src/index-html.ts | 4 ++-- .../ng-app/template-files/src/main.ts | 1 - .../ng-app/template-files/src/polyfills.ts | 1 - .../ng-app/template-files/src/styles.ts | 1 - .../angular-templates/ng-env/files/doc.ts | 2 +- .../ng-env/files/env-jsonc.ts | 2 -- .../angular-templates/ng-env/files/env.ts | 2 +- .../ng-env/files/preview/mounter.ts | 2 +- .../angular-templates/ng-env/index.ts | 2 +- .../angular-v12/angular-v12.bit-env.ts | 2 +- .../versions/angular-v12/jest/jest.config.ts | 1 + .../angular-v13/angular-v13.bit-env.ts | 2 +- .../versions/angular-v13/jest/jest.config.ts | 1 + .../angular-v14/angular-v14.bit-env.ts | 2 +- .../versions/angular-v14/jest/jest.config.ts | 1 + .../angular-v14/jest/jest.resolver.ts | 4 ++-- .../angular-v15/angular-v15.bit-env.ts | 2 +- .../versions/angular-v15/jest/jest.config.ts | 1 + .../angular-v15/jest/jest.resolver.ts | 4 ++-- .../angular-v16/angular-v16.bit-env.ts | 2 +- .../versions/angular-v16/jest/jest.config.ts | 2 ++ .../angular-v16/jest/jest.resolver.ts | 4 ++-- .../angular-apps/angular.application.ts | 4 ++-- .../angular-base/angular-base.bit-env.ts | 11 ++++----- .../common/angular-base/preview/mounter.ts | 1 + 66 files changed, 137 insertions(+), 120 deletions(-) diff --git a/scopes/dev-services/compiler/angular-elements/angular-elements.compiler.ts b/scopes/dev-services/compiler/angular-elements/angular-elements.compiler.ts index be7b5889..d155da94 100644 --- a/scopes/dev-services/compiler/angular-elements/angular-elements.compiler.ts +++ b/scopes/dev-services/compiler/angular-elements/angular-elements.compiler.ts @@ -2,7 +2,6 @@ import type { AngularCompilerOptions } from '@angular/compiler-cli'; import { componentIsApp } from '@teambit/angular-apps'; import type { AngularEnvOptions } from '@teambit/angular-common'; import { getNodeModulesPaths, getWorkspace } from '@teambit/angular-common'; -import { RollupCompiler } from './rollup/rollup.compiler'; import { ApplicationAspect, ApplicationMain } from '@teambit/application'; import { ArtifactDefinition, @@ -21,6 +20,7 @@ import { NgccProcessor } from '@teambit/ngcc'; import { Workspace, WorkspaceAspect } from '@teambit/workspace'; import chalk from 'chalk'; import { extname, join } from 'path'; +import { RollupCompiler } from './rollup/rollup.compiler'; interface AngularElementsCompilerOptions { ngPackagrModulePath?: string; @@ -109,7 +109,7 @@ Built Angular Compositions } // Build compositions await this.compositionsCompilation(params.component, params.componentDir, params.outputDir, true); - return; + // } // TODO: implement compilation of components as webcomponents // throw new Error('not implemented'); diff --git a/scopes/dev-services/compiler/angular-elements/preview/mount.tsx b/scopes/dev-services/compiler/angular-elements/preview/mount.tsx index 755e6e3d..08634de2 100644 --- a/scopes/dev-services/compiler/angular-elements/preview/mount.tsx +++ b/scopes/dev-services/compiler/angular-elements/preview/mount.tsx @@ -11,7 +11,7 @@ const root = document.getElementById('root') as HTMLElement; * this function can be overridden through ReactAspect.overrideCompositionsMounter() API * to apply custom logic for component DOM mounting. */ -export default async (composition: any/*, previewContext: RenderingContext*/) => { +export default async (composition: any/* , previewContext: RenderingContext */) => { ReactDOM.render(
{await ngToReact([composition])}
, root diff --git a/scopes/dev-services/compiler/angular-elements/rollup/ngc-plugin/index.ts b/scopes/dev-services/compiler/angular-elements/rollup/ngc-plugin/index.ts index 4d8bf32b..ff0d4f57 100644 --- a/scopes/dev-services/compiler/angular-elements/rollup/ngc-plugin/index.ts +++ b/scopes/dev-services/compiler/angular-elements/rollup/ngc-plugin/index.ts @@ -66,7 +66,7 @@ export async function ngcPlugin(options: Options, logger: Logger): Promise; @@ -51,14 +51,14 @@ export class RollupCompiler { } async bundleFiles(opts: RollupOptions) { - const cacheDirectory = opts.cacheDirectory; + const {cacheDirectory} = opts; /** File system used by the Angular linker plugin. */ const NodeJSFileSystem = await getNodeJSFileSystem(); const fileSystem = new NodeJSFileSystem(); /** Logger used by the Angular linker plugin. */ - let ConsoleLogger: any, LogLevel: any; + let ConsoleLogger: any; let LogLevel: any; const ngCompilerCliApi = await ngCompilerCli() as any; if (ngCompilerCliApi.ConsoleLogger && ngCompilerCliApi.LogLevel) { ConsoleLogger = ngCompilerCliApi.ConsoleLogger; diff --git a/scopes/dev-services/compiler/angular-elements/rollup/utils/fs.ts b/scopes/dev-services/compiler/angular-elements/rollup/utils/fs.ts index 270d7420..7b72c0f9 100644 --- a/scopes/dev-services/compiler/angular-elements/rollup/utils/fs.ts +++ b/scopes/dev-services/compiler/angular-elements/rollup/utils/fs.ts @@ -2,11 +2,7 @@ import * as fs from 'fs'; import { dirname } from 'path'; import { promisify } from 'util'; -export const readFile = fs.promises.readFile; -export const writeFile = fs.promises.writeFile; -export const access = fs.promises.access; -export const mkdir = fs.promises.mkdir; -export const stat = fs.promises.stat; +export const {readFile, writeFile, access, mkdir, stat} = fs.promises; // @ts-ignore export const rmdir = fs.promises.rm ?? fs.promises.rmdir; diff --git a/scopes/dev-services/compiler/ng-multi-compiler/ng-multi-compiler.task.ts b/scopes/dev-services/compiler/ng-multi-compiler/ng-multi-compiler.task.ts index d52e999c..9de678de 100644 --- a/scopes/dev-services/compiler/ng-multi-compiler/ng-multi-compiler.task.ts +++ b/scopes/dev-services/compiler/ng-multi-compiler/ng-multi-compiler.task.ts @@ -16,7 +16,7 @@ export const NgMultiCompilerTask = { const description = options.description || 'compiling components using NgMultiCompiler'; return CompilerTask.from({ - name: name, + name, description, compiler: options.ngMultiCompiler }); diff --git a/scopes/dev-services/compiler/ng-multi-compiler/ng-multi-compiler.ts b/scopes/dev-services/compiler/ng-multi-compiler/ng-multi-compiler.ts index b4a49ea8..1fe05528 100644 --- a/scopes/dev-services/compiler/ng-multi-compiler/ng-multi-compiler.ts +++ b/scopes/dev-services/compiler/ng-multi-compiler/ng-multi-compiler.ts @@ -63,6 +63,7 @@ export class NgMultiCompiler implements Compiler { } private _babelCompiler!: BabelCompiler; + get babelCompiler(): BabelCompiler { if (!this._babelCompiler) { this._babelCompiler = this.babelMain.createCompiler({ @@ -95,9 +96,9 @@ export class NgMultiCompiler implements Compiler { } if (params.initiator === CompilationInitiator.PreStart || params.initiator === CompilationInitiator.Start) { return this.mainCompiler.transpileComponent(params); - } else { + } return this.ngPackagrCompiler.transpileComponent(params); - } + } transpileFile(fileContent: string, params: TranspileFileParams): TranspileFileOutput { @@ -122,7 +123,7 @@ export class NgMultiCompiler implements Compiler { */ async build(context: BuildContext): Promise { const componentsResults: ComponentResult[] = []; - let capsules = context.capsuleNetwork.seedersCapsules; + const capsules = context.capsuleNetwork.seedersCapsules; // compile all app entry files with babel const appComponentCapsules = capsules.filter(capsule => componentIsApp(capsule.component, this.application)); appComponentCapsules.forEach((capsule: Capsule) => { @@ -200,12 +201,12 @@ export class NgMultiCompiler implements Compiler { const application = context.getAspect(ApplicationAspect.id); const ngPackagrCompiler = NgPackagrCompiler.from({ - artifactName: artifactName, - distDir: distDir, - distGlobPatterns: distGlobPatterns, + artifactName, + distDir, + distGlobPatterns, ngEnvOptions: options.ngEnvOptions, ngPackagrModulePath, - shouldCopyNonSupportedFiles: shouldCopyNonSupportedFiles, + shouldCopyNonSupportedFiles, tsCompilerOptions: options.tsCompilerOptions })(context); diff --git a/scopes/dev-services/compiler/ng-packagr/ng-packagr.compiler.ts b/scopes/dev-services/compiler/ng-packagr/ng-packagr.compiler.ts index 6a523174..9f0963aa 100644 --- a/scopes/dev-services/compiler/ng-packagr/ng-packagr.compiler.ts +++ b/scopes/dev-services/compiler/ng-packagr/ng-packagr.compiler.ts @@ -99,7 +99,7 @@ export class NgPackagrCompiler implements Compiler { } else { // Angular v13+ this.readDefaultTsConfig = async() => { - const initializeTsConfig = module.initializeTsConfig; + const {initializeTsConfig} = module; const entryPoints: any = [{ data: { entryPoint: { @@ -133,7 +133,7 @@ export class NgPackagrCompiler implements Compiler { updatePackageJson.exports = packageJson.exports; props.forEach(prop => { if (packageJson.exports['.'][prop]) { - updatePackageJson.exports['.'][prop] = './' + posix.join(this.distDir, packageJson.exports['.'][prop]); + updatePackageJson.exports['.'][prop] = `./${ posix.join(this.distDir, packageJson.exports['.'][prop])}`; } }); } @@ -151,7 +151,7 @@ export class NgPackagrCompiler implements Compiler { // check for dependencies other than tslib and move them to peer dependencies // see https://github.com/ng-packagr/ng-packagr/blob/master/docs/dependencies.md#general-recommendation-use-peerdependencies-whenever-possible const packageJson = PackageJsonFile.loadFromPathSync(pathToOutputFolder, ''); - const dependencies = packageJson.packageJsonObject.dependencies; + const {dependencies} = packageJson.packageJsonObject; // const peerDependencies = packageJson.packageJsonObject.peerDependencies; const allowedNonPeerDependencies: string[] = []; const depKeys = Object.keys(dependencies).filter(dep => dep !== 'tslib'); // only tslib is allowed in dependencies @@ -228,8 +228,8 @@ export class NgPackagrCompiler implements Compiler { const dist = join(params.outputDir, this.distDir); mkdirsSync(dist); // We do not need to compile using ng-packagr (except for builds) because Angular reads the source files directly - return; - /*const isApp = componentIsApp(params.component, this.application); + + /* const isApp = componentIsApp(params.component, this.application); // No need to compile an app if (isApp) { return; @@ -251,7 +251,7 @@ export class NgPackagrCompiler implements Compiler { this.logger.off(); // Build component package await this.ngPackagrCompilation(params.componentDir, params.outputDir, this.tsCompilerOptions, false); - this.logger.on();*/ + this.logger.on(); */ } private getArtifactDefinition(): ArtifactDefinition[] { @@ -289,7 +289,7 @@ export class NgPackagrCompiler implements Compiler { const componentsResults: ComponentResult[] = []; for (const capsule of componentCapsules) { - const component = capsule.component; + const {component} = capsule; const currentComponentResult: ComponentResult = { component }; diff --git a/scopes/dev-services/compiler/ngcc/ngcc-processor.ts b/scopes/dev-services/compiler/ngcc/ngcc-processor.ts index 05927080..a4b849db 100644 --- a/scopes/dev-services/compiler/ngcc/ngcc-processor.ts +++ b/scopes/dev-services/compiler/ngcc/ngcc-processor.ts @@ -59,7 +59,7 @@ export class NgccProcessor { // The hash is used directly in the file name to mitigate potential read/write race // conditions as well as to only require a file existence check - this.runHashFilePath = path.join(tempFolder, runHash + '.lock'); + this.runHashFilePath = path.join(tempFolder, `${runHash }.lock`); // If the run hash lock file exists, then ngcc was already run against this project state if (existsSync(this.runHashFilePath)) { @@ -101,7 +101,7 @@ export class NgccProcessor { if (status !== 0) { const errorMessage = error?.message || ''; - throw new Error(errorMessage + `NGCC failed${errorMessage ? ', see above' : ''}.`); + throw new Error(`${errorMessage }NGCC failed${errorMessage ? ', see above' : ''}.`); } // ngcc was successful so if a run hash was generated, write it for next time diff --git a/scopes/dev-services/compiler/webpack/ng-webpack-bundler.ts b/scopes/dev-services/compiler/webpack/ng-webpack-bundler.ts index 00851d73..433bdf43 100644 --- a/scopes/dev-services/compiler/webpack/ng-webpack-bundler.ts +++ b/scopes/dev-services/compiler/webpack/ng-webpack-bundler.ts @@ -74,7 +74,7 @@ export class NgWebpackBundler { const webpackBuildConfigFactory: WebpackBuildConfigFactory = options.ngEnvOptions.webpackConfigFactory; const name = options.name || 'ng-webpack-bundler'; const logger = context.createLogger(name); - const bundlerContext = options.bundlerContext; + const {bundlerContext} = options; const workspace = getWorkspace(context); const pkg = context.getAspect(PkgAspect.id); const application = context.getAspect(ApplicationAspect.id); @@ -90,7 +90,7 @@ export class NgWebpackBundler { tempFolder = join(CACHE_ROOT, idName); } - let appRootPath: string, tsconfigPath: string; + let appRootPath: string; let tsconfigPath: string; let plugins: WebpackPluginInstance[] = []; if (isAppBuildContext(bundlerContext)) { // When you use `bit run ` appRootPath = bundlerContext.capsule.path;// this.workspace?.componentDir(context.appComponent.id, {ignoreScopeAndVersion: true, ignoreVersion: true}) || ''; diff --git a/scopes/dev-services/compiler/webpack/ng-webpack-dev-server.ts b/scopes/dev-services/compiler/webpack/ng-webpack-dev-server.ts index 14f566f1..c8c77b64 100644 --- a/scopes/dev-services/compiler/webpack/ng-webpack-dev-server.ts +++ b/scopes/dev-services/compiler/webpack/ng-webpack-dev-server.ts @@ -77,7 +77,7 @@ export class NgWebpackDevServer { const name = options.name || 'ng-webpack-dev-server'; const logger = context.createLogger(name); - const devServerContext = options.devServerContext; + const {devServerContext} = options; const workspace = getWorkspace(context); const webpackMain = context.getAspect(WebpackAspect.id); const pkg = context.getAspect(PkgAspect.id); @@ -93,7 +93,7 @@ export class NgWebpackDevServer { tempFolder = join(CACHE_ROOT, idName); } - let appRootPath: string, tsconfigPath: string; + let appRootPath: string; let tsconfigPath: string; let isApp = false; if (isAppContext(devServerContext)) { // When you use `bit run ` appRootPath = workspace?.componentDir(devServerContext.appComponent.id, { diff --git a/scopes/dev-services/compiler/webpack/webpack-plugins/angular-resolver.ts b/scopes/dev-services/compiler/webpack/webpack-plugins/angular-resolver.ts index b0710c31..7939c219 100644 --- a/scopes/dev-services/compiler/webpack/webpack-plugins/angular-resolver.ts +++ b/scopes/dev-services/compiler/webpack/webpack-plugins/angular-resolver.ts @@ -178,10 +178,10 @@ export class BitDedupeModuleResolvePlugin { || V16_ANGULAR_FORMATS.every(f => Object.keys(entryPointPackageJson as JsonObject).includes(f)) ) { return true; - } else { - const metadataPath = this.fs.resolve(entryPointPath, typings.replace(/\.d\.ts$/, '') + '.metadata.json'); + } + const metadataPath = this.fs.resolve(entryPointPath, `${typings.replace(/\.d\.ts$/, '') }.metadata.json`); return this.fs.exists(metadataPath); - } + } getIssuer(result: any) { diff --git a/scopes/dev-services/compiler/webpack/webpack-plugins/nodejs-file-system.ts b/scopes/dev-services/compiler/webpack/webpack-plugins/nodejs-file-system.ts index 5f425470..d3d91c68 100644 --- a/scopes/dev-services/compiler/webpack/webpack-plugins/nodejs-file-system.ts +++ b/scopes/dev-services/compiler/webpack/webpack-plugins/nodejs-file-system.ts @@ -104,9 +104,11 @@ export class NodeJSPathManipulation implements PathManipulation { pwd(): AbsoluteFsPath { return this.normalize(process.cwd()) as AbsoluteFsPath; } + chdir(dir: AbsoluteFsPath): void { process.chdir(dir); } + resolve(...paths: string[]): AbsoluteFsPath { return this.normalize(p.resolve(...paths)) as AbsoluteFsPath; } @@ -114,24 +116,31 @@ export class NodeJSPathManipulation implements PathManipulation { dirname(file: T): T { return this.normalize(p.dirname(file)) as T; } + join(basePath: T, ...paths: string[]): T { return this.normalize(p.join(basePath, ...paths)) as T; } + isRoot(path: AbsoluteFsPath): boolean { return this.dirname(path) === this.normalize(path); } + isRooted(path: string): boolean { return p.isAbsolute(path); } + relative(from: T, to: T): PathSegment|AbsoluteFsPath { return this.normalize(p.relative(from, to)) as PathSegment | AbsoluteFsPath; } + basename(filePath: string, extension?: string): PathSegment { return p.basename(filePath, extension) as PathSegment; } + extname(path: AbsoluteFsPath|PathSegment): string { return p.extname(path); } + normalize(path: T): T { // Convert backslashes to forward slashes return path.replace(/\\/g, '/') as T; @@ -146,21 +155,27 @@ export class NodeJSReadonlyFileSystem extends NodeJSPathManipulation implements exists(path: AbsoluteFsPath): boolean { return fs.existsSync(path); } + readFile(path: AbsoluteFsPath): string { return fs.readFileSync(path, 'utf8'); } + readFileBuffer(path: AbsoluteFsPath): Uint8Array { return fs.readFileSync(path); } + readdir(path: AbsoluteFsPath): PathSegment[] { return fs.readdirSync(path) as PathSegment[]; } + lstat(path: AbsoluteFsPath): FileStats { return fs.lstatSync(path); } + stat(path: AbsoluteFsPath): FileStats { return fs.statSync(path); } + realpath(path: AbsoluteFsPath): AbsoluteFsPath { return this.resolve(fs.realpathSync(path)); } @@ -173,18 +188,23 @@ export class NodeJSFileSystem extends NodeJSReadonlyFileSystem implements FileSy writeFile(path: AbsoluteFsPath, data: string|Uint8Array, exclusive = false): void { fs.writeFileSync(path, data, exclusive ? {flag: 'wx'} : undefined); } + removeFile(path: AbsoluteFsPath): void { fs.unlinkSync(path); } + symlink(target: AbsoluteFsPath, path: AbsoluteFsPath): void { fs.symlinkSync(target, path); } + copyFile(from: AbsoluteFsPath, to: AbsoluteFsPath): void { fs.copyFileSync(from, to); } + moveFile(from: AbsoluteFsPath, to: AbsoluteFsPath): void { fs.renameSync(from, to); } + ensureDir(path: AbsoluteFsPath): void { const parents: AbsoluteFsPath[] = []; while (!this.isRoot(path) && !this.exists(path)) { @@ -195,6 +215,7 @@ export class NodeJSFileSystem extends NodeJSReadonlyFileSystem implements FileSy this.safeMkdir(parents.pop()!); } } + removeDeep(path: AbsoluteFsPath): void { fs.rmdirSync(path, {recursive: true}); } diff --git a/scopes/dev-services/preview/angular-runtime/loader.ts b/scopes/dev-services/preview/angular-runtime/loader.ts index e85b4c8f..12868d98 100644 --- a/scopes/dev-services/preview/angular-runtime/loader.ts +++ b/scopes/dev-services/preview/angular-runtime/loader.ts @@ -1,8 +1,4 @@ // Only load those if we are in the browser -if (typeof window !== 'undefined') { - require('./native-shim.js'); - require('zone.js/dist/zone'); -} import { Injector, NgModuleRef, Type } from '@angular/core'; import { createCustomElement } from '@angular/elements'; import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; @@ -16,6 +12,11 @@ import { bootstrapApplication } from "@angular/platform-browser"; import { createComponent, NgZone, StaticProvider } from '@angular/core'; // @ts-ignore unavailable until Angular 14 import { createApplication } from '@angular/platform-browser'; + +if (typeof window !== 'undefined') { + require('./native-shim.js'); + require('zone.js/dist/zone'); +} // @ts-ignore const AppModule = require('./main').AppModule as any; @@ -155,9 +156,9 @@ export async function ngToCustomElements(modulesOrComponents: Type[], appli // elements detached from the DOM when we unmount them. We need to keep the appRef alive to be able to reattach. appRef = null; return createCustomElements(componentsToLoad, rootInjector); - } else { + } throw new Error('Unable to load any composition, the Angular env can only load modules or components'); - } + } export interface NgBootstrapOptions { @@ -196,7 +197,7 @@ export async function ngBootstrap(modulesOrComponents: Type | Type[ console.warn('wrapperComponentSelector is only used for Angular v13 and below, starting with v14 you need to use a standalone component wrapper with ``'); } return wrapComponent(options.hostElement, options.wrapper, componentsToLoad, options.appConfig); - } else { + } const selectors: string[] = []; componentsToLoad.forEach((component: Type) => { const selector = getCmpSelector(component); @@ -214,15 +215,15 @@ export async function ngBootstrap(modulesOrComponents: Type | Type[ } return bootstrap(parentModule || AppModule, undefined, options.appConfig); - } - } else { + + } throw new Error('Unable to load any composition, the Angular env can only load modules or components'); - } + } else { // for v13 and below we need to use angular elements to be able to load standalone components // if (options.wrapperComponent) { // throw new Error('WrapperComponent is only supported in Angular v14 and above'); // } - let hostElement: Element | ShadowRoot = options.hostElement; + let {hostElement} = options; if (options.wrapper) { const wrapperSelector = await ngToCustomElements([options.wrapper], options.appConfig); const wrapperElement = replaceDomElements(hostElement, wrapperSelector)[0]; diff --git a/scopes/dev-services/preview/angular-runtime/main.ts b/scopes/dev-services/preview/angular-runtime/main.ts index dfccb7cb..79c7307c 100644 --- a/scopes/dev-services/preview/angular-runtime/main.ts +++ b/scopes/dev-services/preview/angular-runtime/main.ts @@ -1,6 +1,7 @@ +import { BrowserModule } from '@angular/platform-browser'; + require('zone.js/dist/zone'); const i0 = require('@angular/core') as any; -import { BrowserModule } from '@angular/platform-browser'; // The injector used to create custom elements from Angular components class AppComponent { @@ -8,7 +9,7 @@ class AppComponent { // @ts-ignore AppComponent.ɵfac = function AppComponent_Factory(t) { return new (t || AppComponent)(); }; // @ts-ignore -AppComponent.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: AppComponent, selectors: [["app-root"]], decls: 0, vars: 0, template: function AppComponent_Template(rf, ctx) { }, encapsulation: 2 }); +AppComponent.ɵcmp = /* @__PURE__ */ i0.ɵɵdefineComponent({ type: AppComponent, selectors: [["app-root"]], decls: 0, vars: 0, template: function AppComponent_Template(rf, ctx) { }, encapsulation: 2 }); (function () { // @ts-ignore (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(AppComponent, [{ type: i0.Component, @@ -24,9 +25,9 @@ class AppModule { // @ts-ignore AppModule.ɵfac = function AppModule_Factory(t) { return new (t || AppModule)(); }; // @ts-ignore -AppModule.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: AppModule }); +AppModule.ɵmod = /* @__PURE__ */ i0.ɵɵdefineNgModule({ type: AppModule }); // @ts-ignore -AppModule.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [[BrowserModule]] }); +AppModule.ɵinj = /* @__PURE__ */ i0.ɵɵdefineInjector({ imports: [[BrowserModule]] }); (function () { // @ts-ignore (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(AppModule, [{ type: i0.NgModule, diff --git a/scopes/dev-services/preview/angular-runtime/native-shim.js b/scopes/dev-services/preview/angular-runtime/native-shim.js index 28ab1983..62030da0 100644 --- a/scopes/dev-services/preview/angular-runtime/native-shim.js +++ b/scopes/dev-services/preview/angular-runtime/native-shim.js @@ -38,7 +38,7 @@ return Reflect.construct(BuiltInHTMLElement, [], this.constructor); } }; - window.HTMLElement = wrapperForTheName['HTMLElement']; + window.HTMLElement = wrapperForTheName.HTMLElement; HTMLElement.prototype = BuiltInHTMLElement.prototype; HTMLElement.prototype.constructor = HTMLElement; Object.setPrototypeOf(HTMLElement, BuiltInHTMLElement); diff --git a/scopes/dev-services/preview/preview/mounter.ts b/scopes/dev-services/preview/preview/mounter.ts index 0015a47c..a681ee30 100644 --- a/scopes/dev-services/preview/preview/mounter.ts +++ b/scopes/dev-services/preview/preview/mounter.ts @@ -1,3 +1,4 @@ +/* eslint-disable import/no-unresolved */ import { createMounter } from '@teambit/angular-mounter'; export default createMounter(); diff --git a/scopes/forks/angular-env-default/my-angular-env.bit-env.ts b/scopes/forks/angular-env-default/my-angular-env.bit-env.ts index 136380dc..2853afad 100644 --- a/scopes/forks/angular-env-default/my-angular-env.bit-env.ts +++ b/scopes/forks/angular-env-default/my-angular-env.bit-env.ts @@ -110,11 +110,10 @@ export class MyAngularEnv extends AngularEnv { */ override generators(): EnvHandler { const envName = this.constructor.name; - const angularVersion = this.angularVersion; return TemplateList.from([ - NgModuleTemplate.from({envName, angularVersion}), - NgEnvTemplate.from({envName, angularVersion}), - NgAppTemplate.from({envName, angularVersion}) + NgModuleTemplate.from({envName, angularVersion: this.angularVersion}), + NgEnvTemplate.from({envName, angularVersion: this.angularVersion}), + NgAppTemplate.from({envName, angularVersion: this.angularVersion}) ]); } diff --git a/scopes/forks/angular-env-default/preview/mounter.ts b/scopes/forks/angular-env-default/preview/mounter.ts index 56ca3a8b..7a974b6b 100644 --- a/scopes/forks/angular-env-default/preview/mounter.ts +++ b/scopes/forks/angular-env-default/preview/mounter.ts @@ -1,3 +1,4 @@ +/* eslint-disable import/no-unresolved */ import { createMounter } from '@teambit/angular-mounter'; import { Component, ViewEncapsulation } from '@angular/core'; diff --git a/scopes/forks/angular-env-v12/my-angular-env.bit-env.ts b/scopes/forks/angular-env-v12/my-angular-env.bit-env.ts index 668656c0..cb1a6656 100644 --- a/scopes/forks/angular-env-v12/my-angular-env.bit-env.ts +++ b/scopes/forks/angular-env-v12/my-angular-env.bit-env.ts @@ -110,11 +110,10 @@ export class MyAngularEnv extends AngularV12Env { */ override generators(): EnvHandler { const envName = this.constructor.name; - const angularVersion = this.angularVersion; return TemplateList.from([ - NgModuleTemplate.from({envName, angularVersion}), - NgEnvTemplate.from({envName, angularVersion}), - NgAppTemplate.from({envName, angularVersion}) + NgModuleTemplate.from({envName, angularVersion: this.angularVersion}), + NgEnvTemplate.from({envName, angularVersion: this.angularVersion}), + NgAppTemplate.from({envName, angularVersion: this.angularVersion}) ]); } diff --git a/scopes/forks/angular-env-v12/preview/mounter.ts b/scopes/forks/angular-env-v12/preview/mounter.ts index d0ea7780..e7f3e6c2 100644 --- a/scopes/forks/angular-env-v12/preview/mounter.ts +++ b/scopes/forks/angular-env-v12/preview/mounter.ts @@ -1,3 +1,4 @@ +/* eslint-disable */ import { createMounter } from '@teambit/angular-mounter'; import { Component, NgModule, ViewEncapsulation } from '@angular/core'; diff --git a/scopes/forks/angular-env-v13/my-angular-env.bit-env.ts b/scopes/forks/angular-env-v13/my-angular-env.bit-env.ts index 2704f60f..aafe1333 100644 --- a/scopes/forks/angular-env-v13/my-angular-env.bit-env.ts +++ b/scopes/forks/angular-env-v13/my-angular-env.bit-env.ts @@ -110,11 +110,10 @@ export class MyAngularEnv extends AngularV13Env { */ override generators(): EnvHandler { const envName = this.constructor.name; - const angularVersion = this.angularVersion; return TemplateList.from([ - NgModuleTemplate.from({envName, angularVersion}), - NgEnvTemplate.from({envName, angularVersion}), - NgAppTemplate.from({envName, angularVersion}) + NgModuleTemplate.from({envName, angularVersion: this.angularVersion}), + NgEnvTemplate.from({envName, angularVersion: this.angularVersion}), + NgAppTemplate.from({envName, angularVersion: this.angularVersion}) ]); } diff --git a/scopes/forks/angular-env-v13/preview/mounter.ts b/scopes/forks/angular-env-v13/preview/mounter.ts index d0ea7780..e7f3e6c2 100644 --- a/scopes/forks/angular-env-v13/preview/mounter.ts +++ b/scopes/forks/angular-env-v13/preview/mounter.ts @@ -1,3 +1,4 @@ +/* eslint-disable */ import { createMounter } from '@teambit/angular-mounter'; import { Component, NgModule, ViewEncapsulation } from '@angular/core'; diff --git a/scopes/forks/angular-env-v14/my-angular-env.bit-env.ts b/scopes/forks/angular-env-v14/my-angular-env.bit-env.ts index fcf33f1b..34d3a2a4 100644 --- a/scopes/forks/angular-env-v14/my-angular-env.bit-env.ts +++ b/scopes/forks/angular-env-v14/my-angular-env.bit-env.ts @@ -110,11 +110,10 @@ export class MyAngularEnv extends AngularV14Env { */ override generators(): EnvHandler { const envName = this.constructor.name; - const angularVersion = this.angularVersion; return TemplateList.from([ - NgModuleTemplate.from({envName, angularVersion}), - NgEnvTemplate.from({envName, angularVersion}), - NgAppTemplate.from({envName, angularVersion}) + NgModuleTemplate.from({envName, angularVersion: this.angularVersion}), + NgEnvTemplate.from({envName, angularVersion: this.angularVersion}), + NgAppTemplate.from({envName, angularVersion: this.angularVersion}) ]); } diff --git a/scopes/forks/angular-env-v14/preview/mounter.ts b/scopes/forks/angular-env-v14/preview/mounter.ts index 274c3216..5ec70032 100644 --- a/scopes/forks/angular-env-v14/preview/mounter.ts +++ b/scopes/forks/angular-env-v14/preview/mounter.ts @@ -1,3 +1,4 @@ +/* eslint-disable import/no-unresolved */ import { createMounter } from '@teambit/angular-mounter'; import { Component, ViewEncapsulation } from '@angular/core'; diff --git a/scopes/forks/angular-env-v15/my-angular-env.bit-env.ts b/scopes/forks/angular-env-v15/my-angular-env.bit-env.ts index 843fd942..8551b15a 100644 --- a/scopes/forks/angular-env-v15/my-angular-env.bit-env.ts +++ b/scopes/forks/angular-env-v15/my-angular-env.bit-env.ts @@ -110,11 +110,10 @@ export class MyAngularEnv extends AngularV15Env { */ override generators(): EnvHandler { const envName = this.constructor.name; - const angularVersion = this.angularVersion; return TemplateList.from([ - NgModuleTemplate.from({envName, angularVersion}), - NgEnvTemplate.from({envName, angularVersion}), - NgAppTemplate.from({envName, angularVersion}) + NgModuleTemplate.from({envName, angularVersion: this.angularVersion}), + NgEnvTemplate.from({envName, angularVersion: this.angularVersion}), + NgAppTemplate.from({envName, angularVersion: this.angularVersion}) ]); } diff --git a/scopes/forks/angular-env-v15/preview/mounter.ts b/scopes/forks/angular-env-v15/preview/mounter.ts index 274c3216..5ec70032 100644 --- a/scopes/forks/angular-env-v15/preview/mounter.ts +++ b/scopes/forks/angular-env-v15/preview/mounter.ts @@ -1,3 +1,4 @@ +/* eslint-disable import/no-unresolved */ import { createMounter } from '@teambit/angular-mounter'; import { Component, ViewEncapsulation } from '@angular/core'; diff --git a/scopes/forks/angular-env-v16/my-angular-env.bit-env.ts b/scopes/forks/angular-env-v16/my-angular-env.bit-env.ts index b8fb54f9..465e9adf 100644 --- a/scopes/forks/angular-env-v16/my-angular-env.bit-env.ts +++ b/scopes/forks/angular-env-v16/my-angular-env.bit-env.ts @@ -110,11 +110,10 @@ export class MyAngularEnv extends AngularV16Env { */ override generators(): EnvHandler { const envName = this.constructor.name; - const angularVersion = this.angularVersion; return TemplateList.from([ - NgModuleTemplate.from({envName, angularVersion}), - NgEnvTemplate.from({envName, angularVersion}), - NgAppTemplate.from({envName, angularVersion}) + NgModuleTemplate.from({envName, angularVersion: this.angularVersion}), + NgEnvTemplate.from({envName, angularVersion: this.angularVersion}), + NgAppTemplate.from({envName, angularVersion: this.angularVersion}) ]); } diff --git a/scopes/forks/angular-env-v16/preview/mounter.ts b/scopes/forks/angular-env-v16/preview/mounter.ts index 274c3216..5ec70032 100644 --- a/scopes/forks/angular-env-v16/preview/mounter.ts +++ b/scopes/forks/angular-env-v16/preview/mounter.ts @@ -1,3 +1,4 @@ +/* eslint-disable import/no-unresolved */ import { createMounter } from '@teambit/angular-mounter'; import { Component, ViewEncapsulation } from '@angular/core'; diff --git a/scopes/generators/angular-starters/design-system/index.ts b/scopes/generators/angular-starters/design-system/index.ts index 98966b1c..cc833a81 100644 --- a/scopes/generators/angular-starters/design-system/index.ts +++ b/scopes/generators/angular-starters/design-system/index.ts @@ -1,10 +1,10 @@ import { WorkspaceContext, WorkspaceTemplate } from '@teambit/generator'; import { AngularComponentTemplateOptions } from '@teambit/angular-common'; +import { EnvContext, EnvHandler } from '@teambit/envs'; +import PkgAspect, { PkgMain } from '@teambit/pkg'; import { launchJson } from '../common/launch-json'; import { workspaceConfig } from '../common/workspace-config'; import { gitIgnore } from '../common/git-ignore'; -import { EnvContext, EnvHandler } from '@teambit/envs'; -import PkgAspect, { PkgMain } from '@teambit/pkg'; import { DEFAULT_SCOPE_NAME } from '../constants'; export class DesignSystemStarter implements WorkspaceTemplate { diff --git a/scopes/generators/angular-starters/index.ts b/scopes/generators/angular-starters/index.ts index f40d3a62..7ded0330 100644 --- a/scopes/generators/angular-starters/index.ts +++ b/scopes/generators/angular-starters/index.ts @@ -1,4 +1,5 @@ import { AngularStarter } from './ng-workspace'; + export { AngularStarter, /** @deprecated */ AngularStarter as NgWorkspaceTemplate } from './ng-workspace'; export { DesignSystemStarter } from './design-system'; export { MaterialDesignSystemStarter } from './material-design-system'; diff --git a/scopes/generators/angular-starters/material-design-system/index.ts b/scopes/generators/angular-starters/material-design-system/index.ts index c065a813..688c2305 100644 --- a/scopes/generators/angular-starters/material-design-system/index.ts +++ b/scopes/generators/angular-starters/material-design-system/index.ts @@ -1,10 +1,10 @@ import { WorkspaceContext, WorkspaceTemplate } from '@teambit/generator'; import { AngularComponentTemplateOptions } from '@teambit/angular-common'; +import { EnvContext, EnvHandler } from '@teambit/envs'; +import PkgAspect, { PkgMain } from '@teambit/pkg'; import { launchJson } from '../common/launch-json'; import { workspaceConfig } from '../common/workspace-config'; import { gitIgnore } from '../common/git-ignore'; -import { EnvContext, EnvHandler } from '@teambit/envs'; -import PkgAspect, { PkgMain } from '@teambit/pkg'; import { DEFAULT_SCOPE_NAME } from '../constants'; export class MaterialDesignSystemStarter implements WorkspaceTemplate { diff --git a/scopes/generators/angular-templates/ng-app/template-files/index.ts b/scopes/generators/angular-templates/ng-app/template-files/index.ts index 1d1c671a..8a7c7567 100644 --- a/scopes/generators/angular-templates/ng-app/template-files/index.ts +++ b/scopes/generators/angular-templates/ng-app/template-files/index.ts @@ -1,11 +1,11 @@ import { ComponentContext, ComponentFile } from '@teambit/generator'; export const indexFile = (context: ComponentContext): ComponentFile => { - const { name, namePascalCase: Name } = context; + const { name } = context; return { relativePath: `index.ts`, isMain: true, content: `export * from './${name}.ng-app'; -`, +` }; }; diff --git a/scopes/generators/angular-templates/ng-app/template-files/src/app/app.component-html.ts b/scopes/generators/angular-templates/ng-app/template-files/src/app/app.component-html.ts index e98384f8..e62ebcdd 100644 --- a/scopes/generators/angular-templates/ng-app/template-files/src/app/app.component-html.ts +++ b/scopes/generators/angular-templates/ng-app/template-files/src/app/app.component-html.ts @@ -1,7 +1,6 @@ import { ComponentContext, ComponentFile } from '@teambit/generator'; export const appComponentHtmlFile = (context: ComponentContext): ComponentFile => { - const { name, namePascalCase: Name } = context; return { relativePath: `src/app/app.component.html`, content: ` diff --git a/scopes/generators/angular-templates/ng-app/template-files/src/app/app.component-scss.ts b/scopes/generators/angular-templates/ng-app/template-files/src/app/app.component-scss.ts index f5743870..cacb35bd 100644 --- a/scopes/generators/angular-templates/ng-app/template-files/src/app/app.component-scss.ts +++ b/scopes/generators/angular-templates/ng-app/template-files/src/app/app.component-scss.ts @@ -1,7 +1,6 @@ import { ComponentContext, ComponentFile } from '@teambit/generator'; export const appComponentScssFile = (context: ComponentContext): ComponentFile => { - const { name, namePascalCase: Name } = context; return { relativePath: `src/app/app.component.scss`, content: ``, diff --git a/scopes/generators/angular-templates/ng-app/template-files/src/app/app.component-spec.ts b/scopes/generators/angular-templates/ng-app/template-files/src/app/app.component-spec.ts index e3ff014a..b2785ae9 100644 --- a/scopes/generators/angular-templates/ng-app/template-files/src/app/app.component-spec.ts +++ b/scopes/generators/angular-templates/ng-app/template-files/src/app/app.component-spec.ts @@ -1,7 +1,7 @@ import { ComponentContext, ComponentFile } from '@teambit/generator'; export const appComponentSpecFile = (context: ComponentContext): ComponentFile => { - const { name, namePascalCase: Name } = context; + const { name } = context; return { relativePath: `src/app/app.component.spec.ts`, content: `import { TestBed } from '@angular/core/testing'; diff --git a/scopes/generators/angular-templates/ng-app/template-files/src/app/app.component.ts b/scopes/generators/angular-templates/ng-app/template-files/src/app/app.component.ts index b1be69eb..2f5b11ad 100644 --- a/scopes/generators/angular-templates/ng-app/template-files/src/app/app.component.ts +++ b/scopes/generators/angular-templates/ng-app/template-files/src/app/app.component.ts @@ -1,7 +1,7 @@ import { ComponentContext, ComponentFile } from '@teambit/generator'; export const appComponentFile = (context: ComponentContext): ComponentFile => { - const { name, namePascalCase: Name } = context; + const { name } = context; return { relativePath: `src/app/app.component.ts`, content: `import { Component } from '@angular/core'; diff --git a/scopes/generators/angular-templates/ng-app/template-files/src/app/app.module.ts b/scopes/generators/angular-templates/ng-app/template-files/src/app/app.module.ts index 85435e6f..855f35a8 100644 --- a/scopes/generators/angular-templates/ng-app/template-files/src/app/app.module.ts +++ b/scopes/generators/angular-templates/ng-app/template-files/src/app/app.module.ts @@ -1,7 +1,6 @@ import { ComponentContext, ComponentFile } from '@teambit/generator'; export const appModuleFile = (context: ComponentContext): ComponentFile => { - const { name, namePascalCase: Name } = context; return { relativePath: `src/app/app.module.ts`, content: `import { NgModule } from '@angular/core'; diff --git a/scopes/generators/angular-templates/ng-app/template-files/src/assets/gitkeep.ts b/scopes/generators/angular-templates/ng-app/template-files/src/assets/gitkeep.ts index bbae5f1f..b382fd18 100644 --- a/scopes/generators/angular-templates/ng-app/template-files/src/assets/gitkeep.ts +++ b/scopes/generators/angular-templates/ng-app/template-files/src/assets/gitkeep.ts @@ -1,7 +1,6 @@ import { ComponentContext, ComponentFile } from '@teambit/generator'; export const gitKeepFile = (context: ComponentContext): ComponentFile => { - const { name, namePascalCase: Name } = context; return { relativePath: `src/assets/.gitkeep`, content: ``, diff --git a/scopes/generators/angular-templates/ng-app/template-files/src/environments/environment.prod.ts b/scopes/generators/angular-templates/ng-app/template-files/src/environments/environment.prod.ts index 0a08ed0e..4f527630 100644 --- a/scopes/generators/angular-templates/ng-app/template-files/src/environments/environment.prod.ts +++ b/scopes/generators/angular-templates/ng-app/template-files/src/environments/environment.prod.ts @@ -1,7 +1,6 @@ import { ComponentContext, ComponentFile } from '@teambit/generator'; export const environmentProdFile = (context: ComponentContext): ComponentFile => { - const { name, namePascalCase: Name } = context; return { relativePath: `src/environments/environment.prod.ts`, content: `export const environment = { diff --git a/scopes/generators/angular-templates/ng-app/template-files/src/environments/environment.ts b/scopes/generators/angular-templates/ng-app/template-files/src/environments/environment.ts index d8dcc190..85084639 100644 --- a/scopes/generators/angular-templates/ng-app/template-files/src/environments/environment.ts +++ b/scopes/generators/angular-templates/ng-app/template-files/src/environments/environment.ts @@ -1,7 +1,6 @@ import { ComponentContext, ComponentFile } from '@teambit/generator'; export const environmentFile = (context: ComponentContext): ComponentFile => { - const { name, namePascalCase: Name } = context; return { relativePath: `src/environments/environment.ts`, content: `// This file can be replaced during build by using the \`fileReplacements\` array. diff --git a/scopes/generators/angular-templates/ng-app/template-files/src/index-html.ts b/scopes/generators/angular-templates/ng-app/template-files/src/index-html.ts index 790e57bc..5522d02f 100644 --- a/scopes/generators/angular-templates/ng-app/template-files/src/index-html.ts +++ b/scopes/generators/angular-templates/ng-app/template-files/src/index-html.ts @@ -1,7 +1,7 @@ import { ComponentContext, ComponentFile } from '@teambit/generator'; export const indexHtmlFile = (context: ComponentContext): ComponentFile => { - const { name, namePascalCase: Name } = context; + const { namePascalCase: Name } = context; return { relativePath: `src/index.html`, content: ` @@ -17,6 +17,6 @@ export const indexHtmlFile = (context: ComponentContext): ComponentFile => { -`, +` }; }; diff --git a/scopes/generators/angular-templates/ng-app/template-files/src/main.ts b/scopes/generators/angular-templates/ng-app/template-files/src/main.ts index c7516cd6..4bff2b85 100644 --- a/scopes/generators/angular-templates/ng-app/template-files/src/main.ts +++ b/scopes/generators/angular-templates/ng-app/template-files/src/main.ts @@ -1,7 +1,6 @@ import { ComponentContext, ComponentFile } from '@teambit/generator'; export const mainNgAppFile = (context: ComponentContext): ComponentFile => { - const { name, namePascalCase: Name } = context; return { relativePath: `src/main.ts`, content: `import { enableProdMode } from '@angular/core'; diff --git a/scopes/generators/angular-templates/ng-app/template-files/src/polyfills.ts b/scopes/generators/angular-templates/ng-app/template-files/src/polyfills.ts index 0a1fd47c..19969544 100644 --- a/scopes/generators/angular-templates/ng-app/template-files/src/polyfills.ts +++ b/scopes/generators/angular-templates/ng-app/template-files/src/polyfills.ts @@ -1,7 +1,6 @@ import { ComponentContext, ComponentFile } from '@teambit/generator'; export const polyfillFile = (context: ComponentContext): ComponentFile => { - const { name, namePascalCase: Name } = context; return { relativePath: `src/polyfills.ts`, content: `/** diff --git a/scopes/generators/angular-templates/ng-app/template-files/src/styles.ts b/scopes/generators/angular-templates/ng-app/template-files/src/styles.ts index 3016a73f..409277a2 100644 --- a/scopes/generators/angular-templates/ng-app/template-files/src/styles.ts +++ b/scopes/generators/angular-templates/ng-app/template-files/src/styles.ts @@ -1,7 +1,6 @@ import { ComponentContext, ComponentFile } from '@teambit/generator'; export const stylesFile = (context: ComponentContext): ComponentFile => { - const { name, namePascalCase: Name } = context; return { relativePath: `src/styles.scss`, content: `/* You can add global styles to this file, and also import other style files */ diff --git a/scopes/generators/angular-templates/ng-env/files/doc.ts b/scopes/generators/angular-templates/ng-env/files/doc.ts index 5dbcfed7..b0f0edfa 100644 --- a/scopes/generators/angular-templates/ng-env/files/doc.ts +++ b/scopes/generators/angular-templates/ng-env/files/doc.ts @@ -1,6 +1,6 @@ import { ComponentContext } from '@teambit/generator'; -export function docFile({ namePascalCase: Name }: ComponentContext, angularVersion: number, envId: string) { +export function docFile({ }: ComponentContext, angularVersion: number, envId: string) { // language=Markdown return `--- description: A Bit development environment for Angular Components diff --git a/scopes/generators/angular-templates/ng-env/files/env-jsonc.ts b/scopes/generators/angular-templates/ng-env/files/env-jsonc.ts index fb49f411..6e13627b 100644 --- a/scopes/generators/angular-templates/ng-env/files/env-jsonc.ts +++ b/scopes/generators/angular-templates/ng-env/files/env-jsonc.ts @@ -2,8 +2,6 @@ import { ComponentContext } from '@teambit/generator'; import { readFileSync } from 'fs-extra'; export const envJsoncFile = (context: ComponentContext, angularVersion: number) => { - const { name, namePascalCase: Name } = context; - const jsoncFile = require.resolve(`@teambit/angular-v${angularVersion}/env.jsonc`); return readFileSync(jsoncFile, 'utf-8'); }; diff --git a/scopes/generators/angular-templates/ng-env/files/env.ts b/scopes/generators/angular-templates/ng-env/files/env.ts index b8271cab..bec1e4e1 100644 --- a/scopes/generators/angular-templates/ng-env/files/env.ts +++ b/scopes/generators/angular-templates/ng-env/files/env.ts @@ -1,6 +1,6 @@ import { ComponentContext } from '@teambit/generator'; -export function envFile({ namePascalCase: Name, name, componentId }: ComponentContext, envName: string, angularVersion: number, envPkgName: string) { +export function envFile({ namePascalCase: Name, name }: ComponentContext, envName: string, angularVersion: number, envPkgName: string) { // language=TypeScript return `import { ${envName} } from '${envPkgName}'; import { EnvHandler } from '@teambit/envs'; diff --git a/scopes/generators/angular-templates/ng-env/files/preview/mounter.ts b/scopes/generators/angular-templates/ng-env/files/preview/mounter.ts index 35a2283a..2f47ae6c 100644 --- a/scopes/generators/angular-templates/ng-env/files/preview/mounter.ts +++ b/scopes/generators/angular-templates/ng-env/files/preview/mounter.ts @@ -1,7 +1,7 @@ export const mounterFile = () => { return { relativePath: './preview/mounter.ts', - content: `import { createMounter } from '@teambit/angular-mounter'; + content: `// eslint-disable-next-lineimport { createMounter } from '@teambit/angular-mounter'; import { Component, ViewEncapsulation } from '@angular/core'; /** diff --git a/scopes/generators/angular-templates/ng-env/index.ts b/scopes/generators/angular-templates/ng-env/index.ts index 9faad359..c8802f11 100644 --- a/scopes/generators/angular-templates/ng-env/index.ts +++ b/scopes/generators/angular-templates/ng-env/index.ts @@ -55,7 +55,7 @@ export class NgEnvTemplate implements ComponentTemplate { ]; } - config(context: ConfigContext) { + config() { return { 'teambit.envs/envs': { env: 'teambit.envs/env', diff --git a/scopes/versions/angular-v12/angular-v12.bit-env.ts b/scopes/versions/angular-v12/angular-v12.bit-env.ts index e7777254..e4044e15 100644 --- a/scopes/versions/angular-v12/angular-v12.bit-env.ts +++ b/scopes/versions/angular-v12/angular-v12.bit-env.ts @@ -17,7 +17,7 @@ export class AngularV12Env extends AngularBaseEnv { jestModulePath: require.resolve('jest'), ngPackagrModulePath: require.resolve('ng-packagr'), readDefaultTsConfig: require.resolve('ng-packagr/lib/ts/tsconfig'), - webpackConfigFactory: webpackConfigFactory, + webpackConfigFactory, webpackDevServerModulePath: require.resolve('webpack-dev-server'), // resolving to the webpack used by angular devkit to avoid multiple instances of webpack // otherwise, if we use a different version, it would break diff --git a/scopes/versions/angular-v12/jest/jest.config.ts b/scopes/versions/angular-v12/jest/jest.config.ts index 3aef0209..affc36c3 100644 --- a/scopes/versions/angular-v12/jest/jest.config.ts +++ b/scopes/versions/angular-v12/jest/jest.config.ts @@ -1,4 +1,5 @@ import { generateNodeModulesPattern } from '@teambit/dependencies.modules.packages-excluder'; + const packagesToExclude: string[] = ['@angular', '@ngrx']; export default { diff --git a/scopes/versions/angular-v13/angular-v13.bit-env.ts b/scopes/versions/angular-v13/angular-v13.bit-env.ts index d72be7fb..7ba7fc02 100644 --- a/scopes/versions/angular-v13/angular-v13.bit-env.ts +++ b/scopes/versions/angular-v13/angular-v13.bit-env.ts @@ -21,7 +21,7 @@ export class AngularV13Env extends AngularBaseEnv { jestModulePath: require.resolve('jest'), ngPackagrModulePath: require.resolve('ng-packagr'), readDefaultTsConfig: require.resolve('ng-packagr/lib/ts/tsconfig'), - webpackConfigFactory: webpackConfigFactory, + webpackConfigFactory, webpackDevServerModulePath: require.resolve('webpack-dev-server'), // resolving to the webpack used by angular devkit to avoid multiple instances of webpack // otherwise, if we use a different version, it would break diff --git a/scopes/versions/angular-v13/jest/jest.config.ts b/scopes/versions/angular-v13/jest/jest.config.ts index 0a536fae..535d04b5 100644 --- a/scopes/versions/angular-v13/jest/jest.config.ts +++ b/scopes/versions/angular-v13/jest/jest.config.ts @@ -1,4 +1,5 @@ import { generateNodeModulesPattern } from '@teambit/dependencies.modules.packages-excluder'; + const packagesToExclude: string[] = ['@angular', '@ngrx']; export default { diff --git a/scopes/versions/angular-v14/angular-v14.bit-env.ts b/scopes/versions/angular-v14/angular-v14.bit-env.ts index 3efe7d5c..2a07f9f3 100644 --- a/scopes/versions/angular-v14/angular-v14.bit-env.ts +++ b/scopes/versions/angular-v14/angular-v14.bit-env.ts @@ -21,7 +21,7 @@ export class AngularV14Env extends AngularBaseEnv { jestModulePath: require.resolve('jest'), ngPackagrModulePath: require.resolve('ng-packagr'), readDefaultTsConfig: require.resolve('ng-packagr/lib/ts/tsconfig'), - webpackConfigFactory: webpackConfigFactory, + webpackConfigFactory, webpackDevServerModulePath: require.resolve('webpack-dev-server'), // resolving to the webpack used by angular devkit to avoid multiple instances of webpack // otherwise, if we use a different version, it would break diff --git a/scopes/versions/angular-v14/jest/jest.config.ts b/scopes/versions/angular-v14/jest/jest.config.ts index 7a3929d7..068e6bc9 100644 --- a/scopes/versions/angular-v14/jest/jest.config.ts +++ b/scopes/versions/angular-v14/jest/jest.config.ts @@ -1,4 +1,5 @@ import { generateNodeModulesPattern } from '@teambit/dependencies.modules.packages-excluder'; + const packagesToExclude: string[] = ['@angular', '@ngrx']; export default { diff --git a/scopes/versions/angular-v14/jest/jest.resolver.ts b/scopes/versions/angular-v14/jest/jest.resolver.ts index c6d7870a..26f06e80 100644 --- a/scopes/versions/angular-v14/jest/jest.resolver.ts +++ b/scopes/versions/angular-v14/jest/jest.resolver.ts @@ -23,8 +23,8 @@ module.exports = (path: string, options: any) => { ]); if (pkgNamesToTarget.has(pkg.name)) { - delete pkg['exports']; - delete pkg['module']; + delete pkg.exports; + delete pkg.module; } return pkg; diff --git a/scopes/versions/angular-v15/angular-v15.bit-env.ts b/scopes/versions/angular-v15/angular-v15.bit-env.ts index 6394c4c6..9862b985 100644 --- a/scopes/versions/angular-v15/angular-v15.bit-env.ts +++ b/scopes/versions/angular-v15/angular-v15.bit-env.ts @@ -21,7 +21,7 @@ export class AngularV15Env extends AngularBaseEnv { jestModulePath: require.resolve('jest'), ngPackagrModulePath: require.resolve('ng-packagr'), readDefaultTsConfig: require.resolve('ng-packagr/lib/ts/tsconfig'), - webpackConfigFactory: webpackConfigFactory, + webpackConfigFactory, webpackDevServerModulePath: require.resolve('webpack-dev-server'), // resolving to the webpack used by angular devkit to avoid multiple instances of webpack // otherwise, if we use a different version, it would break diff --git a/scopes/versions/angular-v15/jest/jest.config.ts b/scopes/versions/angular-v15/jest/jest.config.ts index 7a3929d7..068e6bc9 100644 --- a/scopes/versions/angular-v15/jest/jest.config.ts +++ b/scopes/versions/angular-v15/jest/jest.config.ts @@ -1,4 +1,5 @@ import { generateNodeModulesPattern } from '@teambit/dependencies.modules.packages-excluder'; + const packagesToExclude: string[] = ['@angular', '@ngrx']; export default { diff --git a/scopes/versions/angular-v15/jest/jest.resolver.ts b/scopes/versions/angular-v15/jest/jest.resolver.ts index c6d7870a..26f06e80 100644 --- a/scopes/versions/angular-v15/jest/jest.resolver.ts +++ b/scopes/versions/angular-v15/jest/jest.resolver.ts @@ -23,8 +23,8 @@ module.exports = (path: string, options: any) => { ]); if (pkgNamesToTarget.has(pkg.name)) { - delete pkg['exports']; - delete pkg['module']; + delete pkg.exports; + delete pkg.module; } return pkg; diff --git a/scopes/versions/angular-v16/angular-v16.bit-env.ts b/scopes/versions/angular-v16/angular-v16.bit-env.ts index ab8a255f..5b34d3ae 100644 --- a/scopes/versions/angular-v16/angular-v16.bit-env.ts +++ b/scopes/versions/angular-v16/angular-v16.bit-env.ts @@ -21,7 +21,7 @@ export class AngularV16Env extends AngularBaseEnv { jestModulePath: require.resolve('jest'), ngPackagrModulePath: require.resolve('ng-packagr'), readDefaultTsConfig: require.resolve('ng-packagr/lib/ts/tsconfig'), - webpackConfigFactory: webpackConfigFactory, + webpackConfigFactory, webpackDevServerModulePath: require.resolve('webpack-dev-server'), // resolving to the webpack used by angular devkit to avoid multiple instances of webpack // otherwise, if we use a different version, it would break diff --git a/scopes/versions/angular-v16/jest/jest.config.ts b/scopes/versions/angular-v16/jest/jest.config.ts index c6f5459b..d0214580 100644 --- a/scopes/versions/angular-v16/jest/jest.config.ts +++ b/scopes/versions/angular-v16/jest/jest.config.ts @@ -1,5 +1,7 @@ import { generateNodeModulesPattern } from '@teambit/dependencies.modules.packages-excluder'; + const { defaultTransformerOptions } = require('jest-preset-angular/presets'); + const packagesToExclude: string[] = ['@angular', '@ngrx']; export default { diff --git a/scopes/versions/angular-v16/jest/jest.resolver.ts b/scopes/versions/angular-v16/jest/jest.resolver.ts index c6d7870a..26f06e80 100644 --- a/scopes/versions/angular-v16/jest/jest.resolver.ts +++ b/scopes/versions/angular-v16/jest/jest.resolver.ts @@ -23,8 +23,8 @@ module.exports = (path: string, options: any) => { ]); if (pkgNamesToTarget.has(pkg.name)) { - delete pkg['exports']; - delete pkg['module']; + delete pkg.exports; + delete pkg.module; } return pkg; diff --git a/scopes/versions/common/angular-apps/angular.application.ts b/scopes/versions/common/angular-apps/angular.application.ts index cca58ea3..97c40dd2 100644 --- a/scopes/versions/common/angular-apps/angular.application.ts +++ b/scopes/versions/common/angular-apps/angular.application.ts @@ -43,7 +43,7 @@ export class AngularApp implements Application { } this.tsconfigPath = pathNormalizeToLinux(join(this.tempFolder, `__tsconfig-${Date.now()}.json`)); - this.preview = this.getPreview(this.tsconfigPath); + this.preview = this.getPreview(); } readonly publicDir = 'public'; @@ -61,7 +61,7 @@ export class AngularApp implements Application { }); } - private getPreview(tsconfigPath: string): EnvHandler { + private getPreview(): EnvHandler { const ngEnvOptions = this.angularEnv.getNgEnvOptions(); const serveOptions: any = Object.assign(cloneDeep(this.options.angularServeOptions), { tsConfig: this.tsconfigPath }); diff --git a/scopes/versions/common/angular-base/angular-base.bit-env.ts b/scopes/versions/common/angular-base/angular-base.bit-env.ts index ac17a019..662dfd40 100644 --- a/scopes/versions/common/angular-base/angular-base.bit-env.ts +++ b/scopes/versions/common/angular-base/angular-base.bit-env.ts @@ -41,7 +41,7 @@ export abstract class AngularBaseEnv implements AngularEnvInterface { icon = 'https://static.bit.dev/extensions-icons/angular.svg'; private ngMultiCompiler: EnvHandler | undefined; - /** Abstract functions & properties specific to the adapter **/ + /** Abstract functions & properties specific to the adapter * */ abstract ngEnvOptions: AngularEnvOptions; abstract name: string; abstract readonly angularVersion: number; @@ -49,7 +49,7 @@ export abstract class AngularBaseEnv implements AngularEnvInterface { [key: string]: any; public getNgEnvOptions(): AngularEnvOptions { - return Object.assign({}, this.ngEnvOptions); + return { ...this.ngEnvOptions}; } /** @@ -199,11 +199,10 @@ export abstract class AngularBaseEnv implements AngularEnvInterface { */ generators(): EnvHandler { const envName = this.constructor.name; - const angularVersion = this.angularVersion; return TemplateList.from([ - NgModuleTemplate.from({envName, angularVersion}), - NgEnvTemplate.from({envName, angularVersion}), - NgAppTemplate.from({envName, angularVersion}) + NgModuleTemplate.from({envName, angularVersion: this.angularVersion}), + NgEnvTemplate.from({envName, angularVersion: this.angularVersion}), + NgAppTemplate.from({envName, angularVersion: this.angularVersion}) ]); } diff --git a/scopes/versions/common/angular-base/preview/mounter.ts b/scopes/versions/common/angular-base/preview/mounter.ts index 274c3216..5ec70032 100644 --- a/scopes/versions/common/angular-base/preview/mounter.ts +++ b/scopes/versions/common/angular-base/preview/mounter.ts @@ -1,3 +1,4 @@ +/* eslint-disable import/no-unresolved */ import { createMounter } from '@teambit/angular-mounter'; import { Component, ViewEncapsulation } from '@angular/core';