Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use ES6 imports instead of require #19919

Merged
merged 2 commits into from Feb 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions packages/angular/cli/BUILD.bazel
Expand Up @@ -69,6 +69,7 @@ ts_library(
"//packages/angular_devkit/core/node",
"//packages/angular_devkit/schematics",
"//packages/angular_devkit/schematics/tools",
"@npm//@angular/core",
"@npm//@types/debug",
"@npm//@types/inquirer",
"@npm//@types/node",
Expand All @@ -79,6 +80,7 @@ ts_library(
"@npm//@types/uuid",
"@npm//ansi-colors",
"@npm//jsonc-parser",
"@npm//open",
"@npm//ora",
],
)
Expand Down
5 changes: 2 additions & 3 deletions packages/angular/cli/commands/doc-impl.ts
Expand Up @@ -6,12 +6,11 @@
* found in the LICENSE file at https://angular.io/license
*/

import * as open from 'open';
import { Command } from '../models/command';
import { Arguments } from '../models/interface';
import { Schema as DocCommandSchema } from './doc';

const open = require('open');

export class DocCommand extends Command<DocCommandSchema> {
public async run(options: DocCommandSchema & Arguments) {
if (!options.keyword) {
Expand Down Expand Up @@ -39,7 +38,7 @@ export class DocCommand extends Command<DocCommandSchema> {
// and use it if we can find it
try {
/* tslint:disable-next-line:no-implicit-dependencies */
const currentNgVersion = require('@angular/core').VERSION.major;
const currentNgVersion = (await import('@angular/core')).VERSION.major;
domain = `v${currentNgVersion}.angular.io`;
} catch (e) { }
}
Expand Down
10 changes: 5 additions & 5 deletions packages/angular_devkit/build_angular/src/dev-server/index.ts
Expand Up @@ -14,7 +14,7 @@ import {
} from '@angular-devkit/build-webpack';
import { json, tags } from '@angular-devkit/core';
import * as path from 'path';
import { Observable, from, of } from 'rxjs';
import { Observable, from } from 'rxjs';
import { concatMap, switchMap } from 'rxjs/operators';
import * as ts from 'typescript';
import * as url from 'url';
Expand Down Expand Up @@ -307,7 +307,7 @@ export function serveWebpackBrowser(
webpackDevServerFactory: require('webpack-dev-server') as typeof webpackDevServer,
},
).pipe(
concatMap((buildEvent, index) => {
concatMap(async (buildEvent, index) => {
// Resolve serve address.
const serverAddress = url.format({
protocol: options.ssl ? 'https' : 'http',
Expand All @@ -325,16 +325,16 @@ export function serveWebpackBrowser(
` + '\n');

if (options.open) {
const open = require('open');
open(serverAddress);
const open = await import('open');
await open(serverAddress);
}
}

if (buildEvent.success) {
logger.info(`\n${colors.greenBright(colors.symbols.check)} Compiled successfully.`);
}

return of({ ...buildEvent, baseUrl: serverAddress } as DevServerBuilderOutput);
return { ...buildEvent, baseUrl: serverAddress } as DevServerBuilderOutput;
}),
);
}),
Expand Down