mirror of
https://github.com/angular/angular
synced 2026-05-24 09:28:37 +00:00
67 lines
1.6 KiB
JavaScript
67 lines
1.6 KiB
JavaScript
/**
|
|
* @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.dev/license
|
|
*/
|
|
const {nodeResolve} = require('@rollup/plugin-node-resolve');
|
|
const commonjs = require('@rollup/plugin-commonjs');
|
|
const {pathPlugin} = require('../../../tools/bazel/rollup/path-plugin.cjs');
|
|
|
|
/** Removed license banners from input files. */
|
|
const stripBannerPlugin = {
|
|
name: 'strip-license-banner',
|
|
transform(code, _filePath) {
|
|
const banner = /(\/\*[\!\*]\s+\*\s@license.*?\*\/)/s.exec(code);
|
|
if (!banner) {
|
|
return;
|
|
}
|
|
|
|
const [bannerContent] = banner;
|
|
const pos = code.indexOf(bannerContent);
|
|
if (pos !== -1) {
|
|
const result = code.slice(0, pos) + code.slice(pos + bannerContent.length);
|
|
|
|
return {
|
|
code: result.trimStart(),
|
|
map: null,
|
|
};
|
|
}
|
|
|
|
return {
|
|
code: code,
|
|
map: null,
|
|
};
|
|
},
|
|
};
|
|
|
|
const banner = `'use strict';
|
|
/**
|
|
* @license Angular v0.0.0-PLACEHOLDER
|
|
* (c) 2010-2026 Google LLC. https://angular.dev/
|
|
* License: MIT
|
|
*/`;
|
|
|
|
const plugins = [
|
|
pathPlugin({tsconfigPath: 'packages/core/schematics/tsconfig.json'}),
|
|
nodeResolve({
|
|
jail: process.cwd(),
|
|
}),
|
|
stripBannerPlugin,
|
|
commonjs(),
|
|
];
|
|
|
|
/** @type {import('rollup').RollupOptions} */
|
|
const config = {
|
|
plugins,
|
|
external: ['typescript', 'tslib', /@angular-devkit\/.+/, /@angular\//],
|
|
output: {
|
|
exports: 'auto',
|
|
chunkFileNames: '[name]-[hash].cjs',
|
|
entryFileNames: '[name].cjs',
|
|
banner,
|
|
},
|
|
};
|
|
|
|
module.exports = config;
|