vite-plugin-treat-umd-as-commonjs
TypeScript icon, indicating that this package has built-in type declarations

0.1.4 • Public • Published

vite-plugin-treat-umd-as-commonjs

Make code runs when using requireJS/amd in browser with vite. This plugin is for a paticular edge case. check RequireJS environment in browser will break the UMD module conversion

NPM

Usage

// vite.config.js
const { defineConfig } = require("vite");
const { treatAsCommonjs } = require("vite-plugin-treat-umd-as-commonjs");

module.exports = defineConfig({
  plugins: [treatAsCommonjs()],
});

It will simple add var define = false; in modules from node_modules by default which avoid the browser requireJS/amd environment to register the module to amd. You can also specifically include or exclude pattern.

Options

type Options = {
  // moduleId/files to include
  indluce?: Array<string | RegExp> | string | RegExp
  // moduleId/files to exclude
  exclude?: Array<string | RegExp> | string | RegExp
}

License

MIT

Package Sidebar

Install

npm i vite-plugin-treat-umd-as-commonjs

Weekly Downloads

3,262

Version

0.1.4

License

MIT

Unpacked Size

5.17 kB

Total Files

6

Last publish

Collaborators

  • pakholeung