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

Does not wait for process to finish #37

Open
rkaw92 opened this issue Feb 14, 2017 · 6 comments
Open

Does not wait for process to finish #37

rkaw92 opened this issue Feb 14, 2017 · 6 comments

Comments

@rkaw92
Copy link

rkaw92 commented Feb 14, 2017

We have a process that writes a value to a file which is then required by the actual build process like this:

git describe --tags HEAD >.app-version || date --rfc-3339=seconds >.app-version

Then, the "version file" generated as above is require()d in the application source.

It turns out this plugin does not wait for the command to finish before passing control back to webpack, because today we got an error during the JS build:

ModuleNotFoundError: Module not found: Error: Cannot resolve 'file' or 'directory' ../.app-version in /builds/xxx/src

Here is a more minimal demonstration:

                new WebpackShellPlugin({
                        onBuildStart: [
                                'sleep 60; touch .myfile'
                        ],
                        safe: true
                })

Then, if you run your build as usual, it will actually finish before the file has been created. This prevents you from require()ing files generated as such in your webpack project.

I see 2 solutions:

  • Use the callback interface provided by Webpack plugin API, or
  • Use execSync instead of exec
@flyon
Copy link

flyon commented May 26, 2017

Same issue here,plugin should wait for process to finish if possible. It's causing a compile loop for me because the pre-build process emits input for the actual webpack compilation after webpack has already completed its build process.

@danielyaa5
Copy link

Just made a pr #50

@charlieclark
Copy link

It would be great to get this merged - this is a pretty big blocker for using this lib for us.

@Feiyang1
Copy link

Is there any update on merging the PR? I can use npm pre- hook for now, but it doesn't execute when webpack rebuild the project on watch. This is a great plugin, it would be perfect for me if this feature is implemented. thanks!

@arielsalminen
Copy link

arielsalminen commented Oct 29, 2017

Having the compile loop issue here too. would love to see this being merged!

@Feiyang1
Copy link

I made a fork that allows you to block until the scripts finish execution. please check it out: https://www.npmjs.com/package/webpack-synchronizable-shell-plugin

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

No branches or pull requests

6 participants