rollup-plugin-amd
rollup-plugin-amd copied to clipboard
Can I use rollup-plugin-amd in vite to convert external AMD library?
In order to use Microsofts libraries for devops extensions, namely node_modules/azure-devops-extension-api and node_modules/azure-devops-sdk (both AMD modules), in a vite project, I need to convert from ADM to ESM. Can I use this plugin? and how?
I have the following vite config:
import react from '@vitejs/plugin-react';
import { defineConfig } from 'vitest/config';
import amd from 'rollup-plugin-amd';
/**
* Configuration for ViteJS
*
* @url https://vitejs.dev/config/
*/
export default defineConfig({
base: './',
plugins: [
react(),
],
optimizeDeps: {
exclude: [
// Add the patterns to exclude here for azure-devops-extension libraries
'azure-devops-extension-api',
'azure-devops-extension-sdk',
],
},
server: {
port: 8000,
},
build: {
rollupOptions: {
plugins: [
amd({
include: [
'node_modules/azure-devops-extension-api/**',
'node_modules/azure-devops-extension-sdk/**']
})
]
},
},
})
But I still get define is not defined errors in the browser indicating that vite is trying to import the AMD modules as ESM and failing.
The module is imported with import * as API from 'azure-devops-extension-api.
What am I missing?