-
Notifications
You must be signed in to change notification settings - Fork 332
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bundle pump.js with Browserify #1539
Open
strugee
wants to merge
1
commit into
master
Choose a base branch
from
browserify
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// bundles.js | ||
// | ||
// Serve up some sweet Browserify bundles | ||
// | ||
// Copyright 2018 AJ Jordan <[email protected]> | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
"use strict"; | ||
|
||
var browserify = require("browserify-middleware"), | ||
path = require("path"); | ||
|
||
var addRoutes = function(app) { | ||
app.get("/javascript/pump.js", browserify(path.join(__dirname, "../public/javascript/pump.js"))); | ||
}; | ||
|
||
exports.addRoutes = addRoutes; |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think is good idea minified and make a bundle, but is not a good idea for performance make this from the server, you can make the bundle from CLI (with browserify and watchify) in build scripts, also we don's use the commonJs on the client side (dependencies, imports etc) so Browserify adds unnecessary extra code for that.
If the idea is to convert the client side to a commonJs structure I think webpack is more powerful because you can make lazyLoad and other advantages.
Also, you can make the bundle only with UglifyJS2 from CLI without extra code and add some watch task for the development process.
Also, I think is better keep independent the frontEnd process like create bundles, for that reason I closed #1350 also for performance reasons and is similar to browserify-middleware
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, the plan was to switch to using CommonJS since it just makes it so much easier to structure the code. Really not even "easier", but "possible at all".
Re: WebPack, I thought about it, but I like Browserify better for its flexibility and I tend to agree with this assessment by @substack (the author):
Also WebPack is famous for having complicated, hard-to-debug/patch/etc. config files.
That's funny, since that was opened I actually have changed my mind on it and I think caching in memory is probably better, both for contributor experience and for production. Serving from memory is faster and you don't have to rebuild in development. FWIW that's what Express does with compiled templates.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was working with Browserify and is pretty cool, the last year work more with webpack and is powerful to manage alias, split by components, lazy load, minified styles, copy fonts/files, configuration by environment etc and webpack is more used right now and is like browserify + gulp.
but a think the
browserify-middleware
is unnecessary because you only need to make one bundle and you can make this from a CLI simple like:also if you will minify styles you should use gulp, webpack or scripts in package.json, so should be a unified solution.
Also with
browserify-middleware
if you precompile on startup you'll add some delay in the startup (for this reason I closed #1350) or from the response the first time would be slow and more when you add the external libs/modules as dependencies