rluba / browserify-global-shim Goto Github PK
View Code? Open in Web Editor NEWA browserify transform for replacing modules with global variables.
A browserify transform for replacing modules with global variables.
SHA 141ef99 on github has a fix regarding importing non-js files, please update the npm repo with the latest.
"lodash": "~2.4.1" is removed in 1.0.2 but is still required.
I would love to pull in a patch that would add the global feature for version v2
of browserify-shim. IMHO that would be a better solution than have to use a separate module.
With the help of exposify implementing this should be fairly easy.
You can also consult these changesets to help you along.
Is there a way to make the replacement code not use the leading window.
so that resolution is based on whatever happens to be available, scoped?
I'm using browerify-global-shim to shim React, which has worked great until now.
The problem I've encountered is in using react-chartify. I can see from the bundle that all my instances of React are assigned to window.React. However, the code from react-chartify still has React = require('react') even after the transformation.
Thus my web app now contains conflicts caused by having two instances of React.
How do I solve this?
I'm requiring CSS files and Mustache files using browserify-css and hoganify. I'm finding that browserify-global-shim does not play well with this because it is trying to process these files that aren't JS files. It leads to a SyntaxError: Unexpected Token
.
To fix this, use the includeExtensions
option that Browserify-transform-tools features. It limits the transform to files with one of the listed extensions. I was able to get around the bug by editing browserify-global-shim.js
like so:
module.exports = transformTools.makeRequireTransform('browserify-global-shim',
{
evaluateArguments: true,
includeExtensions: ['js'] // <-- PROCESS ONLY JS FILES
},
function(args, opts, cb) {
var shimmedModules = opts.config || {};
// etc.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.