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