1.9 KB66 lines
Blame
1/**
2 * Copyright (c) Meta Platforms, Inc. and affiliates.
3 *
4 * This source code is licensed under the MIT license found in the
5 * LICENSE file in the root directory of this source tree.
6 */
7
8import alias from '@rollup/plugin-alias';
9import cjs from '@rollup/plugin-commonjs';
10import importJson from '@rollup/plugin-json';
11import nodeResolve from '@rollup/plugin-node-resolve';
12import replace from '@rollup/plugin-replace';
13import path from 'node:path';
14import {fileURLToPath} from 'node:url';
15import esbuild from 'rollup-plugin-esbuild';
16
17// eslint-disable-next-line no-undef
18const isProduction = process.env.NODE_ENV === 'production';
19
20const filePath = fileURLToPath(import.meta.url);
21const __dirname = path.dirname(filePath);
22const projectRootDir = path.dirname(__dirname);
23
24const customResolver = nodeResolve({
25 extensions: ['.ts', '.tsx', '.mjs', '.js', '.jsx', '.json', '.sass', '.scss'],
26});
27
28export default (async () => {
29 /** @type {import('rollup').RollupOptions} */
30 return {
31 input: './extension/extension.ts',
32 output: {
33 format: 'cjs',
34 dir: 'dist',
35 paths: id => id,
36 sourcemap: true,
37 },
38 external: ['ws', 'vscode'],
39 plugins: [
40 replace({
41 'process.env.NODE_ENV': isProduction ? '"production"' : '"development"',
42 preventAssignment: true,
43 }),
44 // Support importing from `isl` and `shared` inside `vscode`
45 alias({
46 entries: [
47 {
48 find: /^isl/,
49 replacement: path.resolve(projectRootDir, 'isl'),
50 },
51 {
52 find: /^shared/,
53 replacement: path.resolve(projectRootDir, 'shared'),
54 },
55 ],
56 customResolver,
57 }),
58 esbuild(),
59 nodeResolve({preferBuiltins: true, moduleDirectories: ['..', 'node_modules']}),
60 cjs(),
61 importJson(),
62 isProduction && (await import('@rollup/plugin-terser')).default(),
63 ],
64 };
65})();
66