rspack-plugin-virtual-module
An Rspack plugin that allows you to create virtual modules.
Last updated a year ago by chenjiahan .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install rspack-plugin-virtual-module 
SYNC missed versions from official npm registry.

rspack-plugin-virtual-module

An Rspack plugin that allows you to create virtual modules.

npm version license

Installation

# npm
npm install rspack-plugin-virtual-module

# yarn
yarn add rspack-plugin-virtual-module

# pnpm
pnpm add rspack-plugin-virtual-module

Usage

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

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],
};

License

MIT.

Current Tags

  • 1.0.1                                ...           latest (a year ago)

17 Versions

  • 1.0.1                                ...           a year ago
  • 1.0.0                                ...           a year ago
  • 0.1.13                                ...           2 years ago
  • 0.1.12                                ...           3 years ago
  • 0.1.11                                ...           3 years ago
  • 0.1.10                                ...           3 years ago
  • 0.1.9                                ...           3 years ago
  • 0.1.8                                ...           3 years ago
  • 0.1.7                                ...           3 years ago
  • 0.1.6                                ...           3 years ago
  • 0.1.5                                ...           3 years ago
  • 0.1.4                                ...           3 years ago
  • 0.1.3                                ...           3 years ago
  • 0.1.2                                ...           3 years ago
  • 0.1.1                                ...           3 years ago
  • 0.1.0                                ...           3 years ago
  • 0.0.0                                ...           3 years ago
Downloads
Today 0
This Week 1
This Month 2
Last Day 0
Last Week 12
Last Month 17
Dependencies (1)
Dev Dependencies (9)

Copyright 2013 - present © cnpmjs.org | Home |