Code Monkey home page Code Monkey logo

Comments (16)

shama avatar shama commented on August 27, 2024

@Bockit Could post the stack trace with grunt browserify --stack? That helps track down where the error is originating from.

from grunt-browserify.

Bockit avatar Bockit commented on August 27, 2024
Fatal error: Arguments to path.resolve must be strings
TypeError: Arguments to path.resolve must be strings
    at Object.exports.resolve (path.js:313:15)
    at Object.exports.relative (path.js:371:18)
    at Stream._vars.__filename (/Users/work/Documents/project/node_modules/grunt-browserify/node_modules/browserify/node_modules/insert-module-globals/index.js:32:31)
    at /Users/work/Documents/project/node_modules/grunt-browserify/node_modules/browserify/node_modules/insert-module-globals/index.js:86:40
    at Array.forEach (native)
    at Stream.write (/Users/work/Documents/project/node_modules/grunt-browserify/node_modules/browserify/node_modules/insert-module-globals/index.js:84:18)
    at Stream.stream.write (/Users/work/Documents/project/node_modules/grunt-browserify/node_modules/browserify/node_modules/insert-module-globals/node_modules/through/index.js:25:11)
    at Stream.ondata (stream.js:51:26)
    at Stream.EventEmitter.emit (events.js:95:17)
    at drain (/Users/work/Documents/project/node_modules/grunt-browserify/node_modules/browserify/node_modules/through/index.js:36:16)
    at Stream.stream.queue.stream.push (/Users/work/Documents/project/node_modules/grunt-browserify/node_modules/browserify/node_modules/through/index.js:45:5)
    at Stream.<anonymous> (/Users/work/Documents/project/node_modules/grunt-browserify/node_modules/browserify/index.js:191:19)
    at Stream.stream.write (/Users/work/Documents/project/node_modules/grunt-browserify/node_modules/browserify/node_modules/through/index.js:26:11)
    at Stream.ondata (stream.js:51:26)
    at Stream.EventEmitter.emit (events.js:95:17)
    at drain (/Users/work/Documents/project/node_modules/grunt-browserify/node_modules/browserify/node_modules/through/index.js:36:16)
    at Stream.stream.queue.stream.push (/Users/work/Documents/project/node_modules/grunt-browserify/node_modules/browserify/node_modules/through/index.js:45:5)
    at Stream.write (/Users/work/Documents/project/node_modules/grunt-browserify/node_modules/browserify/index.js:231:18)
    at Stream.stream.write (/Users/work/Documents/project/node_modules/grunt-browserify/node_modules/browserify/node_modules/through/index.js:26:11)
    at Stream.ondata (stream.js:51:26)
    at Stream.EventEmitter.emit (events.js:95:17)
    at drain (/Users/work/Documents/project/node_modules/grunt-browserify/node_modules/browserify/node_modules/through/index.js:36:16)
    at Stream.stream.queue.stream.push (/Users/work/Documents/project/node_modules/grunt-browserify/node_modules/browserify/node_modules/through/index.js:45:5)
    at done (/Users/work/Documents/project/node_modules/grunt-browserify/node_modules/browserify/node_modules/module-deps/index.js:193:20)
    at parseDeps (/Users/work/Documents/project/node_modules/grunt-browserify/node_modules/browserify/node_modules/module-deps/index.js:182:32)
    at done (/Users/work/Documents/project/node_modules/grunt-browserify/node_modules/browserify/node_modules/module-deps/index.js:141:13)
    at ap (/Users/work/Documents/project/node_modules/grunt-browserify/node_modules/browserify/node_modules/module-deps/index.js:127:42)
    at ConcatStream.cb (/Users/work/Documents/project/node_modules/grunt-browserify/node_modules/browserify/node_modules/module-deps/index.js:134:21)
    at ConcatStream.end (/Users/work/Documents/project/node_modules/grunt-browserify/node_modules/browserify/node_modules/concat-stream/index.js:43:21)
    at Stream.onend (stream.js:79:10)
    at Stream.EventEmitter.emit (events.js:117:20)
    at drain (/Users/work/Documents/project/node_modules/coffeeify/node_modules/through/index.js:33:23)
    at Stream.stream.queue.stream.push (/Users/work/Documents/project/node_modules/coffeeify/node_modules/through/index.js:41:5)
    at /Users/work/Documents/project/node_modules/coffeeify/index.js:82:20
    at compile (/Users/work/Documents/project/node_modules/coffeeify/index.js:64:5)
    at Stream.end (/Users/work/Documents/project/node_modules/coffeeify/index.js:79:9)
    at _end (/Users/work/Documents/project/node_modules/coffeeify/node_modules/through/index.js:61:9)
    at Stream.stream.end (/Users/work/Documents/project/node_modules/coffeeify/node_modules/through/index.js:70:5)
    at /Users/work/Documents/project/node_modules/grunt-browserify/node_modules/browserify/node_modules/module-deps/index.js:136:19
    at nr (/Users/work/Documents/project/node_modules/grunt-browserify/node_modules/browserify/node_modules/module-deps/index.js:218:13)
    at /Users/work/Documents/project/node_modules/grunt-browserify/node_modules/browserify/node_modules/module-deps/node_modules/resolve/lib/async.js:43:21
    at /Users/work/Documents/project/node_modules/grunt-browserify/node_modules/browserify/node_modules/module-deps/node_modules/resolve/lib/async.js:116:35
    at /Users/work/Documents/project/node_modules/grunt-browserify/node_modules/browserify/node_modules/module-deps/node_modules/resolve/lib/async.js:90:39
    at /Users/work/Documents/project/node_modules/grunt-browserify/node_modules/browserify/node_modules/module-deps/node_modules/resolve/lib/async.js:59:30
    at /Users/work/Documents/project/node_modules/grunt-browserify/node_modules/browserify/node_modules/module-deps/node_modules/resolve/lib/async.js:18:18
    at Object.oncomplete (fs.js:107:15)

from grunt-browserify.

Bockit avatar Bockit commented on August 27, 2024

For what it's worth, my node_modules/grunt-browserify/node_modules/browserify/index.js has two console.logs in it from when I was trying to debug a different config which had alias and ignore. This may knock the line numbers in browserify/index.js a little bit.

In browserify.prototype.deps, starts at line 222

function write (row) {
        console.log(row.id)
        self.emit('dep', row);

        if (row.id === emptyModulePath) {
            row.source = '';
        }

        ...

        if (self._external[row.id]) {
            console.log('externalising ' + row.id)
            return;
        }

Ends at line 244

We only see the first console.log appear before the error occurs:

/Users/work/Documents/project/src/app/settings.coffee

from grunt-browserify.

jmreidy avatar jmreidy commented on August 27, 2024

Looks like an issue with browserify-shim. I believe 2.0.7 fixes it. Can you test with that version and see if it works? If so I'll go ahead and update the package.json.

from grunt-browserify.

nicolashery avatar nicolashery commented on August 27, 2024

Having same issue with [email protected] and [email protected]...

from grunt-browserify.

jmreidy avatar jmreidy commented on August 27, 2024

@nicolashery can you provide a simplified version of your config so I can try to figure out what's going on? Thanks!

from grunt-browserify.

nicolashery avatar nicolashery commented on August 27, 2024

@jmreidy How's this: https://github.com/nicolashery/test-grunt-browserify-globals

Thanks!

from grunt-browserify.

jmreidy avatar jmreidy commented on August 27, 2024

@nicolashery, thanks, this is perfect.

@thlorenz, any thoughts on this? The issue only seems to come up when using browserify-shim...

from grunt-browserify.

jmreidy avatar jmreidy commented on August 27, 2024

@nicolashery, could you allow me to push to that repo?

from grunt-browserify.

thlorenz avatar thlorenz commented on August 27, 2024

@jmreidy I recently fixed some issues with browserify shim.

Not sure if the grunt plugin and/or @Bockit, @nicolashery are using the latest version.

Since browserify-shim just creates a transform and auto-requires files with browserify, I'm not sure what else it could break that affects the bundling process.

from grunt-browserify.

nicolashery avatar nicolashery commented on August 27, 2024

@jmreidy added you as collaborator on that repo

from grunt-browserify.

jmreidy avatar jmreidy commented on August 27, 2024

@thlorenz it looks like if you pass insertGlobals: true as an option to browserify, then the path.resolve bug manifests itself again. detectGlobals works fine.

@nicolashery, @Bockit: switch out insertGlobals for detectGlobals and you'll be fine.

from grunt-browserify.

Bockit avatar Bockit commented on August 27, 2024

Sorry for not being able to test what you asked for, I was away for a week. Sadly detect globals are the opposite of what I want (trying to speed up build times for my dev environment) but I understand there's not much you can do about it. Thanks for your help!

from grunt-browserify.

jmreidy avatar jmreidy commented on August 27, 2024

@Bockit The best approach would be to isolate the shims to their own browserify:vendor subtask, and expose those for consumption externally. That way, you only have to build your big vendor libraries once, which should significantly speed up times. There's an example of this approach in the examples folder.

from grunt-browserify.

nicolashery avatar nicolashery commented on August 27, 2024

Thanks for the tip @jmreidy! Careful though if using source maps with Browserify during development, concatenating vendor.js and app.js messes it up.

What works for me is:

During development, use source maps (debug: true option of grunt-browserify) and use separate script tags:

<script type="text/javascript" src="vendor.js"></script>
<script type="text/javascript" src="app.js"></script> 

For production, no source maps, concatenate vendor.js and app.js to main.js, minify, and use a single script tag:

<script type="text/javascript" src="main.js"></script> 

from grunt-browserify.

jmreidy avatar jmreidy commented on August 27, 2024

@nicolashery Really helpful advice. I'm going to add this to the docs.

from grunt-browserify.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.