aurelia / webpack-plugin

A plugin for webpack that enables bundling Aurelia applications.
MIT License
90 stars 36 forks source link

UnhandledPromiseRejectionWarning #135

Closed eric-914 closed 2 years ago

eric-914 commented 6 years ago

I'm submitting a bug report

Please tell us about your environment:

Current behavior: When I run Webpack through gulp, I get the following message when my AureliaPlugin is included in webpack's config file:

(node:5920) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): TypeError: Cannot read property 'default' of undefined

It does not appear that AureliaPlugin has executed, as my output bundle is significantly smaller. This warning does not appear if I run Webpack directly.

Expected/desired behavior:

AureliaPlugin behavior should be consistent in either invocation.

Additional: My AureliaPlugin usage:

        new AureliaPlugin({
            dist: "native-modules",
            includeSubModules: [
                { moduleId: "aurelia-dialog" },
                { moduleId: "aurelia-validation" }
            ]
        })

My gulp task:

var gulp = require("gulp");
var webpack = require("webpack");

var config = require("../../webpack.dev.js");

gulp.task("webpack",
    (done) => {
        var onBuild =
            function(err, stats) {
                if (err) {
                    console.log(`Error: ${err}`);
                } else {
                    Object.keys(stats.compilation.assets).forEach(function(key) {
                        console.log(`Webpack: output ${key}`);
                    });
                }
            }

        webpack(config, onBuild);

        done();
    }
);

My invocation of webpack via gulp: npm run gulp webpack

I originally had this problem with another webpack plugin, but turns out I didn't need it. All remaining webpack plugins (5) do not have this warning.

jods4 commented 6 years ago

Before any further action: your invocation of done is clearly incorrect. It should happen when the task completes, i.e. inside onBuild.

eric-914 commented 6 years ago

Yeah, I noticed that as well the next day. It didn't change anything regarding this issue though. This isn't high priority to me, I've moved on to stop using the gulp steps. But I thought it still should be noted that it occurs.

jods4 commented 6 years ago

I don't have time to debug this, as long as Webpack CLI works it's not a critical issue... Not sure why the Webpack JS API would behave any different.

The error Cannot read property 'default' of undefined smells like a import X from "abc" that failed to resolve properly.

Alexander-Taran commented 6 years ago

@eric-914 have you tried it with webpack4 and new version of plugin? I don't see a way that plugin would be called differently. If you look at CLI source - it calls webpack directly. Your gulp task probably tries to do the same.

You can compare how it's implemented and figure out where mismatch is.

jauniuse commented 6 years ago

Having the same issue.

jods4 commented 6 years ago

Can someone post a stacktrace?

last-Programmer commented 6 years ago

I am also facing the same issue. Any Help would be appreciated

Alexander-Taran commented 2 years ago

@3cp maybe should be closed (-:

3cp commented 2 years ago

cc @bigopon

bigopon commented 2 years ago

This probably shouldn't be an issue in the latest version of the plugin. If you do face it, please open a new issue.