0.1.12 • Published 8 months ago

rspack-plugin-virtual-module v0.1.12

Weekly downloads
-
License
MIT
Repository
-
Last release
8 months ago

rspack-plugin-virtual-module

A plugin for rspack that allows you to create virtual modules.

Installation

# npm
npm install rspack-plugin-virtual-module
# yarn
yarn add rspack-plugin-virtual-module
# pnpm
pnpm add rspack-plugin-virtual-module

Usage

const { RspackVirtualModulePlugin } = require('rspack-plugin-virtual-module');
// rspack.config.js
module.exports = {
  plugins: [
    new RspackVirtualModulePlugin({
      contents: 'export default "Hello World";',
    }),
  ],
};

Then you can import the virtual module in your code:

import hello from 'contents';

console.log(hello); // "Hello World"

If you want to dynamically write the contents of the virtual module, you can use the writeModule method:

// rspack.config.js
const { RspackVirtualModulePlugin } = require('rspack-plugin-virtual-module');

const vmp = new RspackVirtualModulePlugin({
  contents: 'export default "Hello World";',
});

// Write the contents of the virtual module after 1 second
setTimeout(() => {
  vmp.writeModule('export default "Hello World 2";');
}, 1000);

module.exports = {
  plugins: [vmp],
};
0.1.10

9 months ago

0.1.11

9 months ago

0.1.12

8 months ago

0.1.8

9 months ago

0.1.7

11 months ago

0.1.9

9 months ago

0.1.6

11 months ago

0.1.5

12 months ago

0.1.4

12 months ago

0.1.3

1 year ago

0.1.2

1 year ago

0.1.1

1 year ago

0.1.0

1 year ago

0.0.0

1 year ago