Factor-bundle and browserify-shim don't play well together
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 25/100
- Tipo di issue
- Bug
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Ferma
- Stack tecnologico
- javascript, jquery, react
- Ambito
- build-system, tooling
Direzione di ricerca
Inizia da package.json e gulpfile.js, quindi segui il punto di ingresso del plugin di factor-bundle e la gestione della dipendenza jquery da parte di browserify-shim. Riproduci gli output di factor-bundle dalla configurazione pages/common mostrata e verifica che i plugin jquery mantengano window.jQuery senza il require HTML manuale.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
We were using browserify with browserify-shim to be able to use jQuery with a few plugins. So far so good. At this time we were creating another bundle for dependencies common across all pages, manually specifying them.
We then discovered and decided to use factor-bundle to factor common dependencies in a better way. The result was very good in terms of file size, but shims provided by browserify-shim disappeared. Since jQuery and its plugins are used in several pages, they're successfully factored out with factor-bundle, but they're produced without the shims. The problem is that jQuery plugins rely in window.jQuery that's no more available since there's no more shim.
We ended up requireing jQuery manually in the HTML and expose it, with <script>var jQuery = require("jquery")</script>. We would love factor-bundle to work with browserify-shim (or the opposite, whatever).
My understanding is that since factor-bundle is a plugin that act at the bundle level, it may not call it properly. But in our setup, it successfully apply the reactify transform (we use React.js with JSX syntax). So I suppose it's not a problem of factor-bundle not using transforms at all, but a specific incompatibility between factor-bundle and browserify-shim. However I couln't determine the problem precisely since I'm not familiar at all with the internals of those modules.
For reference in case it helps, here are relevant parts of our package.json and gulpfile (some parts are skipped to focus, it may look inconsistent/weird) :
package.json
"browserify": {
"transform": [
"reactify",
"browserify-shim"
]
},
"browser": {
"jquery": "./node_modules/jquery/dist/jquery.js",
"twitter-typeahead": "./node_modules/typeahead.js/dist/typeahead.bundle.js",
"magnific-popup": "./node_modules/magnific-popup/dist/jquery.magnific-popup.js"
},
"browserify-shim": {
"jquery": "$",
"slick-carousel": {
"depends": [
"jquery"
]
},
"twitter-typeahead": {
"depends": [
"jquery"
]
},
"magnific-popup": {
"depends": [
"jquery"
]
}
}
gulpfile.js
function browserifyPages() {
var pages = fs.readdirSync("./pages");
var b = browserify(pages.map(function (p) {
return "./pages/" + p;
}), BROWSERIFY_ARGS);
b.require("jquery");
b = minifyBundle(b); // using minifyify
return b.plugin("factor-bundle", {outputs: pages.map(function (p) {
return JS_DST_DIR + "/" + p;
})});
}
function browserifyCommonJs() {
var b = browserify("./common/header.js", BROWSERIFY_ARGS);
b.external("jquery");
return minifyBundle(b);
}
Hope this helps identify the problem. Thanks in advance.
(Let me ping browserify-shim people : @thlorenz and @bendrucker. In case I shouldn't, sorry guys !)
- Lingua principale
- JavaScript
- Stelle
- 397
- Fork
- 24
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Preparare l'ambiente
Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di browserify/factor-bundle
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 32/100
browserify/factor-bundle#95 ·
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 30/100
browserify/factor-bundle#94 ·
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 25/100
browserify/factor-bundle#92 ·
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 35/100
browserify/factor-bundle#83 ·
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 35/100
browserify/factor-bundle#82 · 3 reazioni ·
Tutte le issue di browserify/factor-bundle
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
invoiceninja/invoiceninja#13320 ·
I maintainer di solito rispondono entro 1 giorno
-
NoCode.vue, Task.vue: replace explicit `any` with real typesForse già presa @prayas-bit l’ha presa oggi. Apertaarea/frontend good first issue kind/cooldown
Difficoltà 2/5 1-3 ore Idoneità per principianti 67/100
kestra-io/kestra#20347 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Electron/Chromium StatusNotifierItem unreachable via unique bus name, tray icon never appearsAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
ubuntu/gnome-shell-extension-appindicator#676 · 1 commento ·