-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: defer internal cli imports to ng-compat component
- Loading branch information
Showing
33 changed files
with
377 additions
and
136 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
module.exports = { | ||
parser: '@typescript-eslint/parser', | ||
ignorePatterns: ["node_modules/"], | ||
parserOptions: { | ||
createDefaultProgram: true | ||
}, | ||
env: { | ||
browser: true, | ||
node: true, | ||
es6: true, | ||
jest: true | ||
}, | ||
extends: [ | ||
'plugin:@typescript-eslint/recommended', | ||
"plugin:markdown/recommended" | ||
], | ||
plugins: [ | ||
'@typescript-eslint', | ||
'import' | ||
], | ||
overrides: [ | ||
{ | ||
files: ['*.ts', '*.js'], | ||
parserOptions: { | ||
project: require.resolve('./tsconfig.json'), | ||
createDefaultProgram: true, | ||
} | ||
} | ||
], | ||
rules: { | ||
complexity: ['error', { max: 25 }], | ||
'no-console': ['error'], | ||
'@typescript-eslint/no-unused-vars': ['error', { args: 'after-used' }], | ||
'@typescript-eslint/no-use-before-define': [ | ||
'error', | ||
{ functions: false, classes: true, variables: true, typedefs: true }, | ||
], | ||
'@typescript-eslint/return-await': 'error', | ||
'no-return-await': 'off', | ||
'@typescript-eslint/no-misused-promises': 'error', | ||
'@typescript-eslint/no-floating-promises': 'error', | ||
'@typescript-eslint/explicit-module-boundary-types': 'off', | ||
'@typescript-eslint/ban-ts-comment': 'off', | ||
'@typescript-eslint/ban-types': 'off', | ||
'no-shadow': 'off', | ||
'@typescript-eslint/no-shadow': ['error'], | ||
// ERRORS OF plugin:@typescript-eslint/recommended | ||
'@typescript-eslint/no-var-requires': 'off', | ||
'@typescript-eslint/ban-ts-ignore': 'off', | ||
'@typescript-eslint/camelcase': 'off', | ||
'@typescript-eslint/no-explicit-any': 'off', | ||
// END ERRORS OF plugin:@typescript-eslint/recommended | ||
|
||
// ERRORS OF 'plugin:promise/recommended' | ||
'promise/always-return': 'off', | ||
'promise/no-nesting': 'off', | ||
// END ERRORS OF 'plugin:promise/recommended' | ||
'import/prefer-default-export': 'off', // typescript works better without default export | ||
'import/export': 'off', // typescript does allow multiple export default when overloading. not sure why it's enabled here. rule source: https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/export.md | ||
'prefer-object-spread': 'off', | ||
'@typescript-eslint/explicit-function-return-type': 'off', | ||
'import/no-cycle': 'off', | ||
'import/no-useless-path-segments': 'off', | ||
'no-restricted-imports': [ | ||
'error', | ||
{ | ||
name: '@teambit/ui-foundation.ui.react-router.link', | ||
message: 'use @teambit/base-ui.routing.link', | ||
}, | ||
{ | ||
name: '@teambit/ui-foundation.ui.react-router.nav-link', | ||
message: 'use @teambit/base-ui.routing.nav-link', | ||
}, | ||
], | ||
'lines-between-class-members': 'off', | ||
radix: 'off', | ||
'no-underscore-dangle': 'off', | ||
'no-param-reassign': 'off', | ||
'no-return-assign': [0, 'except-parens'], | ||
'class-methods-use-this': 'off', | ||
// 'simple-import-sort/sort': 'error', | ||
// 'sort-imports': 'off', | ||
// 'import/first': 'error', | ||
// 'import/newline-after-import': 'error', | ||
'import/no-duplicates': 'error', | ||
'prefer-destructuring': 'off', | ||
'import/no-extraneous-dependencies': 'off', | ||
'no-restricted-syntax': [2, 'ForInStatement', 'LabeledStatement', 'WithStatement'], | ||
'no-unused-expressions': 'off', | ||
'max-len': [ | ||
2, | ||
200, | ||
2, | ||
{ | ||
ignoreUrls: true, | ||
ignoreComments: true, | ||
ignoreRegExpLiterals: true, | ||
ignoreStrings: true, | ||
ignoreTemplateLiterals: true, | ||
}, | ||
], | ||
'max-lines': [2, 1800], | ||
'func-names': [0], | ||
|
||
// ERRORS OF plugin:react/recommended | ||
'react/no-unescaped-entities': 'off', | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { VERSION } from '@angular/cli'; | ||
|
||
export let BrowserBuilderSchema: any; | ||
|
||
if (Number(VERSION.major) > 12) { | ||
BrowserBuilderSchema = require('@angular-devkit/build-angular/src/builders/browser/schema').Schema; | ||
} |
9 changes: 9 additions & 0 deletions
9
angular/devkit/ng-compat/build-angular/index-html-webpack-plugin.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { VERSION } from '@angular/cli'; | ||
|
||
export let IndexHtmlWebpackPlugin: any; | ||
if (VERSION.major === '16' && Number(VERSION.minor) >= 2) { | ||
// 16.2+ | ||
IndexHtmlWebpackPlugin = require('@angular-devkit/build-angular/src/tools/webpack/plugins/index-html-webpack-plugin').IndexHtmlWebpackPlugin; | ||
} else { | ||
IndexHtmlWebpackPlugin = require('@angular-devkit/build-angular/src/webpack/plugins/index-html-webpack-plugin').IndexHtmlWebpackPlugin; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { VERSION } from '@angular/cli'; | ||
|
||
export let OutputHashing: any; | ||
|
||
if (VERSION.major === '12') { | ||
OutputHashing = require('@angular-devkit/build-angular/src/server/schema').OutputHashing; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { json, logging } from '@angular-devkit/core'; | ||
import { VERSION } from '@angular/cli'; | ||
import { BrowserBuilderSchema } from '../browser-schema'; | ||
|
||
export * from './normalize-cache'; | ||
export * from './package-chunk-sort'; | ||
export * from './webpack-browser-config'; | ||
|
||
export let normalizeBrowserSchema: (workspaceRoot: string, projectRoot: string, projectSourceRoot: string | undefined, options: typeof BrowserBuilderSchema, metadata?: json.JsonObject, logger?: logging.LoggerApi) => any; | ||
export let normalizeOptimization: (optimization?: any) => any; | ||
export let BuildBrowserFeatures: any; | ||
|
||
if (VERSION.major) { | ||
const utils = require('@angular-devkit/build-angular/src/utils'); | ||
normalizeBrowserSchema = utils.normalizeBrowserSchema; | ||
normalizeOptimization = utils.normalizeOptimization; | ||
BuildBrowserFeatures = utils.BuildBrowserFeatures; | ||
} |
8 changes: 8 additions & 0 deletions
8
angular/devkit/ng-compat/build-angular/utils/normalize-cache.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { VERSION } from '@angular/cli'; | ||
import { json } from '@angular-devkit/core'; | ||
|
||
|
||
export let normalizeCacheOptions: (metadata: json.JsonObject, worspaceRoot: string) => any; | ||
if (Number(VERSION.major) > 12) { | ||
normalizeCacheOptions = require('@angular-devkit/build-angular/src/utils/normalize-cache').normalizeCacheOptions; | ||
} |
11 changes: 11 additions & 0 deletions
11
angular/devkit/ng-compat/build-angular/utils/package-chunk-sort.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { VERSION } from '@angular/cli'; | ||
|
||
export let generateEntryPoints: (options: { | ||
styles: any[]; | ||
scripts: any[]; | ||
isHMREnabled?: boolean; | ||
}) => any[]; | ||
|
||
if (VERSION.major) { | ||
generateEntryPoints = require('@angular-devkit/build-angular/src/utils/package-chunk-sort').generateEntryPoints; | ||
} |
34 changes: 34 additions & 0 deletions
34
angular/devkit/ng-compat/build-angular/utils/webpack-browser-config.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { logging } from '@angular-devkit/core'; | ||
import { VERSION } from '@angular/cli'; | ||
import { Configuration } from '@teambit/webpack'; | ||
import { BrowserBuilderSchema } from '../browser-schema'; | ||
|
||
type wbConfigFn = ( | ||
workspaceRoot: string, | ||
projectRoot: string, | ||
sourceRoot: string | undefined, | ||
projectName: string, | ||
options: any, | ||
webpackPartialGenerator: any, | ||
logger: logging.LoggerApi, | ||
extraBuildOptions: Partial<any> | ||
) => Promise<Configuration>; | ||
|
||
type wbConfigFnV12 = ( | ||
workspaceRoot: string, | ||
projectRoot: string, | ||
sourceRoot: string | undefined, | ||
options: any, | ||
webpackPartialGenerator: any, | ||
logger: logging.LoggerApi, | ||
extraBuildOptions: Partial<any> | ||
) => Promise<Configuration>; | ||
|
||
export let generateWebpackConfig: wbConfigFn & wbConfigFnV12; | ||
export let getIndexOutputFile: (index: typeof BrowserBuilderSchema['index']) => string; | ||
|
||
if (VERSION.major) { | ||
const webpackBrowserConfig = require('@angular-devkit/build-angular/src/utils/webpack-browser-config'); | ||
generateWebpackConfig = webpackBrowserConfig.generateWebpackConfig; | ||
getIndexOutputFile = webpackBrowserConfig.getIndexOutputFile; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import type { Configuration } from 'webpack'; | ||
import { VERSION } from '@angular/cli'; | ||
|
||
type configFn = (wco: any) => Promise<Configuration> | Configuration; | ||
let configs: any; | ||
if (VERSION.major === '16' && Number(VERSION.minor) >= 2) { | ||
// 16.2+ | ||
configs = require('@angular-devkit/build-angular/src/tools/webpack/configs'); | ||
} else { | ||
configs = require('@angular-devkit/build-angular/src/webpack/configs'); | ||
} | ||
|
||
export const getCommonConfig: configFn = configs.getCommonConfig; | ||
export const getDevServerConfig: configFn = configs.getDevServerConfig; | ||
export const getStylesConfig: configFn = configs.getStylesConfig; | ||
|
||
// Angular v12, undefined for other versions | ||
export const getBrowserConfig: configFn = configs.getBrowserConfig; | ||
export const getStatsConfig: (wco: any) => { stats: any } = configs.getStatsConfig; | ||
export const getTypeScriptConfig: configFn = configs.getTypeScriptConfig; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export * from './configs'; | ||
export * from './stats'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { WebpackLoggingCallback } from '@angular-devkit/build-webpack'; | ||
import { logging } from '@angular-devkit/core'; | ||
import { VERSION } from '@angular/cli'; | ||
import { BrowserBuilderSchema } from '../browser-schema'; | ||
|
||
export let createWebpackLoggingCallback: (options: typeof BrowserBuilderSchema, logger: logging.LoggerApi) => WebpackLoggingCallback; | ||
|
||
if (VERSION.major === '16' && Number(VERSION.minor) >= 2) { | ||
createWebpackLoggingCallback = require('@angular-devkit/build-angular/src/tools/webpack/utils/stats').createWebpackLoggingCallback; | ||
} else { | ||
createWebpackLoggingCallback = require('@angular-devkit/build-angular/src/webpack/utils/stats').createWebpackLoggingCallback; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"componentId": { | ||
"scope": "bitdev.angular", | ||
"name": "dev-services/ng-compat" | ||
}, | ||
"propagate": true, | ||
"extensions": { | ||
"teambit.dependencies/dependency-resolver": { | ||
"policy": { | ||
"dependencies": { | ||
}, | ||
"peerDependencies": { | ||
"@angular-devkit/build-angular": ">= 0.0.1", | ||
"@angular/cli": ">= 8.0.0", | ||
"webpack": ">= 4.44.2" | ||
} | ||
} | ||
}, | ||
"teambit.node/[email protected]": {} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export * from './build-angular/index-html-webpack-plugin'; | ||
export * from './build-angular/webpack'; | ||
export * from './build-angular/utils'; | ||
export * from './build-angular/browser-schema'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.