-
-
Notifications
You must be signed in to change notification settings - Fork 27.2k
Clean publish and eject #257
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
Conversation
|
Don't merge for now. I found this in CI build console. |
|
You probably want to chmod +x tasks/pack.sh |
|
@vjeux , Yes, I checked the permission on my local machine, it has +x permission. Thankfully, the last build (222.1) looks OK. |
config/webpack.config.dev.js
Outdated
| var webpack = require('webpack'); | ||
| var HtmlWebpackPlugin = require('html-webpack-plugin'); | ||
| var paths = require('./paths'); | ||
| var paths = require('./')('paths'); |
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’m worried that this convention is going to look super confusing to people after ejecting (or even for those who want to contribute to this project). What alternative solutions have you considered?
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 agree that the code is confusing to some extent. In fact, I leant very recently that require looks for index.js when the required path is a folder.
Two ideas:
- replace it with
require('../config')('paths');even if the file is in the same folder. At least the wordconfigappears in the code to suggest the meaning of this line. - create a symbolic name config so that the above code is rewritten as
require('config')('paths').
I don't know how to do 2 honestly. I will take a look at this method and search for others.
There is another decision worthy a discussion: should config/index.js export a function (like the current change) or an object with fields like paths and so on.
It is more conventional for a module to export an object or a constructor. But exporting a function has advantages in this case:
- the code is short, and we don't need to introduce a new field every time when a new configuration is introduced; simply create a *.prod|dev.js file.
- we could add an error message/exception when developers made a typo on importing a configuration, let the typo be exposed earlier.
- in test/dev, we are still able to import a prod config (e.g. the current
build.jsalways useswebpack.prod)
|
Looking at this, I think we should keep it simple and not mess with the filenames. // paths.js
module.exports = {
// ejected paths
}
// @remove-on-eject-begin
if (...) {
module.exports = // local dev paths
} else if (...) {
module.exports = // dependency paths
}
// @remove-on-eject-end |
Changes in this PR cut off code at 2 places
If we don't do 1, then dev-only flags like I like your syntax of |
|
We can do (1) with separate flags. // paths.js
module.exports = {
// ejected paths
}
// @remove-on-publish-begin
if (...) {
module.exports = // local dev paths
}
// @remove-on-publish-end
// @remove-on-eject-begin
if (...) {
module.exports = // dependency paths
}
// @remove-on-eject-end |
|
Yes, merging *.prod.js file and *.dev.js into one file is a good idea for code maintenance. I will try later today or over this weekend. Thanks for your advice. |
163e252 to
81cb759
Compare
61e588d to
170b603
Compare
|
Refactored and rebased previous changes as suggested. To summarise
As per the support of the above 2 tags, if code looks OK, this PR is ready to be merged. If we wanted to merge
In an earlier test, it seems fine to let I will search for |
tasks/clean_pack.sh
Outdated
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.
Can you please use the same error handling mechanism that e2e test now uses?
|
I left a few final comments, I think it’s good to go when they are addressed. |
170b603 to
be39c14
Compare
be39c14 to
30aa0de
Compare
|
@gaearon , I rebased as suggested. Do you think we should use the same error handling mechanism in |
4fd98ce to
9f5226d
Compare
6d753ff to
7e9b45b
Compare
7e9b45b to
a361970
Compare
…ly code (@remove-on-eject-begin/end) facebook#257
a361970 to
ab49abe
Compare
|
Rebased. @gaearon , do you plan to add this PR back to milestone 0.3.0, if not merging it soon? Currently, minor changes to config/paths.js will cause code conflicts due reordering of configs. I don't mind to rebase again when it is a good time to deliver. Just curious about the plan. |
9f5226d to
ab49abe
Compare
|
Let’s get this in and maybe iterate on it later. |
|
This is really nice. 👍 If you’d like, please feel free to make a followup PR to make eject result more natural. For example I think it might make sense to try to write |
|
@gaearon , good point. I will try as you suggested. |
…ly code (@remove-on-eject-begin/end) facebook#257 (facebook#257)
…ly code (@remove-on-eject-begin/end) facebook#257 (facebook#257)

--smoke-testtag is kept in production code for now--debug-templateflage2etest, when testing cli, only pack production codeDisscussion 1: add parameter
stageto pack.sh so thatThis can be done by removing
filesin package.json, and creating a few versions of .npmignore files (e.g. .npmignore.prod).Disscussion 2: further split paths.prod.js to 2 files, paths.beforeEject.js and paths.afterEject.js; remove the
// Dead code on eject:start/endblock.Question:
start.js always use the dev config for webpack. Is there a reason for this? In my local test, it seems fine to use production config in a generated app.