question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Feature Request] Use virtual file as entry point

See original GitHub issue

Do you want to request a feature or report a bug?

feature

What is the current behavior?

You must specify the entry point file path and output dir.

If the current behavior is a bug, please provide the steps to reproduce.

not a bugs.

What is the expected behavior?

We can specify the code string as an entry point.

If this is a feature request, what is motivation or use case for changing the behavior?

I some case. I build a builder cli base on webpack. I need to pack my code.

In current behavior, I gonna create a temp file and use it as entry file, so webpack can work it well.

webpack({
  entry: "/path/to/temp/file.js" // before pack the code, I need to create this temp file first
});

What if I can use code string as an entry point?

such as this:

webpack({
  entry: {
    code: "const xx = require('xxx'); // do something else",
    filepath: "/home/xxx/xxx.js"
  }
});

Or maybe we can make it better

const virtualEntryFile = new webpack.VirtualFile(
  "filepath.js",
  "// here is the js code string"
);

const virtualImages = new webpack.VirtualFile(
  "example.png",
  new Buffer()
);

webpack({
  entry: virtualEntryFile
});

In here, you can see that, I don’t need to create an intermediary file anymore

Please mention other relevant information such as the browser version, Node.js version, webpack version and Operating System.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:43
  • Comments:23 (7 by maintainers)

github_iconTop GitHub Comments

19reactions
micha149commented, Mar 8, 2018

I just tested virtual-module-webpack-plugin which seems to work with entry points and also (interesting for my case) as template source for the HtmlWebpackPlugin.

Example: const VirtualModulePlugin = require(‘virtual-module-webpack-plugin’);

{
    // ...
    entry: '/path/to/temp/file.js',
    // ...
    plugins: [
        new VirtualModulePlugin({
            moduleName: '/path/to/temp/file.js',
            contents: 'const xx = require('xxx'); // do something else',
        }),
    ],
}
13reactions
AlbertMarashicommented, Nov 17, 2018

If you want to be able to access node_modules, I’d suggest using a memory file system + node fs and merging them with unionfs and then in the compiler using:

const {Union} = require('unionfs');
const MFS = require('memory-fs');
const fs = require('fs');
let mfs = new MFS();
let ufs = new Union();
ufs.use(mfs).use(fs);

const compiler = webpack(config);
compiler.inputFileSystem = this.ufs
compiler.outputFileSystem = this.mfs;
Read more comments on GitHub >

github_iconTop Results From Across the Web

Virtual Workspaces | Visual Studio Code Extension API
Virtual Workspaces. Extensions like the GitHub Repositories extension open VS Code on one or more folders backed by a file system provider.
Read more >
Overview of the Linux Virtual File System
When a request is made to mount a filesystem onto a directory in your namespace, the VFS will call the appropriate mount() method...
Read more >
DllMain entry point (Process.h) - Win32 apps | Microsoft Learn
An optional entry point into a dynamic-link library (DLL). When the system starts or terminates a process or thread, it calls the entry-point...
Read more >
VFS - the Tcler's Wiki!
Since VFS support is implemented at the C level, all Tcl extensions have access to files on virtual file systems. To work with...
Read more >
Dockerfile reference - Docker Documentation
If you would like your container to run the same executable every time, then you should consider using ENTRYPOINT in combination with CMD...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found