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

Odd run-time error after upgrading from 1.6.0 to 1.7.1 #159

Closed
tybro0103 opened this issue Apr 17, 2018 · 3 comments
Closed

Odd run-time error after upgrading from 1.6.0 to 1.7.1 #159

tybro0103 opened this issue Apr 17, 2018 · 3 comments

Comments

@tybro0103
Copy link

tybro0103 commented Apr 17, 2018

I just fixed a problem of mine by pinning resolve to 1.6.0... seems possibly related to this. TBH, I don't understand what's going on, but hoping maybe someone here will.

My projects runs on both server and client, with browserify building a bundle for each. Client build is fine (at least in dev where is the only difference is just watchify), but the server/node build is not. I didn't notice the problem in dev because dev doesn't run the code through browserfiy for the server. Node bundle builds without errors, but upon execution I get the error:

TypeError: Cannot read property 'numeral' of undefined

on line

if (typeof window !== 'undefined' && this.numeral && this.numeral.language)

which is in numeral.js (here) and gets included into my app via require('numeral/languages/de') from another package in node_modules.

If you're thinking this doesn't sound related, I'd be inclined to agree, considering the build succeeded and all. But I found this by doing a diff on output of npm ls on an older, working docker image against my current build (my builds do npm install from a clean slate), and manually pinning things that had changed 1-by-1 until pinning [email protected] fixed things. I've undone and redone this pinning a couple of times in isolation, and am sure it was the fix. 1.7.1 is the version which causes my error. 1.7.0 also causes same error.

I'm now inspired to make my build process more robust, but any insight here would be appreciated.

My browserify (^14.4.0) options for node target are:

        entries: ['./scripts/run.js'],
        extensions: ['.js', '.jsx'],
        debug: true,
        browserField: false,
        bare: true,
        commondir: false,
        builtins: false,
        insertGlobalVars: {
            process: () => undefined,
        },
@tybro0103 tybro0103 changed the title Odd run-time errors after upgrading from 1.6.0 to 1.7.1 Odd run-time error after upgrading from 1.6.0 to 1.7.1 Apr 17, 2018
@tybro0103
Copy link
Author

perhaps worth noting I do global.window = mockBrowser.getWindow(); on the server to avoid some other issues 🤷‍♂️

@ljharb
Copy link
Member

ljharb commented Apr 23, 2018

@tybro0103 thanks for filing a separate issue!

The this.numeral in there kind of relies on the module being invoked with the global object as the receiver (which is odd).

Is there any way you could provide a diff of the two bundle files: using resolve 1.6, and v1.7.1?

@ljharb
Copy link
Member

ljharb commented Jun 17, 2018

@tybro0103 is this still an issue for you?

If so, I'm happy to reopen.

@ljharb ljharb closed this as completed Jun 17, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants