-
Fototrend
JavaScript != Java (A JavaScript nem összekeverendő a Javával, két különböző programozási nyelvről van szó!)
Új hozzászólás Aktív témák
-
Jim-Y
veterán
Gondoltam megmutatom, hogy hogy működik a browserify, mert viszonylag egyszerűen be lehet mutatni:
Vannak a forrás fájlok:
.
├── app.js
├── index.html
├── module1.js
├── module2.js
└── node_modules
└── browserifymodule1
======='use strict';
module.exports.hello = function(world) {
return 'hello, ' + world();
};module2
======='use strict';
module.exports.world = function() {
return 'world!';
};app
==='use strict';
var module1 = require('./module1.js'),
module2 = require('./module2.js');
document.querySelector('body > div > p').innerText = module1.hello(module2.world);Majd itt használjuk fel a browserify-t egy bundle készítésre, terminálban a gyökér könyvtárban ki kell adni ezt a parancsot:
browserify app.js > bundle.js
index.html
========<!DOCTYPE html>
<head>
<title>Browserify</title>
</head>
<body>
<div>
<p></p>
</div>
<script src="bundle.js"></script>
</body>
</html>Tehát a html-be már csak a bundle-t húzzuk be, illetve a webszerverre/CDN-re is már csak a bundle-t kell feltenni.
A bundle pedig ezt tartalmazza:
(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
'use strict';
var module1 = require('./module1.js'),
module2 = require('./module2.js');
document.querySelector('body > div > p').innerText = module1.hello(module2.world);
},{"./module1.js":2,"./module2.js":3}],2:[function(require,module,exports){
'use strict';
module.exports.hello = function(world) {
return 'hello, ' + world();
};
},{}],3:[function(require,module,exports){
'use strict';
module.exports.world = function() {
return 'world!';
};
},{}]},{},[1]);Sok-sok olvashatatlan dolog, de látszik, hogy végső soron a te fájlaidat rakja össze.
Üdv
Új hozzászólás Aktív témák
- Üzletből, garanciával, Lenovo ThinkPad P14s Gen2. Ryzen 5 Pro-5650u/16GBRAM/512GBSSD/FULLHD IPS
- SAMSUNG Odyssey G4 LS27BG400EUXEN + INGYEN SZÁLLÍTÁS
- Apple iPhone 14 Pro Max - 256GB / Space Gray / 83% + Spigen tokok
- Logitech Trueforce G923 kormány és pedál szett váltóval, break moddal
- Bomba ár! HP ProBook 450 G7 - i5-10GEN I 8GB I 256SSD I HDMI I 15,6" FHD I Cam I W11 I Gar
- Bomba ár! HP EliteBook 845 G8 - R3 5450U I 16GB I 256GB SSD I HDMI I 14" FHD I Cam I W11 I Gari!
- Dell Latitude 5440 14" Touchscreen i5-1235U 16GB 256GB 1 év garancia
- Samsung Galaxy S24 8/128 GB Amber Yellow 6 hónap Garancia Beszámítás Házhozszállítás
- HIBÁTLAN iPhone 14 512GB Blue -1 ÉV GARANCIA - Kártyafüggetlen, MS3922, 100% Akkumulátor
- billentyűzetek - kiárusítás - Logitech, Corsair, ASUS
Állásajánlatok
Cég: ATW Internet Kft.
Város: Budapest
Cég: BroadBit Hungary Kft.
Város: Budakeszi

