Files
angular__angular/packages/language-service/bundles/rollup.config.js
Dylan Hunn ef39107ce5 refactor(language-service): Replace tsserverlibrary -> typescript (#54726)
Typescript recently consolidated `tsserverlibrary` into `typescript`: [blog post](https://devblogs.microsoft.com/typescript/announcing-typescript-5-3/#consolidation-between-tsserverlibrary-js-and-typescript-js)

In this commit, we remove all references to `tsserverlibrary` accordingly. This should be safe, since v18 and later support TS 5.3+.

PR Close #54726
2024-03-07 10:49:01 -08:00

66 lines
1.4 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.io/license
*/
const {nodeResolve} = require('@rollup/plugin-node-resolve');
const commonJs = require('@rollup/plugin-commonjs');
// This is a custom AMD file header that patches the AMD `define` call generated
// by rollup so that the bundle exposes a CJS-exported function which takes an
// instance of the TypeScript module. More details in `/language-service/index.ts`.
const amdFileHeader = `
/**
* @license Angular v0.0.0-PLACEHOLDER
* Copyright Google LLC All Rights Reserved.
* License: MIT
*/
let $deferred;
function define(modules, callback) {
$deferred = {modules, callback};
}
module.exports = function(provided) {
const ts = provided['typescript'];
if (!ts) {
throw new Error('Caller does not provide typescript module');
}
const results = {};
const resolvedModules = $deferred.modules.map(m => {
if (m === 'exports') {
return results;
}
if (m === 'typescript') {
return ts;
}
return require(m);
});
$deferred.callback(...resolvedModules);
return results;
};
`;
const external = [
'os',
'fs',
'path',
'typescript',
];
const config = {
external,
plugins: [
nodeResolve({preferBuiltins: true}),
commonJs(),
],
output: {
banner: amdFileHeader,
},
};
module.exports = config;