This repository was archived by the owner on Feb 26, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6.9k
chore(web-server): use a rewriting server to get rid of bower dependency #385
Closed
Closed
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 was deleted.
Oops, something went wrong.
This file contains hidden or 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 was deleted.
Oops, something went wrong.
This file contains hidden or 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 hidden or 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 |
---|---|---|
|
@@ -6,32 +6,39 @@ | |
"repository": "https://github.com/angular/angular-seed", | ||
"license": "MIT", | ||
"devDependencies": { | ||
"bower": "^1.7.7", | ||
"http-server": "^0.9.0", | ||
"angular-mocks": "^1.5.8", | ||
"jasmine-core": "^2.4.1", | ||
"karma": "^0.13.22", | ||
"karma-chrome-launcher": "^0.2.3", | ||
"karma-firefox-launcher": "^0.1.7", | ||
"karma-jasmine": "^0.3.8", | ||
"karma-junit-reporter": "^0.4.1", | ||
"local-web-server": "^1.2.6", | ||
"protractor": "^4.0.9" | ||
}, | ||
"scripts": { | ||
"postinstall": "bower install", | ||
|
||
"prestart": "npm install", | ||
"start": "http-server -a localhost -p 8000 -c-1 ./app", | ||
|
||
"start": "ws", | ||
"pretest": "npm install", | ||
"test": "karma start karma.conf.js", | ||
"test-single-run": "karma start karma.conf.js --single-run", | ||
|
||
"preupdate-webdriver": "npm install", | ||
"update-webdriver": "webdriver-manager update", | ||
|
||
"preprotractor": "npm run update-webdriver", | ||
"protractor": "protractor e2e-tests/protractor.conf.js", | ||
|
||
"update-index-async": "node -e \"var fs=require('fs'),indexFile='app/index-async.html',loaderFile='app/bower_components/angular-loader/angular-loader.min.js',loaderText=fs.readFileSync(loaderFile,'utf-8').split(/sourceMappingURL=angular-loader.min.js.map/).join('sourceMappingURL=bower_components/angular-loader/angular-loader.min.js.map'),indexText=fs.readFileSync(indexFile,'utf-8').split(/\\/\\/@@NG_LOADER_START@@[\\s\\S]*\\/\\/@@NG_LOADER_END@@/).join('//@@NG_LOADER_START@@\\n'+loaderText+' //@@NG_LOADER_END@@');fs.writeFileSync(indexFile,indexText);\"" | ||
"update-index-async": "node -e \"var fs=require('fs'),indexFile='app/index-async.html',loaderFile='app/lib/angular-loader/angular-loader.min.js',loaderText=fs.readFileSync(loaderFile,'utf-8').split(/sourceMappingURL=angular-loader.min.js.map/).join('sourceMappingURL=lib/angular-loader/angular-loader.min.js.map'),indexText=fs.readFileSync(indexFile,'utf-8').split(/\\/\\/@@NG_LOADER_START@@[\\s\\S]*\\/\\/@@NG_LOADER_END@@/).join('//@@NG_LOADER_START@@\\n'+loaderText+' //@@NG_LOADER_END@@');fs.writeFileSync(indexFile,indexText);\"" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
}, | ||
"dependencies": { | ||
"angular": "^1.5.8", | ||
"angular-loader": "^1.5.8", | ||
"angular-route": "^1.5.8", | ||
"html5-boilerplate": "0.0.1" | ||
}, | ||
"local-web-server": { | ||
"port": 8000, | ||
"rewrite": [ | ||
{ "from": "/lib/*", "to": "./node_modules/$1" }, | ||
{ "from": "/*", "to": "./app/$1" } | ||
] | ||
} | ||
} |
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.
Why os this needed? Previously the files were served from
bower_components
, why can't they just now be served fromnode_modules
without any rewriting server?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.
Because the root directory (for the webapp) is
app/
which is a sibling ofnode_module/
.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 see. And in
package.json
it's not possible to specify an alternative location ofnode_modules
.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.
We could create a separate
package.json
insideapp/
. ;)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.
We could. I did think about that. But I felt that might be more confusing than helpful.
And in reality, and real project is going to have a build step of some kind, right?
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.
In that case it might be better to do the following in the build process:
app/dist/
app/dist/
jQuery uses the
npmcopy
Grunt task for this[1] but regular copying should work as well.I'd like the official seed to stop using Bower as we're discouraging its use so we're not following our own advice if we keep using it.
[1] https://github.com/jquery/jquery/blob/7fbab88/Gruntfile.js#L78-L104
EDIT: Clarified the description a little.
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 would rather not introduce a task runner (grunt, gulp etc). Everyone will have a different preference and this seed project has been tranditionally quite unopinionated. Also, keep n mind that
angular-seed
is used as a base forangular-phonecat
, so simplicity is a feature 😃How about using an npm script (e.g. postinstall) that copies the necessary files from
node_modules/...
toapp/lib/
? It is still less straightforward thanbower install
imo, but more straightforward than using a task runner or a rewriting server. WDYT?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.
@gkalpak That's exactly what I proposed in my last comment...
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.
Ooops, I thought you were proposing to use Grunt 😁
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.
No, I just gave an example of how jQuery does it. :) The details of the copying mechanisms are not the most important parts.