-
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
Stable webpacker 4.0 release #1823
Conversation
Please feel free to link other issues you might think are important and we can work together to either ship them in the initial 4.x release or subsequent 4.x releases. |
Is someone up for helping with docs i.e. if we need to improve or update? Feel free to make PRs |
Also, need to make a list of features that are new/improved in Webpacker 4.0 |
Please expect the final release to be made by end of this week (once this PR is merged). |
You will need 3rd party webpacker libraries should note that #1822 is a breaking change. |
@ytbryan Both included with webpacker and works out of the box: https://github.com/rails/webpacker/blob/master/package.json#L27 |
|
||
chdirTestApp() | ||
|
||
const config = require('../config') | ||
|
||
describe('Config', () => { | ||
beforeEach(() => jest.resetModules()) | ||
beforeEach(() => jest.resetModules() && resetEnv()) |
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.
resetEnv
like this might give you more problems than you would expect. I would do:
beforeEach(() => {
jest.resetModules()
process.env = {}
// OR
// delete process.env.RAILS_ENV
})
package/utils/helpers.js
Outdated
if (hasTrailingSlash) return path.substr(0, path.length - 1) | ||
return path | ||
} | ||
const resetEnv = () => (process.env = {}) |
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.
https://travis-ci.org/rails/webpacker/jobs/465694990#L703 CI is pointing out that you are returning the value of the assignment. I would omit this altogether.
Thank you for all the great work and bringing webpack to rails. Would it perhaps be a good default to rename I like the customizability of this framework but it is sometimes confusing which config to modify and where to inject, what, to make webpack behave a certain way. Perhaps we could add a few predefined functions that you can import in the |
This is precisely what I did on the project I'm working on - I got rid of |
I can also recommend the following webpack dev server settings: config/webpack/environment.js const { environment } = require('@rails/webpacker')
// Reduce the output of the Webpack Dev Server
environment.config.merge({
devServer: {
stats: {
entrypoints: false,
errorDetails: false,
modules: false,
moduleTrace: false
}
}
});
module.exports = environment Perhaps a good default? It reduces the output of webpack dev server to just the pack statistics (names, filesizes etc.). |
package/rules/file.js
Outdated
|
||
module.exports = { | ||
test: /\.(jpg|jpeg|png|gif|tiff|ico|svg|eot|otf|ttf|woff|woff2)$/i, | ||
test: new RegExp(fileExtensions.join('|'), 'i'), |
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.
regexp should be changed slightly
test: new RegExp(fileExtensions.join('|'), 'i'), | |
test: new RegExp(`\\.(${fileExtensions.join('|')})$`, 'i'), |
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.
@Morantron Not sure if we need dot there since extensions already include them?
/.jpg|.jpeg|.png|.gif|.tiff|.ico|.svg|.eot|.otf|.ttf|.woff|.woff2/i
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.
Changed it to this:
new RegExp(`(${fileExtensions.join('|')})`, 'i') =>
/(.jpg|.jpeg|.png|.gif|.tiff|.ico|.svg|.eot|.otf|.ttf|.woff|.woff2)/i
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.
True! It's missing the trailing dollar, It could be an issue since without it it can match the extension in the middle of the filename
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.
Gotcha thanks @Morantron 🙏
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.
Fixed in #1832
@gauravtiwari I get the impression that this v4 release is getting held up so that things are in place for Rails 6 to make Webpacker the default asset pipeline. Is that correct? That said, webpacker's lack of webpack v4 and babel v7 support is causing issues with us upgrading other dependencies that our applications use on the JS side like Storybook. It seems like the v4 release has been a long time in the release candidate state. It's ok if it will take some time to get things ready for Rails 6. I totally understand but is there a middle ground where consumers of Webpacker can utilize a stable version with webpack v4 and babel v7 support sooner rather than later? |
@nickpith I think that was already merged into master rails/rails#33079 (rails/rails@4838c17#diff-e79a60dc6b85309ae70a6ea8261eaf95R37) |
622958f
to
71266e1
Compare
Published a release candidate, please give it a try and if no issues found, will make a final release this weekend. |
Thanks @gauravtiwari! |
Made another release, which fixes a bug (#1835), thanks @Zyphrax for testing and reporting 🙏 |
Thanks @gauravtiwari, the bug has been fixed. Unfortunately the |
This PR is final PR to finish up some remaining bits and release Webpacker 4.x.
Apologies it took us a while but looks like Webpacker is now in a great shape. Thanks, everyone for chipping in and making things better.
Things I would like to finish and ship:
[ ] Integrity hashes for assets - Subresource Integrity #323 (Not done)Engines support - there are two pending PRs Refactor singleton usage #1808 and Resolve errors blocking usage in a mountable Rails engine #1694Update: Will look into integrity hashes in other PR or perhaps after 4.0 release including engines support.