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

Outputted bundle is not correct. Example case inside: #405

Open
JSMan2000 opened this issue Aug 15, 2018 · 0 comments
Open

Outputted bundle is not correct. Example case inside: #405

JSMan2000 opened this issue Aug 15, 2018 · 0 comments

Comments

@JSMan2000
Copy link

JSMan2000 commented Aug 15, 2018

Expected Result

  1. A valid bundle is included and all modules can be found via require()

Actual result

The bundle fails to require the "bluebird" module with the following error:

Uncaught Error: Cannot find module 'bluebird'

You can see in the reproduction code that bluebird does in fact exist. It is defined in main2.js/bundle2.js. As a result, it should be found, but it fails to be found.

Reproduction Code

Include bundle1.js and bundle2.js into a file and then call the functions:

window.main1();
window.main2();

You will receive the error that bluebird cannot be found even though it is clearly defined in main2/bundle2

It is the main1() function that fails to find the module.

Grunt file

module.exports = function(grunt) {
    grunt.initConfig({
        browserify: {
            main1: {
                src: ['src/main1.js'],
                dest: 'build/bundle1.js',
                options: {
                    external: ['bluebird']
                },
            },

            main2: {
                src: ['src/main2.js'],
                dest: 'build/bundle2.js',
            }
        }
    });

    grunt.loadNpmTasks('grunt-browserify');
    grunt.registerTask('default', ['browserify']);

};

Main1.js

window.main1 = function() {
    let pexec = require('pexec');
    console.log(pexec);
}

Main2.js

window.main2 = function() {
    let t = require('bluebird');
    console.log(t);
};
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

1 participant