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

Using require() statements which refer to vendor/bower/ don't work. Possibly incompatibility with lineman-browserify? #6

Open
erichiggins opened this issue May 8, 2014 · 10 comments

Comments

@erichiggins
Copy link

I basically copied the example in the README and lineman build failed:

Running "browserify:common" (browserify) task
Verifying property browserify.common exists in config...OK
Files: app/js/entrypoint.coffee -> generated/js/browserify.js
>> Error: module "jquery" not found from "my_lineman_app/app/js/entrypoint.coffee"
Warning: Error running grunt-browserify. Use --force to continue.

app/js/entrypoint.coffee

window.$ = require('jquery')(window);
require("./hello")

config/files.js

module.exports = function(lineman) {
  return {
    //Override file patterns here
    js: {
      vendor: [
        "vendor/bower/jquery/dist/jquery.js",
        "vendor/js/**/*.js"
      ]
    }
  };
};
@searls
Copy link
Member

searls commented May 8, 2014

Hey Eric, thanks for opening all these tickets! Apologies I won't have a chance to look at them until Scotland JS is behind me tomorrow

On Thu, May 8, 2014 at 11:51 PM, Eric Higgins [email protected]
wrote:

I basically copied the example in the README and lineman build failed:

Running "browserify:common" (browserify) task
Verifying property browserify.common exists in config...OK
Files: app/js/entrypoint.coffee -> generated/js/browserify.js
>> Error: module "jquery" not found from "my_lineman_app/app/js/entrypoint.coffee"
Warning: Error running grunt-browserify. Use --force to continue.

app/js/entrypoint.coffee

window.$ = require('jquery')(window);
require("./hello")

config/files.js

module.exports = function(lineman) {
  return {
    //Override file patterns here
    js: {
      vendor: [
        "vendor/bower/jquery/dist/jquery.js",
        "vendor/js/**/*.js"
      ]
    }
  };
};

Reply to this email directly or view it on GitHub:
#6

@erichiggins
Copy link
Author

No problem, Justin!

It's worth noting that if I just copy these files from vendor/bower/ to vendor/js/ then it works fine.

@searls
Copy link
Member

searls commented May 8, 2014

Oh you probably just need to specify vendor/bower as a loadPath for browserify. Check the result of lineman config browserify

On Thu, May 8, 2014 at 11:54 PM, Eric Higgins [email protected]
wrote:

No problem, Justin!

It's worth noting that if I just copy these files from vendor/bower/ to vendor/js/ then it works fine.

Reply to this email directly or view it on GitHub:
#6 (comment)

@erichiggins
Copy link
Author

Here's the output:

$ lineman config browserify
{
  "common": {
    "files": {
      "<%= files.browserify.generated %>": "<%= files.browserify.entrypoint %>"
    },
    "options": {
      "debug": false,
      "extensions": [
        ".js",
        ".coffee"
      ],
      "transform": [
        "coffeeify"
      ],
      "aliasMappings": [
        {
          "cwd": "vendor/js",
          "src": "**/*.{js,coffee}",
          "dest": ""
        },
        {
          "cwd": "app/js",
          "src": "**/*.{js,coffee}",
          "dest": ""
        }
      ]
    }
  },
  "spec": {
    "files": {
      "<%= files.browserify.generatedSpec %>": [
        "<%= files.js.spec %>",
        "<%= files.coffee.spec %>"
      ]
    },
    "options": {
      "debug": false,
      "extensions": [
        ".js",
        ".coffee"
      ],
      "transform": [
        "coffeeify"
      ],
      "aliasMappings": [
        {
          "cwd": "vendor/js",
          "src": "**/*.{js,coffee}",
          "dest": ""
        },
        {
          "cwd": "app/js",
          "src": "**/*.{js,coffee}",
          "dest": ""
        },
        {
          "cwd": "spec",
          "src": "**/*.{js,coffee}",
          "dest": ""
        }
      ]
    }
  }
}

I don't see loadPath in there; did you mean aliasMappings?
Should this go in the docs somewhere?

@searls
Copy link
Member

searls commented May 8, 2014

Yes I do. The same concept is called a load path in similar tools

On Fri, May 9, 2014 at 12:22 AM, Eric Higgins [email protected]
wrote:

Here's the output:

$ lineman config browserify
{
  "common": {
    "files": {
      "<%= files.browserify.generated %>": "<%= files.browserify.entrypoint %>"
    },
    "options": {
      "debug": false,
      "extensions": [
        ".js",
        ".coffee"
      ],
      "transform": [
        "coffeeify"
      ],
      "aliasMappings": [
        {
          "cwd": "vendor/js",
          "src": "**/*.{js,coffee}",
          "dest": ""
        },
        {
          "cwd": "app/js",
          "src": "**/*.{js,coffee}",
          "dest": ""
        }
      ]
    }
  },
  "spec": {
    "files": {
      "<%= files.browserify.generatedSpec %>": [
        "<%= files.js.spec %>",
        "<%= files.coffee.spec %>"
      ]
    },
    "options": {
      "debug": false,
      "extensions": [
        ".js",
        ".coffee"
      ],
      "transform": [
        "coffeeify"
      ],
      "aliasMappings": [
        {
          "cwd": "vendor/js",
          "src": "**/*.{js,coffee}",
          "dest": ""
        },
        {
          "cwd": "app/js",
          "src": "**/*.{js,coffee}",
          "dest": ""
        },
        {
          "cwd": "spec",
          "src": "**/*.{js,coffee}",
          "dest": ""
        }
      ]
    }
  }
}

I don't see loadPath in there; did you mean aliasMappings?

Should this go in the docs somewhere?

Reply to this email directly or view it on GitHub:
#6 (comment)

@erichiggins
Copy link
Author

Ok. Is there a "right" way to add vendor/js/ to this?

@searls
Copy link
Member

searls commented May 10, 2014

Why yes, there is a right way! It might look like this:

browserify: {
  common: {
    options: {
      aliasMappings: lineman.config.application.browserify.common.options.aliasMappings.concat({
        cwd: "vendor/bower",
        src: "**/*.{js,coffee}",
        dest: ""
      })
    }
  }
}

@searls searls closed this as completed May 10, 2014
@searls searls reopened this May 10, 2014
@searls
Copy link
Member

searls commented May 10, 2014

(Keeping this open to verify it helps you actually fix your issue)

@erichiggins
Copy link
Author

Thanks for the help! That seems to have helped somewhat, but it also appears to include all JS files that exist under vendor/bower/. Here's an error I see during the build process:

Running "browserify:common" (browserify) task
Verifying property browserify.common exists in config...OK
Files: app/js/entrypoint.js -> generated/js/browserify.js
>> Error: Parsing file /src/myproject/vendor/bower/jquery/src/intro.js: Line 46: Unexpected end of input

@searls
Copy link
Member

searls commented May 10, 2014

Yeah indeed. This just isn't a problem we've solved yet. Honestly we're a bit flummoxed that bower sucks down the universe

On Sat, May 10, 2014 at 8:06 PM, Eric Higgins [email protected]
wrote:

Thanks for the help! That seems to have helped somewhat, but it also appears to include all JS files that exist under vendor/bower/. Here's an error I see during the build process:

Running "browserify:common" (browserify) task
Verifying property browserify.common exists in config...OK
Files: app/js/entrypoint.js -> generated/js/browserify.js
>> Error: Parsing file /src/myproject/vendor/bower/jquery/src/intro.js: Line 46: Unexpected end of input

Reply to this email directly or view it on GitHub:
#6 (comment)

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