{"action":"created","issue":{"url":"https://api.github.com/repos/substack/node-browserify/issues/1625","repository_url":"https://api.github.com/repos/substack/node-browserify","labels_url":"https://api.github.com/repos/substack/node-browserify/issues/1625/labels{/name}","comments_url":"https://api.github.com/repos/substack/node-browserify/issues/1625/comments","events_url":"https://api.github.com/repos/substack/node-browserify/issues/1625/events","html_url":"https://github.com/substack/node-browserify/issues/1625","id":176686599,"number":1625,"title":"External modules still being bundled","user":{"login":"Liero","id":3494407,"avatar_url":"https://avatars.githubusercontent.com/u/3494407?v=3","gravatar_id":"","url":"https://api.github.com/users/Liero","html_url":"https://github.com/Liero","followers_url":"https://api.github.com/users/Liero/followers","following_url":"https://api.github.com/users/Liero/following{/other_user}","gists_url":"https://api.github.com/users/Liero/gists{/gist_id}","starred_url":"https://api.github.com/users/Liero/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Liero/subscriptions","organizations_url":"https://api.github.com/users/Liero/orgs","repos_url":"https://api.github.com/users/Liero/repos","events_url":"https://api.github.com/users/Liero/events{/privacy}","received_events_url":"https://api.github.com/users/Liero/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2016-09-13T16:21:26Z","updated_at":"2017-02-22T13:59:09Z","closed_at":null,"body":"[package.zip](https://github.com/substack/node-browserify/files/470294/package.zip)\nIn a specific situation (when I try to browserify my jasmine tests), some of the modules marked as external (like react) are included to the bundle as well.\n\n```\nvar bundler = browserify({\n  basedir: '.',\n  debug: true,\n  entries: [\"spec/fooSpec.ts\"]\n}).plugin(tsify)\n  .external(['react', 'react-dom', 'react-router', 'react-bootstrap']);\n\ngulp.task(\"compile-test\", function () { \n    return bundler.bundle() //this bundles react although it is marked as external\n      .pipe(source('tests2.js'))\n      .pipe(gulp.dest(\"dist\"))\n});\n```\n\nhowever, when I try to browserify from another entry point, like `src/index.ts`, react is not bundled.\n\nI've attached [working demo](https://github.com/substack/node-browserify/files/470296/package.zip) that demostrates the problem.\n\njust run \n\n```\nnpm install\ngulp compile-tests\n```\n\nand check that react is included in the output file (tests2.js). However, when you run gulp-compile, which browserifies from another entry point, react is externalized\n\n[working demo - package.zip](https://github.com/substack/node-browserify/files/470296/package.zip)\n"},"comment":{"url":"https://api.github.com/repos/substack/node-browserify/issues/comments/281676372","html_url":"https://github.com/substack/node-browserify/issues/1625#issuecomment-281676372","issue_url":"https://api.github.com/repos/substack/node-browserify/issues/1625","id":281676372,"user":{"login":"mauriziocescon","id":3672842,"avatar_url":"https://avatars.githubusercontent.com/u/3672842?v=3","gravatar_id":"","url":"https://api.github.com/users/mauriziocescon","html_url":"https://github.com/mauriziocescon","followers_url":"https://api.github.com/users/mauriziocescon/followers","following_url":"https://api.github.com/users/mauriziocescon/following{/other_user}","gists_url":"https://api.github.com/users/mauriziocescon/gists{/gist_id}","starred_url":"https://api.github.com/users/mauriziocescon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mauriziocescon/subscriptions","organizations_url":"https://api.github.com/users/mauriziocescon/orgs","repos_url":"https://api.github.com/users/mauriziocescon/repos","events_url":"https://api.github.com/users/mauriziocescon/events{/privacy}","received_events_url":"https://api.github.com/users/mauriziocescon/received_events","type":"User","site_admin":false},"created_at":"2017-02-22T13:59:09Z","updated_at":"2017-02-22T13:59:09Z","body":"Ok, my fault with the usage of browserify! \r\n\r\n```\r\nvar paths = {\r\n    browserifyEntries: [\"dist/tmp_ts/main.ts\"],\r\n    dependencies: [\r\n        \"jquery\",\r\n        \"angular\",\r\n        \"angular-animate\",\r\n        \"angular-mocks\",\r\n        \"angular-sanitize\",\r\n        \"angular-touch\",\r\n        \"bootstrap-sass\",\r\n        \"angular-dynamic-locale\",\r\n        \"angular-loading-bar\",\r\n        \"angular-stats\",\r\n        \"angular-ui-bootstrap\",\r\n        \"angular-ui-router\",\r\n        \"angular-ui-scroll\",\r\n        \"babel-polyfill\",\r\n        \"format4js\",\r\n        \"ng-infinite-scroll\",\r\n        \"stacktrace-js\"\r\n    ]\r\n};\r\n\r\ngulp.task(\"bundle-vendors\", function () {\r\n    return browserify()\r\n        .require(paths.dependencies)\r\n        .bundle()\r\n        .pipe(vinylSourceStream(appendVersionToFileName(\"vendors.js\")))\r\n        .pipe(vinylBuffer())\r\n        .pipe(gulp.dest(\"dist/js/\"));\r\n});\r\n\r\ngulp.task(\"compile-ts-prod\", function () {\r\n    return browserify({\r\n        basedir: \".\",\r\n        cache: {},\r\n        entries: paths.browserifyEntries,\r\n        packageCache: {}\r\n    })\r\n        .external(paths.dependencies)\r\n        .plugin(tsify)\r\n        .transform(babelify, {presets: [\"es2015\"], extensions: [\".tsx\", \".ts\"]})\r\n        .bundle()\r\n        .pipe(vinylSourceStream(appendVersionToFileName(\"app.js\")))\r\n        .pipe(vinylBuffer())\r\n        .pipe(gulpNgAnnotate())\r\n        .pipe(gulpUglify({mangle: false}))\r\n        .pipe(gulp.dest(\"dist/js/\"));\r\n});\r\n```\r\n\r\nThen in my ``app.module.ts``: \r\n\r\n```\r\nimport * as angular from \"angular\";\r\nimport {appConfigFunc} from \"./app-config.module\";\r\nimport {routingConfigFunc} from \"./app-routing.module\";\r\nimport {runFunc} from \"./app-run.module\";\r\nimport {AppComponent} from \"./app.component\";\r\nimport {core} from \"./core/core.module\";\r\nimport {shared} from \"./shared/shared.module\";\r\nimport {albums} from \"./albums/albums.module\";\r\nimport {users} from \"./users/users.module\";\r\n\r\nexport * from \"./core/core.module\";\r\n\r\nconst appModule = angular.module(\"app\", [\r\n\t\"angular-loading-bar\",\r\n\t\"angular-stats\",\r\n\t\"app-templates\",\r\n\t\"infinite-scroll\",\r\n\t\"ngAnimate\",\r\n\t\"ngSanitize\",\r\n\t\"ngTouch\",\r\n\t\"tmh.dynamicLocale\",\r\n\t\"ui.bootstrap\",\r\n\t\"ui.router\",\r\n\t\"ui.scroll\",\r\n\tcore,\r\n\tshared,\r\n\talbums,\r\n\tusers\r\n]);\r\n```\r\n\r\nPlease check [my repo](https://github.com/mauriziocescon/angular-1-x-app)"}}
{"actor":{"display_login":"mauriziocescon"}}