-
-
Notifications
You must be signed in to change notification settings - Fork 197
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
Fix browserify issue #101
Fix browserify issue #101
Conversation
var langFiles = fs.readdirSync(path.join(__dirname, 'languages')); | ||
langFiles.forEach(function (langFile) { | ||
numbro.language(path.basename(langFile, '.js'), require(path.join(__dirname, 'languages', langFile))); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I put back the automatic load 😄
@stewart42, @alexkwolfe care to weigh in on this patch with respect to #62/#66? |
@clayzermk1 I wanted to test first that the new If it does, we can put it back here |
but maybe having it as a separated functions as you suggested is a good idea 😄 |
} | ||
|
||
function inNodejsRuntime() { | ||
return process.browser === undefined; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure, but I don't think this is universal for client-side CommonJS implementations. It should work in browserify, but no clue about webpack or others. I don't think it is standardized. process.title === 'node'
seems to be more standard from what I could find.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok 😄
It's what I found after some googling.
maybe use both ?
} | ||
|
||
function inNodejsRuntime() { | ||
return process && process.browser === undefined && (process.title === 'node' || process.title === 'grunt'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is an issue with using this line and browserify, process
is not defined by default with browserify.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe add a typeof process !== 'undefined'
at the beginning? Possibly instead of the first process
in the condition?
Replacing the first process
with typeof process !== 'undefined'
worked for me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if process
is undefined, inNodejsRuntime
returns false, or?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nah, throws a "process is not defined" error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
weird 😄
I will fix it then 😉
is it a merge candidate now? |
f98d998
to
cb4889c
Compare
LGTM for my purposes, no errors during a quick test. |
Fix browserify issue
done then ;) |
in numbro 1.5.2 |
Fix #70
Fix #71
Fix #79