addons/vscode/rollup.extension.config.mjsblame
View source
b69ab311/**
b69ab312 * Copyright (c) Meta Platforms, Inc. and affiliates.
b69ab313 *
b69ab314 * This source code is licensed under the MIT license found in the
b69ab315 * LICENSE file in the root directory of this source tree.
b69ab316 */
b69ab317
b69ab318import alias from '@rollup/plugin-alias';
b69ab319import cjs from '@rollup/plugin-commonjs';
b69ab3110import importJson from '@rollup/plugin-json';
b69ab3111import nodeResolve from '@rollup/plugin-node-resolve';
b69ab3112import replace from '@rollup/plugin-replace';
b69ab3113import path from 'node:path';
b69ab3114import {fileURLToPath} from 'node:url';
b69ab3115import esbuild from 'rollup-plugin-esbuild';
b69ab3116
b69ab3117// eslint-disable-next-line no-undef
b69ab3118const isProduction = process.env.NODE_ENV === 'production';
b69ab3119
b69ab3120const filePath = fileURLToPath(import.meta.url);
b69ab3121const __dirname = path.dirname(filePath);
b69ab3122const projectRootDir = path.dirname(__dirname);
b69ab3123
b69ab3124const customResolver = nodeResolve({
b69ab3125 extensions: ['.ts', '.tsx', '.mjs', '.js', '.jsx', '.json', '.sass', '.scss'],
b69ab3126});
b69ab3127
b69ab3128export default (async () => {
b69ab3129 /** @type {import('rollup').RollupOptions} */
b69ab3130 return {
b69ab3131 input: './extension/extension.ts',
b69ab3132 output: {
b69ab3133 format: 'cjs',
b69ab3134 dir: 'dist',
b69ab3135 paths: id => id,
b69ab3136 sourcemap: true,
b69ab3137 },
b69ab3138 external: ['ws', 'vscode'],
b69ab3139 plugins: [
b69ab3140 replace({
b69ab3141 'process.env.NODE_ENV': isProduction ? '"production"' : '"development"',
b69ab3142 preventAssignment: true,
b69ab3143 }),
b69ab3144 // Support importing from `isl` and `shared` inside `vscode`
b69ab3145 alias({
b69ab3146 entries: [
b69ab3147 {
b69ab3148 find: /^isl/,
b69ab3149 replacement: path.resolve(projectRootDir, 'isl'),
b69ab3150 },
b69ab3151 {
b69ab3152 find: /^shared/,
b69ab3153 replacement: path.resolve(projectRootDir, 'shared'),
b69ab3154 },
b69ab3155 ],
b69ab3156 customResolver,
b69ab3157 }),
b69ab3158 esbuild(),
b69ab3159 nodeResolve({preferBuiltins: true, moduleDirectories: ['..', 'node_modules']}),
b69ab3160 cjs(),
b69ab3161 importJson(),
b69ab3162 isProduction && (await import('@rollup/plugin-terser')).default(),
b69ab3163 ],
b69ab3164 };
b69ab3165})();