Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature/help] running with child processes #11

Open
andykais opened this issue Apr 1, 2019 · 4 comments
Open

[Feature/help] running with child processes #11

andykais opened this issue Apr 1, 2019 · 4 comments
Labels
enhancement New feature or request

Comments

@andykais
Copy link
Contributor

andykais commented Apr 1, 2019

Hi, thank you for maintaining this fork! I have a project that creates child processes from other webpack entrypoints. Minimally reproducible example:

// webpack.config.js
const path = require('path')

module.exports = {
  target: 'node',
  node: {
    dirname: true
  },
  mode: 'development',
  entry: {
    main: './src/main.js',
    child: './src/child.js'
  },
  output: {
    path: path.resolve(__dirname, 'build'),
    filename: '[name].js'
  }
}
// test_sample.js
import {startFork} from './main';

describe('me', () => {
  it('test only', () => {
    console.log('forky')
    startFork();
  });
});
// src/main.js
import {fork} from 'child_process';

export const startFork = () => {
  console.log('starting fork');
  fork('./child.js');
};
// src/child.js
import * as path from 'path'

console.log('im a fork')

Running the tests with mochapack (or mocha-webpack) will fail because a fork (or any code that expects a physical file to work with from an entrypoint) cannot use the entrypoint.

npx mochapack test_sample.js
Error: Cannot find module '/Users/andrew/Code/development/sample-failure/build/child.js'

What is the course of action here? Is there a simple workaround? If not, this is a feature request that proposes actually writing code to the build folder, which is not something mochapack/mocha-webpack has done in the past

@andykais
Copy link
Contributor Author

andykais commented Apr 1, 2019

let me know if you prefer a repo to reproduce the problem, Im happy to make one!

@larixer
Copy link
Member

larixer commented Apr 1, 2019

@andykais I'm not sure I understand. Would you be willing to chat in a gitter room about this issue?

@larixer
Copy link
Member

larixer commented Apr 1, 2019

@andykais I have created gitter room for mochapack here:
https://gitter.im/sysgears/mochapack

@larixer larixer added the enhancement New feature or request label Apr 1, 2019
@larixer
Copy link
Member

larixer commented Apr 1, 2019

Thank you @andykais for raising this issue and having a chat about it. As per our chat conversation, it seems like a good idea to enable writing output to disk with some mochapack cli flag, so that we support both in-memory output mode and filesystem output mode. The relevant Pull Request for original mocha-webpack that can be of help to add back filesystem output support can be seen here:
https://github.com/zinserjan/mocha-webpack/pull/83/files

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants