-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
yarn_install task is not installing devDependencies #1212
Comments
@nikolalsvk Perhaps you can use yarn directly instead of relying on rake task? |
@gauravtiwari yes, I'm doing I'm just wondering could there be a different yarn_install task for testing environment for example? |
@nikolalsvk I guess what you could do is disable webpacker rake task and create a new one as before: # lib/tasks/yarn_install.rake
Rake::Task['yarn_install'].clear
task 'yarn_install' do
# old task here
end Would this work? |
@gauravtiwari guess it would work, thanks. I'm just curious why not leave the choice whether to install or not to install devDependencies? |
I'm having issues with this change as well. In particular, |
IMHO lots of people install |
Maybe I'm doing something wrong, but this change broke my production deploys. I too had all my compilation related packages in devDependencies, so the production server couldn't build the assets correctly. |
Cross-linking to #1330, where the task ends up removing dev dependencies which have already been installed. |
Any solutions? As in rails 5.2 the |
I am also having issues with |
I have a Rails 5.1.6 app with webpacker successfully deployed on Heroku app with 2 buildpacks: Upgrading to 5.2.0 breaks the Heroku build for the reasons @nikolalsvk listed above. The build fails because there is a number of Moving What is interesting is Heroku's approach to handling
( https://devcenter.heroku.com/articles/nodejs-support#package-installation ) It seems like a more reasonable approach than just excluding all Unfortunately, the rails buildpack is executed after the nodejs buildpack, and I am wondering what the correct solution should be. |
@leikind They are not With webpacker, we recommend putting all build and app related dependencies under dependencies section in package.json (except test deps). I understand the confusion but you see they are not app dependencies i.e. it won't be included in your pack but they are needed to produce a pack or build - either on Heroku or on your local machine. Does this make sense? |
The app is indeed built on Heroku, You see, if my app were a Node.js app using only the node buildpack, I'd have no issues building my app on Heroku, as the node buildpack would install all packages first, run build scripts (webpack for instance), and then strip devDependencies. So, the node team in Heroku does invite its customers to build their node apps on Heroku. I see no argument against building my app on Heroku except for the webpacker team making it harder. Here's my current hack to solve my problem: namespace :yarn do
desc 'Install all JavaScript dependencies as specified via Yarn'
task :install do
system('./bin/yarn install --no-progress')
Rake::Task['yarn:install'].clear
end
end |
Many teams run assets:precompile on heroku. In fact, it is a standard part of the rails build pack...
It does not. Webpack, babel, etc are dev ops tools. They are not application code. Heroku installs devDeps, so why force everyone to make a bad organization decision and move those to deps? This should be addressed by the Webpacker team... |
@gauravtiwari I agree this makes sense if you look at the I ran into the same problem myself when deploying this via the |
This is really confusing. I have the following devDependencies: "devDependencies": {
"@types/bootstrap": "<4",
"@types/braintree-web": "^3.6.3",
"@types/chartist": "^0.9.43",
"@types/daterangepicker": "<3",
"@types/dropzone": "^5.0.4",
"@types/jquery": "<3",
"@types/jqueryui": "^1.12.6",
"@types/moment-timezone": "^0.5.9",
"caniuse-lite": "^1.0.30000910",
"node-sass": "^4.10.0",
"resolve-url-loader": "^3.0.0",
"sass-loader": "^7.1.0",
"ts-loader": "^5.3.0",
"tslint": "^5.11.0",
"typescript": "^3.1.6",
"webpack": "^4.26.1",
"webpack-bundle-analyzer": "^3.0.3",
"webpack-dev-server": "^3.1.10"
} It doesn't make sense to me to move all the TypeScript typings and Webpack loaders in dependencies just to make compilation work. Would it be possible to remove the Yarn install step or turn it off? |
Let's take
This is what @gauravtiwari was getting at. Your rails app is "the end of the JS line", you don't need to worry about downstream users. I am aware that many READMEs will tell you to use TL;DR: If you need something to build you production bundle, it cannot be placed in |
@jakeNiemiec is there some confusion here about what |
IMO there are legitimate use cases for Webpacker hardcoding |
You never need to worry about downstream
Are you using webpack to bundle Karma or Jasmine? I don't understand why you would do this.
Less "confusion" and more like ritual inclusion of programing patterns that subvert their original purpose (e.g.: running CI tests in development mode). All it does is tell yarn/npm what libraries to put in TL;DR: You should follow what @gauravtiwari said, there are mechanical differences between the |
@jakeNiemiec sorry if I was unclear, but to clarify:
I'm using My suggestion is the webpacker commands should be environment aware. |
If you pass production bundles to your tests, you will get less surprises, faster testing times, and results that are truer to your actual production env. (but at the cost of increased build time) Real-life example: The Font Awesome package tends to break when using webpack 4, but only if you are in However, if you really want to have the autonomy to do this, you can use this trick to force a different environment: |
That's an example of bikeshedding if I ever saw one. Further, this is listed nowhere in the documentation. I should not have to crawl the Webpacker source or track down this exact issue just to find out that your team is imposing their own view on how Hundreds of other JS-based open source projects intentionally instruct you to use the And besides that, what is the |
@trent-boyd Mr Boyd, Thank you @gauravtiwari for your time contributing to the rails/webpacker project. Webpacker has been a delight and it saves me so much time integrating Vue into Rails <3 |
I don't think you'd like the the voice of my documentation on this one. 😉 It's just frustrating to see a lack of attention to his, especially when dev team has come up against it themselves and there's been an unaddressed PR about it for nine months. Even closing something as a #wontfix is fine if that's what the maintainers decide. |
The dev team has come up against it? Pretty sure the resolution was the opposite of what you portray:
👆That's bikeshedding if I ever saw it. The WebpackER team is aligning themselves with how Webpack is used by the Node.js community. This is smart, it will do a lot to reduce friction between Rails & JS pipelines. Remember that
Like I said here, those instructions aren't always meant for end users that are not creating a package themselves (like any Webpacker app). The 2 links below are useful for explaining why this is:
Rails is a development tool too 🙃. Did you know that both Webpack and Babel are set up to behave differently depending on which flag is set? (NODE_ENV) I personally would want to run tests against production bundles. The webpacker team is just trying to keep you on the most pain-free path. Just chuck your |
Neat. Awesome. I'm on board as long as it's in the docs.
Yes, and that's how I'd prefer it to stay. Using the |
Thanks, everyone and sorry about the confusion 🙏 @jakeNiemiec really like the way you have explained it ❤️ @trent-boyd I understand this could be confusing but even if we remove production flag, which I think we should because it hardcodes the environment. Anyway, Yarn would use |
We're still having production flag hardcoded y'all and I still don't understand why 😄 |
Reading this thread, I'm finding myself super confused. Are we supposed to not use devDependencies at all when using Webpacker? Is that the intended use? 😕 We don't use this rake task in our project (we just run |
We just don't use devDependencies. Yeah extra packages might get downloaded in production but it shouldn't be that big of a deal. To me it's just a paper cut, but the few hours I spent debugging I'll never get back. |
@csalvato Don't feel bad, people have been confusing this for over |
Due to the recent changes that have been made,
webpacker:yarn_install
task is not installingdevDependencies
. This is breaking my CI builds, since I relied on webpacker to do the install of packages for my test environment on the CI server.Change that brought this in the webpacker gem d5fe0fe#diff-5a0f30530a2f1282593526bb85d65029
Change that brought this in the Rails gem
rails/rails@2118c98#diff-dcd44149ba1cd25c12956a3ebecc32a3
I'm just wondering if we could introduce an optional
--production=true|false
flag in the rake task that doesyarn install
?Or create a
NODE_ENV
dependant flag for the rake task?The text was updated successfully, but these errors were encountered: