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
Target multiple plattforms (node, browser) using a bundler (Browserify) #53
Conversation
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.
So I've been down this road before and there was nothing but trouble having a built file checked in. We would accidentally publish new releases but no one remembered to update the bundled version. Is there a way in which the browser version can not be checked in at all and instead built automatically when "npm publish" is ran? This way no one ever forgets to keep them in sync and we don't have duplicate checked in code.
Also ping @pfeigl if you can confirm including the bundle in the npm package like yhis works for your use case. |
Besides the above issue to look into, I marked the PR as "needs docs" because (a) we need user docs for how users will use this (or, at the very least, to update the blurb that this is a Node.js module to add what the browser support is and which browsers) and (b) need maintainer / contributor does now that there are a lot of scripts. I locally pulled this down and ran I also see there is a new
Not sure what's up with that, but I may be just missing something. I ran |
Got the same problem and this is not a consistent way to build. I will replace
I did not test it on a Windows machine, but test on Mac and Linux (Travis CI) run without problems.
Before installing the cli, try the following: |
When you test the code, it automatically builds the browser version and then tests it. So you can not forget to build it (because you alway test before a commit). |
Can you add the file to .gitignore?
Thanks, I will try this today. If it works, can this be what npm run test-browser does?
Gotcha. |
We just need the browser version in the npm package, but not in the version control.
This is a good solution. What do you think about deploying with Travis CI? |
How would that work? Wouldn't publish get stuck waiting for me to type in my 2FA code? |
Here is a good instruction: With environment variables you can set your API_TOKEN (just visible for you). |
Right, but even with my token, running the npm publish will still prompt me to enter in my 2FA code from my phone to allow publishing a package. |
Maybe this helps:
|
Looks like there is no solution from that issue, just a request to add a feature? |
Looks like you have to drop 2FA to publish with Travis CI. |
Yea, I turned on 2FA because there was at least one instance where a npm publish I did included my API token in the package, unbeknownst to me. It was in a config.gypi file that npm included automatically. You can find a good write up at https://github.com/ChALkeR/notes/blob/master/Do-not-underestimate-credentials-leaks.md Because of these issues ChALkeR pushed to get npm to add 2FA and I enabled it the instant it was available so I wouldn't get hit by this again. |
Just release this as a fork of the module to npm. Perhaps |
Why another package? This module is just only do something about string process, remove the |
Goal: Run this module in a browser
Approach: Using an npm package
Cons:
Better Approach: Use a bundler to build an independet file for the browser
Pros:
This PR contains:
window["mime-types"]
to access functions in the browser