Comments (3)
Personally when I had this kind of task, I just walked over tons of modules and manually reformatted them to be in CommonJS. I'd replace some common patterns via "find and replace" but it was mostly manual work.
from ama.
@winterbe See also exports-loader
, which can fix this kind of issue and prevent the leak to global. If most of your modules follow a similar style, you can apply a loader to all of them and fix the issue in your bundle.
This code will create a local variable called window
in the module's scope and set it to an empty object so your module is unable to actually export to global. Then, it will add module.exports = window.MyModule
to the module so you can use it like a proper commonjs module.
require("imports?window=>{}!exports?window.MyModule!./file.js")
From http://webpack.github.io/docs/shimming-modules.html
from ama.
Thanks for pointing that out. I'll give it a shot.
Am 17.09.2015 um 00:19 schrieb Samuel Reed [email protected]:
@winterbe See also exports-loader, which can fix this kind of issue and prevent the leak to global. If most of your modules follow a similar style, you can apply a loader to all of them and fix the issue in your bundle.
This code will create a local variable called window in the module's scope and set it to an empty object so your module is unable to actually export to global. Then, it will add module.exports = window.MyModule to the module so you can use it like a proper commonjs module.
require("imports?window=>{}!exports?window.MyModule!./file.js")
—
Reply to this email directly or view it on GitHub.
from ama.
Related Issues (20)
- What are the most popular IDEs among React developers at Facebook?
- Which product metrics does React have?
- What skills have made the biggest impact on your programming?
- Google Analytics && extending setState in the class
- React-Native support in 2018 later
- CRA + Monorepo + Lerna + Yarn HOT 3
- Help me to find a right way HOT 2
- Curious what keyboard and mouse you use
- react-testing-library Integration Tests HOT 1
- What Computer Science concepts do you know?
- How did you get a UK Work Visa without a degree.
- What does "gaeron" mean? HOT 2
- Single source of truth and Redux
- Concurrent mode in react
- Building performant forms in React over a hundred fields HOT 1
- About your earnings.
- The webpack adds an unnecessary file to the chunk HOT 1
- component variables access inside hooks. HOT 1
- react-fast-refresh from scratch
- Do you meditate?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ama.