It seems that you need to use a standalone package to run the script.
browserify main.js --standalone Bundle > bundle.js
After that you should have window.Bundle in bundle.js .
Therefore, at this point you will be able to access script.js .
if you use grunt
If you are using grunt install grunt-browserify .
npm install grunt-browserify
And then on grunt.js Gruntfile:
// Add the task grunt.loadNpmTasks('grunt-browserify'); // Add the configuration: browserify: { dist: { options: { // uncomment if you use babel // transform: [ // ["babelify", { "presets": ["env"] }] // ], browserifyOptions: { standalone: 'Bundle' } }, files: { "bundle.js": ["main.js"] } } },
if you use gulp
// on your build task var bundled = browserify('main.js', { standalone: 'Bundle' }) .bundle() .pipe(source('bundle.js')) .pipe(gulp.dest(outDir));
See here for the Chart.js gulp file.
if you use babel
If you are using babel and es6 , perhaps you are exporting your Bundle class.
So, because babel is now using Bundle , you have to use Bundle.default and so:
// in script.js var bundle = new Bundle.default();
To avoid this syntax, you can override Bundle with Bundle.default .
At the end of bundle.js insert:
window.Bundle = window.Bundle.default;
So now you will have:
// in script.js var bundle = new Bundle.default();
Sources
Standalone browser builds