browserify / browserify/factor-bundle

Make two files instead of three

Offen
#80 2 Kommentare 2 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
Vorherrschende Sprache
JavaScript
Sterne
397
Forks
24
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

Hey!

I effectively want to split out part of a file, instead of splitting out the common parts of two files.

Currently I have bundle.js, which contains everything used on the site. There is some checkout specific logic there that I only want on the checkout, so I want to split that stuff out into bundle-checkout.js, but then run both bundle.js and bundle-checkout.js in the checkout.

With factor-bundle by default, I would be running these files on the main site:
- bundle-common.js
- bundle.js

And these on the checkout:
- bundle-common.js
- bundle.js
- bundle-checkout.js

It's pointless for me to have both bundle-common.js and bundle.js!

The best solution I've found so far is to add `require('./main')` to the top of the input `bundle-checkout.js`, which would mean that `bundle.js` is effectively an empty file and I can include `bundle-common.js` by itself, but then that generates a junk file.

---

lib.js:

``` js
module.exports = 'lib';
```

main.js:

``` js
var lib = require('./lib');
console.log(lib);
```

checkout.js:

``` js
require('./main');
console.log('special checkout logic');
```

And then the command:

```
browserify main.js checkout.js -p [ factor-bundle -o junk.js -o bundle-checkout.js ] -o bundle.js
```

Is there any way to do this without the `require('./main')` and the useless `junk.js` file?

Thanks, and sorry for the long question! I'll turn this into an article once it's been figured out so that nobody asks it again :)

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Rechercherichtung

Beginne mit dem im Issue gezeigten factor-bundle-Befehl und reproduziere ihn mit lib.js, main.js und checkout.js. Verfolge, wie der Befehl die gemeinsamen und die Entry-Bundles verarbeitet; abgeschlossen ist die Aufgabe, wenn die angeforderten Site- und Checkout-Bundles generiert werden, ohne ./main zu benötigen oder junk.js zu erzeugen.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
javascript
Bereich
build-system, tooling
Issue-Typ
Feature
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
35/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.