Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Browserify, beyond differences of node and web
Search
wtnabe
August 29, 2015
Programming
1
860
Browserify, beyond differences of node and web
Kanazawa.rb meetup #36で喋ったBrowserifyの紹介と今後もJavaScriptを利用するに当たって押さえておくべき課題のまとめ
wtnabe
August 29, 2015
Tweet
Share
More Decks by wtnabe
See All by wtnabe
Rubyでもモノリポしたい - 調査、おわわり編 -
wtnabe
0
21
Ruby de Railway Oriented Programming
wtnabe
0
51
Bindanのススメ
wtnabe
0
35
そのオブジェクト、何を保証してくれますか? - GuideRailのススメ -
wtnabe
0
47
Effective Jekyll
wtnabe
0
77
5 min Jekyll/Liquid Plugin cooking
wtnabe
0
42
Ruby de Wasm
wtnabe
0
71
Cloud Native Buildpacksって結局どうなの?
wtnabe
0
57
Decoupled System with Turbo Frame
wtnabe
1
140
Other Decks in Programming
See All in Programming
CSC307 Lecture 04
javiergs
PRO
0
630
[AtCoder Conference 2025] LLMを使った業務AHCの上⼿な解き⽅
terryu16
6
1k
2年のAppleウォレットパス開発の振り返り
muno92
PRO
0
180
AIエージェント、”どう作るか”で差は出るか? / AI Agents: Does the "How" Make a Difference?
rkaga
3
1.1k
Honoを使ったリモートMCPサーバでAIツールとの連携を加速させる!
tosuri13
1
120
Spinner 軸ズレ現象を調べたらレンダリング深淵に飲まれた #レバテックMeetup
bengo4com
1
220
PC-6001でPSG曲を鳴らすまでを全部NetBSD上の Makefile に押し込んでみた / osc2025hiroshima
tsutsui
0
210
The Art of Re-Architecture - Droidcon India 2025
siddroid
0
160
AI時代を生き抜く 新卒エンジニアの生きる道
coconala_engineer
1
530
コマンドとリード間の連携に対する脅威分析フレームワーク
pandayumi
1
240
クラウドに依存しないS3を使った開発術
simesaba80
0
220
React 19でつくる「気持ちいいUI」- 楽観的UIのすすめ
himorishige
11
5.3k
Featured
See All Featured
Visualization
eitanlees
150
16k
Avoiding the “Bad Training, Faster” Trap in the Age of AI
tmiket
0
52
Leveraging Curiosity to Care for An Aging Population
cassininazir
1
150
職位にかかわらず全員がリーダーシップを発揮するチーム作り / Building a team where everyone can demonstrate leadership regardless of position
madoxten
54
49k
SEOcharity - Dark patterns in SEO and UX: How to avoid them and build a more ethical web
sarafernandez
0
110
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
141
34k
Noah Learner - AI + Me: how we built a GSC Bulk Export data pipeline
techseoconnect
PRO
0
81
Speed Design
sergeychernyshev
33
1.5k
DevOps and Value Stream Thinking: Enabling flow, efficiency and business value
helenjbeal
1
79
Docker and Python
trallard
47
3.7k
From Legacy to Launchpad: Building Startup-Ready Communities
dugsong
0
120
Designing for Timeless Needs
cassininazir
0
110
Transcript
BrowserifyでNode.jsとWebの いいとこどりJS開発 〜 今、ちょい先、だいぶ先まで⾒すえて 〜 @wtnabe Kanazawa.rb meetup #36 2015-08-29
(Sat) at IT-Plaza MUSASHI
お品書き そもそも Ecma262 は ⼀⽅ Node.js は そこで Browserify ですよ
Browserify の特徴から⾒える我々の課題
最初にまとめ
Browserifyにできること require をブラウザ上で動くように変換 変換後は1つの JS ファイルに結合 その他移植可能なモジュールの提供 transform, plugin による拡張
Here, we go !!
そもそもEcma262は
依存コードを取得できない プラットフォーム独⽴ ⾔語⾃⾝にファイル読み込みがない FileSystemを持つJScriptですらwsfファイ ルで<script>を使う
スコープはfunctionのみ ファイルを分割しても影響は全体に うっかり var を忘れると global leak
「テクニック」が横⾏ 利⽤機会が増えてお互いに影響が出るとまずい (function() { ... })(); ※ testability が激しく落ちるデメリット
⼀⽅Node.jsは
責務の単位でファイル分割 ファイル単位スコープ 必要なものは require module.exports 公開するものを明⽰ そのうえで名前空間不可侵
node_modules 依存モジュールは閉じてる 個々のモジュール内にnode_modules 全体のコンフリクトが存在しない
スケールする依存管理 ※ 代わりに容量は膨らむ
安⼼して開発を進められる
そこでBrowserifyですよ
Browserifyにできること Node.js の require がブラウザ上で動く 変換後は1つの JS ファイルに結合 その他移植可能なモジュールの提供 transform,
plugin による拡張
requireが動く 依存ツリーを解決 1つの JavaScript ファイルを出⼒ ファイル単位のスコープ分割が⾃動的に ⾏われる 例のテクニック + α
何が嬉しいのか? スコープ管理⽤のテクニック不要 豊富な npm module 群の⼀部を活⽤可能 <script> を書き連ねる必要なし
そしてtransformの例 coffeeify ( CoffeeScript ) cssify ( CSS ) babelify
( Babel : ES6 & JSX ) espowerify ( power-assert ) cf. list of transforms · substack/node-browserify Wiki
ローダーとの⽐較 LABjs ブラウザのみ対応、⾮同期読み込み RequireJS ブラウザも node.js も対応している が、それぞれ書き⽅が違う ※ 要
LAB.js, require.js
Browserifyの特徴から ⾒える我々の課題
その1 : npm JSer の知⾒は以前にも増して npm に集約 されつつある download して
<script> とかやらない package.json は多機能、タスクランナーと か⾔う前にマニュアル読め
その2 : transpiler source-to-source compiler transcompiler / transpiler JavaScript の変換は
altJS に限らず常識に JSX とか 変換⽅法はいくつかあるが、⾃分たちに合うものを⾒つけておく
その3: source map 変換された JS と元のコードの対応付け Browserify は debug オプションだけで
data uri の source map を⽣成してくれる
その4 : preprocess preprocess で trans compile できるなら新 しいチャレンジはやりやすい ES6,
JSX, ... preprocess の⾃動化で学習、業務効率に 差がつく
Browserify以外では View, DOMの新しい動き JSX系の記法、VirtualDOM フルスタックフレームワーク vs Tools ※ ツールの話をしてるけどツールの話だけ追うのはよくない
その先の課題
EcmaScript 2015 将来はこれ HTML 5 に突っ込むよりは確実 今から慣れるという意味では Babel 重要 先んずれば⼈を制す
Enjoy !!
参考 Browserify substack/browserify-handbook studiomohawk/browserify-handbook list of transforms · substack/node-browserify Wiki
参考 Effective ES6 ECMAScript 2015 Language Specification – ECMA-262 6th
Edition Babel · The compiler for writing next generation JavaScript