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

Browserify copies modules multiple times #200

Open
anhang opened this issue May 4, 2017 · 2 comments
Open

Browserify copies modules multiple times #200

anhang opened this issue May 4, 2017 · 2 comments

Comments

@anhang
Copy link

anhang commented May 4, 2017

I have this file structure in Rails

app:
  assets:
    javascripts:
      application.js
      components:
        my_component.js
      utils:
        my_util.js

application.js requires my_util.js and my_component.js
my_component.js requires my_util.js

Browserify outputs 2 copies of my_util.js. This is causing my codebase to be way too big.

My package.json

{
  "name": "MyApp",
  "dependencies": {
    "babel-plugin-syntax-async-functions": "^6.13.0",
    "babel-plugin-transform-regenerator": "^6.3.18",
    "babel-polyfill": "^6.23.0",
    "babel-preset-es2015": "^6.3.13",
    "babel-preset-react": "^6.24.1",
    "babel-preset-stage-0": "^6.24.1",
    "babelify": "^7.2.0",
    "browserify": "^14.3.0",
    "browserify-incremental": "^3.0.1",
    "browserify-resolutions": "^1.1.0",
    "es6-promise": "^4.1.0",
    "fetch": "^1.1.0",
    "jquery": "^3.2.1",
    "jquery-ujs": "^1.2.2",
    "react": "^15.5.4"
  },
  "license": "MIT",
  "engines": {
    "node": ">= 0.10"
  }
}

My application.rb:

    config.browserify_rails.paths << /vendor\/assets\/javascripts\/module\.js/
    config.browserify_rails.paths << './assets/javascripts/' # Added this so that I can use relative paths when calling require() to see if browserify would dedupe, but this didn't help either.
    config.browserify_rails.commandline_options = "-t [ babelify --presets [ es2015 react stage-0 ] --plugins [ syntax-async-functions transform-regenerator browserify-resolutions '*' ] ]"

@cymen
Copy link
Member

cymen commented May 5, 2017

Can you paste in the require lines from application.js and my_component.js? That would help trying to figure it out.

@cymen
Copy link
Member

cymen commented May 5, 2017

Or if it's just a demo/test thing, you could push the whole thing up to github and I'll take a look.

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

2 participants