-
-
Notifications
You must be signed in to change notification settings - Fork 375
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
feature: Installing dependencies with yarn #31
Conversation
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.
Nice!
Perhaps we could refactor away the npm()
helper entirely & run everything through spawn()
?
Good call. Also npm-install-loader possibly could use yarn not end up with missing dependencies in yarn.lock file. |
src/lib/run-webpack.js
Outdated
@@ -66,13 +66,12 @@ export function writeJsonStats(stats) { | |||
jsonStats.modules.forEach(normalizeModule) | |||
jsonStats.chunks.forEach(c => c.modules.forEach(normalizeModule)) | |||
|
|||
return fs.writeFile(outputPath, JSON.stringify(jsonStats)) |
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.
Sneaky refactor 👣
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.
well-earned, I'd say ;)
@lukeed removed I've looked into
What's the point of the loader? |
package.json
Outdated
@@ -94,7 +94,7 @@ | |||
"babel-register": "^6.24.1", | |||
"copy-webpack-plugin": "^4.0.1", | |||
"cross-spawn-promise": "^0.10.1", | |||
"css-modules-require-hook": "^4.1.0-beta", | |||
"css-modules-require-hook": "^4.0.6", |
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.
This is the culprit of #22 and issues with yarn. I don't know why beta version was used - last stable version works fine for prerendering (at least for the examples). Don't know if that's ok.
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.
Ooh cool. I'll check this out!
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.
heads up - i merged @lukeed's PR without seeing this first.
I finished review this PR, read several articles on hacker news and it's still installing devDeps. So 👍 👍 |
src/commands/create.js
Outdated
@@ -83,7 +84,7 @@ export default asyncCommand({ | |||
|
|||
spinner.text = 'Initializing project'; | |||
|
|||
await npm(target, ['init', '-y']); | |||
await spawn('npm', ['init', '-y'], { cwd: target, stdio: 'ignore' }) |
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.
lol this is what it used to be 😆
does Yarn not include an init
functionality like npm's?
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.
@developit yes it does
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.
future thing to do might be to move the which
check up and use yarn here too. For now anyone running yarn would have npm installed anyway.
src/lib/run-webpack.js
Outdated
@@ -66,13 +66,12 @@ export function writeJsonStats(stats) { | |||
jsonStats.modules.forEach(normalizeModule) | |||
jsonStats.chunks.forEach(c => c.modules.forEach(normalizeModule)) | |||
|
|||
return fs.writeFile(outputPath, JSON.stringify(jsonStats)) |
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.
well-earned, I'd say ;)
src/commands/create.js
Outdated
if(isDev) { | ||
args.push('-D') | ||
} | ||
|
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 can slim this down by moving the .filter(Boolean)
into install, but I'll just slip that in post-merge :)
@rkostrzewski regarding The use case is: you created a new project and added a |
@rkostrzewski should we move |
@developit I don't think it works at all. The less example might work because less-loader is included in preact-cli deps.
Yields:
Even tough sass-loader & node-sass are included in npm-install-loader config. That's why I was asking. I'll try to fix it along while adding yarn to it. |
@developit Yeah, I think it won't work and if I'm not wrong there's no way to fix this. Long story short, webpack verifies if all loaders are present before attempting to compile files. This happens in NormalModuleFactory and occurs before compiler starts compiling & any loaders are run (source + empirical tests). Seemed like a cool feature tough 😢 |
Darn. I had figured pitching phase would circumvent that. One other option would be to use a proxy loader - that internally does the installation and then calls out to less-loader. |
…tall # Conflicts: # src/commands/create.js
Yeah, proxying the loader would work for normal loaders. However it would be hard to make it work with pitch loaders and the solution looks very hacky. |
…tall # Conflicts: # src/lib/run-webpack.js
@rkostrzewski I think you can just fix that in webpack by passing a |
@hassanbazzi I don't quite get how to use |
|
…tall # Conflicts: # package.json
@rkostrzewski Travis tests are failing because of an eslint error. Can I go ahead and fix that error? But there is this error - https://travis-ci.org/developit/preact-cli/jobs/247829570#L1925-L1926 which I didn't understand. What is this about? |
@reznord sure go ahead. As for the other error I think there's some problem with async commands. I think about spiking the tesrs with console.log to determine where the error is (seems like output folder doesn't exist sometimes on first test) |
Also @lukeed has proposed installing with tarn using a switch as new npm has same capabilities as yarn with which I totally agree. |
@rkostrzewski I'm not agree with this. Yarn offers much more besides speed and lock file. IMHO, if someone installed yarn it mean that they want to use it. How about an interactive question to ask which dependency manager to use? |
@rkostrzewski you have to make the changes, since it is a branch in your local repo :P |
Well, consider this case where you have enabled |
@reznord try npm@5 ;) |
@thangngoc89 I did try, I have to say that it is faster than previous versions but still not close to yarn. |
@reznord It's faster than yarn in my exeperience. Maybe your npm@5 global cache is empty? But anyway, see my comment above for my opinion |
Chiming in: Yes, I think We should use a Just my 2¢ 😉 |
@lukeed That seems ok to me |
Agreed on this !! |
Oooh very good point @lukeed, I'm for the |
@rkostrzewski Unless I'm hugely mistaken, it doesn't look like that PR is going with a |
@lukeed yeah I've meant continuing as in developing |
A fresh new PR available for |
Changes
npm install
toyarn add
when creating app & yarn is available as global command (similar to how create-react-app works). Faster install, progressive enhancement, yada, yada, yada.Your next Preact PWA starts in less than 30 seconds. 😉
Cross-platform compatibility verified on MacOS & Windows 10.