caleb / broccoli-fast-browserify

A caching, flexible Browserify Broccoli filter
https://github.com/caleb/broccoli-fast-browserify
BSD 3-Clause "New" or "Revised" License
14 stars 7 forks source link

Problem with entry files #6

Closed hipertracker closed 9 years ago

hipertracker commented 9 years ago

I used broccoli-fast-browserify earlier and all was fine. Currently it does not work and I suspect it is related to the way how it traverse entry points. I have simple definition:

jsFiles = fastBrowserify(jsFiles, {
    bundles: {
        'index.js': {
            entryPoints: ['**/index.js']
        }
    }
});

But, for unknown reason broccoli-fast-browserify is now trying to load different files:

Error: EMFILE, open '/Users/hipertracker/tmp/react-es7/node_modules/react/package.json'

So, I updated my config to use more specific entry point:

jsFiles = fastBrowserify(jsFiles, {
    bundles: {
        'index.js': {
            entryPoints: ['src/index.js']
        }
    }
});

Now I get another error:

Bundle specified by " index.js " does not have any entry files

caleb commented 9 years ago

I'll check this out.

caleb commented 9 years ago

I tried to build your project with broccoli serve and I get the error:

Built with error:
Error: Cannot find module 'react-semantify' from '/Users/caleb/Desktop/react-es7/tmp/babel-tmp_dest_dir-lwUJY1t7.tmp/app/components'
    at /Users/caleb/Desktop/react-es7/node_modules/broccoli-fast-browserify/node_modules/browserify/node_modules/browser-resolve/node_modules/resolve/lib/async.js:46:17
    at process (/Users/caleb/Desktop/react-es7/node_modules/broccoli-fast-browserify/node_modules/browserify/node_modules/browser-resolve/node_modules/resolve/lib/async.js:173:43)
    at ondir (/Users/caleb/Desktop/react-es7/node_modules/broccoli-fast-browserify/node_modules/browserify/node_modules/browser-resolve/node_modules/resolve/lib/async.js:188:17)
    at load (/Users/caleb/Desktop/react-es7/node_modules/broccoli-fast-browserify/node_modules/browserify/node_modules/browser-resolve/node_modules/resolve/lib/async.js:69:43)
    at onex (/Users/caleb/Desktop/react-es7/node_modules/broccoli-fast-browserify/node_modules/browserify/node_modules/browser-resolve/node_modules/resolve/lib/async.js:92:31)
    at /Users/caleb/Desktop/react-es7/node_modules/broccoli-fast-browserify/node_modules/browserify/node_modules/browser-resolve/node_modules/resolve/lib/async.js:22:47
    at FSReqWrap.oncomplete (fs.js:77:15)

I think this might be related to the react-semantify package's package.json file's main declaration:

{
...
"main": "lib/index.js",
...
}

The react-semantify package doesn't have a lib/index.js file in it's npm package. It doesn't have a lib/index.js file even in it's source repository.

It doesn't look like that's the problem you mentioned above, but this is the first error I ran into when trying to build your project. Is this something you've seen?

caleb commented 9 years ago

@hipertracker: I removed references to react-semantify to test the rest of the build and everything built without errors with the **/index.js entryPoint.

As for why using src/index.js as an entry point doesn't work, it's because your broccoli tree jsFiles uses Funnel to select files from src, but the destination directory is the root of the broccoli tree (the default for Funnel). If you wanted to hardcode the entryPoint to the index.js inside of src, you would use:

jsFiles = fastBrowserify(jsFiles, {
    bundles: {
        'index.js': {
            entryPoints: ['index.js']
        }
    }
});

Or you can tell Funnel to output the files to a different directory with the destDir option:

var jsFiles = new Funnel('src', {
  exclude: [new RegExp(/__tests__/)],
  include: [new RegExp(/\.js$/)],
  destDir: 'src'
});
hipertracker commented 9 years ago

@caleb thanks, it works. I've upgraded my project.