Skip to content

Does not wait for process to finish #37

Description

@rkaw92

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

Activity

  1. flyon commented on May 26, 2017

    @flyon

    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.

  2. danielyaa5 commented on Aug 20, 2017

    @danielyaa5

    Just made a pr #50

  3. charlieclark commented on Aug 24, 2017

    @charlieclark

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

  4. Feiyang1 commented on Oct 27, 2017

    @Feiyang1

    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!

  5. arielsalminen commented on Oct 29, 2017

    @arielsalminen

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

  6. Feiyang1 commented on Nov 18, 2017

    @Feiyang1

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions