Updated the files.

This commit is contained in:
Batuhan Berk Başoğlu 2024-02-08 19:38:41 -05:00
parent 1553e6b971
commit 753967d4f5
23418 changed files with 3784666 additions and 0 deletions

View file

@ -0,0 +1,28 @@
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
import { BuilderContext } from '@angular-devkit/architect';
import { Observable } from 'rxjs';
import webpack from 'webpack';
import WebpackDevServer from 'webpack-dev-server';
import { BuildResult, WebpackFactory, WebpackLoggingCallback } from '../webpack';
import { Schema as WebpackDevServerBuilderSchema } from './schema';
export type WebpackDevServerFactory = typeof WebpackDevServer;
export type DevServerBuildOutput = BuildResult & {
port: number;
family: string;
address: string;
};
export declare function runWebpackDevServer(config: webpack.Configuration, context: BuilderContext, options?: {
shouldProvideStats?: boolean;
devServerConfig?: WebpackDevServer.Configuration;
logging?: WebpackLoggingCallback;
webpackFactory?: WebpackFactory;
webpackDevServerFactory?: WebpackDevServerFactory;
}): Observable<DevServerBuildOutput>;
declare const _default: import("../../../../architect/src/internal").Builder<WebpackDevServerBuilderSchema & import("../../../../core/src").JsonObject>;
export default _default;

View file

@ -0,0 +1,88 @@
"use strict";
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.runWebpackDevServer = void 0;
const architect_1 = require("@angular-devkit/architect");
const path_1 = require("path");
const rxjs_1 = require("rxjs");
const webpack_1 = __importDefault(require("webpack"));
const webpack_dev_server_1 = __importDefault(require("webpack-dev-server"));
const utils_1 = require("../../utils");
function runWebpackDevServer(config, context, options = {}) {
const createWebpack = (c) => {
if (options.webpackFactory) {
const result = options.webpackFactory(c);
if ((0, rxjs_1.isObservable)(result)) {
return result;
}
else {
return (0, rxjs_1.of)(result);
}
}
else {
return (0, rxjs_1.of)((0, webpack_1.default)(c));
}
};
const createWebpackDevServer = (webpack, config) => {
if (options.webpackDevServerFactory) {
return new options.webpackDevServerFactory(config, webpack);
}
return new webpack_dev_server_1.default(config, webpack);
};
const log = options.logging || ((stats, config) => context.logger.info(stats.toString(config.stats)));
const shouldProvideStats = options.shouldProvideStats ?? true;
return createWebpack({ ...config, watch: false }).pipe((0, rxjs_1.switchMap)((webpackCompiler) => new rxjs_1.Observable((obs) => {
const devServerConfig = options.devServerConfig || config.devServer || {};
devServerConfig.host ??= 'localhost';
let result;
const statsOptions = typeof config.stats === 'boolean' ? undefined : config.stats;
webpackCompiler.hooks.done.tap('build-webpack', (stats) => {
// Log stats.
log(stats, config);
obs.next({
...result,
webpackStats: shouldProvideStats ? stats.toJson(statsOptions) : undefined,
emittedFiles: (0, utils_1.getEmittedFiles)(stats.compilation),
success: !stats.hasErrors(),
outputPath: stats.compilation.outputOptions.path,
});
});
const devServer = createWebpackDevServer(webpackCompiler, devServerConfig);
devServer.startCallback((err) => {
if (err) {
obs.error(err);
return;
}
const address = devServer.server?.address();
if (!address) {
obs.error(new Error(`Dev-server address info is not defined.`));
return;
}
result = {
success: true,
port: typeof address === 'string' ? 0 : address.port,
family: typeof address === 'string' ? '' : address.family,
address: typeof address === 'string' ? address : address.address,
};
});
// Teardown logic. Close the server when unsubscribed from.
return () => {
devServer.stopCallback(() => { });
webpackCompiler.close(() => { });
};
})));
}
exports.runWebpackDevServer = runWebpackDevServer;
exports.default = (0, architect_1.createBuilder)((options, context) => {
const configPath = (0, path_1.resolve)(context.workspaceRoot, options.webpackConfig);
return (0, rxjs_1.from)((0, utils_1.getWebpackConfig)(configPath)).pipe((0, rxjs_1.switchMap)((config) => runWebpackDevServer(config, context)));
});

View file

@ -0,0 +1,9 @@
/**
* Webpack Dev-Server Builder schema for Architect.
*/
export interface Schema {
/**
* The path to the Webpack configuration file.
*/
webpackConfig: string;
}

View file

@ -0,0 +1,4 @@
"use strict";
// THIS FILE IS AUTOMATICALLY GENERATED. TO UPDATE THIS FILE YOU NEED TO CHANGE THE
// CORRESPONDING JSON SCHEMA FILE, THEN RUN devkit-admin build (or bazel build ...).
Object.defineProperty(exports, "__esModule", { value: true });

View file

@ -0,0 +1,14 @@
{
"$schema": "http://json-schema.org/draft-07/schema",
"title": "Webpack Dev-Server Builder",
"description": "Webpack Dev-Server Builder schema for Architect.",
"type": "object",
"properties": {
"webpackConfig": {
"type": "string",
"description": "The path to the Webpack configuration file."
}
},
"additionalProperties": false,
"required": ["webpackConfig"]
}

View file

@ -0,0 +1,31 @@
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
import { BuilderContext, BuilderOutput } from '@angular-devkit/architect';
import { Observable } from 'rxjs';
import webpack from 'webpack';
import { EmittedFiles } from '../../utils';
import { Schema as RealWebpackBuilderSchema } from './schema';
export type WebpackBuilderSchema = RealWebpackBuilderSchema;
export interface WebpackLoggingCallback {
(stats: webpack.Stats, config: webpack.Configuration): void;
}
export interface WebpackFactory {
(config: webpack.Configuration): Observable<webpack.Compiler> | webpack.Compiler;
}
export type BuildResult = BuilderOutput & {
emittedFiles?: EmittedFiles[];
webpackStats?: webpack.StatsCompilation;
outputPath: string;
};
export declare function runWebpack(config: webpack.Configuration, context: BuilderContext, options?: {
logging?: WebpackLoggingCallback;
webpackFactory?: WebpackFactory;
shouldProvideStats?: boolean;
}): Observable<BuildResult>;
declare const _default: import("../../../../architect/src/internal").Builder<RealWebpackBuilderSchema & import("../../../../core/src").JsonObject>;
export default _default;

View file

@ -0,0 +1,88 @@
"use strict";
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.runWebpack = void 0;
const architect_1 = require("@angular-devkit/architect");
const path_1 = require("path");
const rxjs_1 = require("rxjs");
const webpack_1 = __importDefault(require("webpack"));
const utils_1 = require("../../utils");
function runWebpack(config, context, options = {}) {
const { logging: log = (stats, config) => context.logger.info(stats.toString(config.stats)), shouldProvideStats = true, } = options;
const createWebpack = (c) => {
if (options.webpackFactory) {
const result = options.webpackFactory(c);
if ((0, rxjs_1.isObservable)(result)) {
return result;
}
else {
return (0, rxjs_1.of)(result);
}
}
else {
return (0, rxjs_1.of)((0, webpack_1.default)(c));
}
};
return createWebpack({ ...config, watch: false }).pipe((0, rxjs_1.switchMap)((webpackCompiler) => new rxjs_1.Observable((obs) => {
const callback = (err, stats) => {
if (err) {
return obs.error(err);
}
if (!stats) {
return;
}
// Log stats.
log(stats, config);
const statsOptions = typeof config.stats === 'boolean' ? undefined : config.stats;
const result = {
success: !stats.hasErrors(),
webpackStats: shouldProvideStats ? stats.toJson(statsOptions) : undefined,
emittedFiles: (0, utils_1.getEmittedFiles)(stats.compilation),
outputPath: stats.compilation.outputOptions.path,
};
if (config.watch) {
obs.next(result);
}
else {
webpackCompiler.close(() => {
obs.next(result);
obs.complete();
});
}
};
try {
if (config.watch) {
const watchOptions = config.watchOptions || {};
const watching = webpackCompiler.watch(watchOptions, callback);
// Teardown logic. Close the watcher when unsubscribed from.
return () => {
watching.close(() => { });
webpackCompiler.close(() => { });
};
}
else {
webpackCompiler.run(callback);
}
}
catch (err) {
if (err) {
context.logger.error(`\nAn error occurred during the build:\n${err instanceof Error ? err.stack : err}`);
}
throw err;
}
})));
}
exports.runWebpack = runWebpack;
exports.default = (0, architect_1.createBuilder)((options, context) => {
const configPath = (0, path_1.resolve)(context.workspaceRoot, options.webpackConfig);
return (0, rxjs_1.from)((0, utils_1.getWebpackConfig)(configPath)).pipe((0, rxjs_1.switchMap)((config) => runWebpack(config, context)));
});

View file

@ -0,0 +1,9 @@
/**
* Webpack Builder schema for Architect.
*/
export interface Schema {
/**
* The path to the Webpack configuration file.
*/
webpackConfig: string;
}

View file

@ -0,0 +1,4 @@
"use strict";
// THIS FILE IS AUTOMATICALLY GENERATED. TO UPDATE THIS FILE YOU NEED TO CHANGE THE
// CORRESPONDING JSON SCHEMA FILE, THEN RUN devkit-admin build (or bazel build ...).
Object.defineProperty(exports, "__esModule", { value: true });

View file

@ -0,0 +1,14 @@
{
"$schema": "http://json-schema.org/draft-07/schema",
"title": "Webpack Builder.",
"description": "Webpack Builder schema for Architect.",
"type": "object",
"properties": {
"webpackConfig": {
"type": "string",
"description": "The path to the Webpack configuration file."
}
},
"additionalProperties": false,
"required": ["webpackConfig"]
}