Skip to content

Consecutive writeModule calls in quick succession only take effect the first time, subsequent updates do not trigger recompilation #187

@IceApriler

Description

@IceApriler

Hello Maintainers,

First, thank you for this incredibly useful plugin! We are heavily relying on webpack-virtual-modules for dynamic module generation in our project. However, we've encountered an issue when trying to update multiple virtual modules in quick succession.

When calling virtualModulesPlugin.writeModule multiple times in rapid succession (e.g., triggered by consecutive API calls that update different virtual modules), only the first update is applied and triggers a webpack recompilation. Subsequent calls to writeModule do not seem to update the module content or trigger a new compilation, even though the method executes without throwing an error.

Steps To Reproduce

const VirtualModulesPlugin = require('webpack-virtual-modules');
const virtualModulesPlugin = new VirtualModulesPlugin({
  // Initial virtual modules
});

// Simulate rapid successive updates, e.g., via API calls
app.get('/update-modules', (req, res) => {
  // First update - works and triggers recompilation
  virtualModulesPlugin.writeModule('./src/virtual-module-A.js', 'console.log("Version A1");');
  
  // Second update - often does not apply or trigger recompilation
  virtualModulesPlugin.writeModule('./src/virtual-module-B.js', 'console.log("Version B1");');

  res.send('Update requests sent.');
});

Observed Result:
Only the first virtual module (virtual-module-A.js) is updated. The second module (virtual-module-B.js) remains unchanged, and no second recompilation is triggered.

Expected Behavior
Each call to writeModule should consistently update the specified virtual module's content and trigger a webpack recompilation, regardless of how quickly these calls are made after one another.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions