Skip to content
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

Version update - most imporantly Webpack 4 #113

Merged
merged 19 commits into from
Apr 18, 2018
Merged

Version update - most imporantly Webpack 4 #113

merged 19 commits into from
Apr 18, 2018

Conversation

EECOLOR
Copy link
Member

@EECOLOR EECOLOR commented Apr 9, 2018

@EECOLOR
Copy link
Member Author

EECOLOR commented Apr 9, 2018

We need to update 'package.json' file with the actual current versions.

Copy link
Member Author

@EECOLOR EECOLOR left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should also test this branch against a few sites that are already in production, both watch and build

@@ -81,7 +81,7 @@ module.exports = function CssLoader(source, map) {

function executeModuleAt(url) {
return source => {
const completeSource = `const __webpack_public_path__ = '${self.options.output.publicPath || '/'}'\n` + source
const completeSource = `const __webpack_public_path__ = '${self._compiler.options.output.publicPath || '/'}'\n` + source
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

module.exports = function websocketCommunicationPlugin() {

return {
apply: compiler => {
// we should add this check to all hooks we create
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, do that

@EECOLOR
Copy link
Member Author

EECOLOR commented Apr 9, 2018

Used syncyarnlock to update package.json files. For future reference:

syncyarnlock -p ./library -k -s
syncyarnlock -p ./example -k -s
yarn

@EECOLOR EECOLOR requested a review from klaasman April 9, 2018 13:14
chunkAssets[chunk.name] = {
filename,
hasRuntime: chunk.hasRuntime(),
parents: chunk.parents.map(c => c.name).filter(Boolean)
isShared,
...(!isShared && { dependencies: group.chunks.filter(x => x !== chunk).map(x => x.name) })
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can not use this syntax for nodejs < 8.6

Copy link
Contributor

@klaasman klaasman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Still needs testing with some projects.

"react-dom": "^16.2.0",
"normalize.css": "^8.0.0",
"react": "^16.3.1",
"react-dom": "^16.3.1",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

react and react-dom aren't necessary anymore - they were defined for [email protected]

@@ -2,6 +2,7 @@

Breaking changes:

- v0.0.?? - `chunk-manifest.json` changed
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't forget this

"helmet": "^3.9.0",
"express": "^4.16.3",
"file-loader": "^1.1.11",
"find-yarn-workspace-root": "^1.1.0",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎉

@@ -25,7 +30,8 @@ const fragmentResolverPlugin = require('../webpack-resolver-plugins/fragment-res
const CaseSensitivePathsPlugin = require('case-sensitive-paths-webpack-plugin')
const ExtendedAPIPlugin = require('webpack/lib/ExtendedAPIPlugin')
const ProgressBarPlugin = require('progress-bar-webpack-plugin')
const findYarnWorkspaceRoot = require('find-yarn-workspace-root')
const TimeFixPlugin = require('time-fix-plugin') // https://github.com/webpack/watchpack/issues/25
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will this fix the weird build loops which occasionally happened?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most of them, yes

@@ -25,7 +30,8 @@ const fragmentResolverPlugin = require('../webpack-resolver-plugins/fragment-res
const CaseSensitivePathsPlugin = require('case-sensitive-paths-webpack-plugin')
const ExtendedAPIPlugin = require('webpack/lib/ExtendedAPIPlugin')
const ProgressBarPlugin = require('progress-bar-webpack-plugin')
const findYarnWorkspaceRoot = require('find-yarn-workspace-root')
const TimeFixPlugin = require('time-fix-plugin') // https://github.com/webpack/watchpack/issues/25
const UglifyJsPlugin = require('uglifyjs-webpack-plugin')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎉

})
})

// tell the web compiler to compile, emit the assets and notify the appropriate plugins
compiler.plugin('make-additional-entries', (compilation, createEntries, done) => {
// Note, we can not use `make` because it's parralel
compiler.hooks.makeAdditionalEntries.tapAsync(p, (compilation, _, done) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how do we name the third argument, callback or done?

compilation.dependencyFactories.set(ConstDependency, new NullFactory())
compilation.dependencyTemplates.set(ConstDependency, new ConstDependency.Template())
compilation.mainTemplate.plugin('require-extensions', function(source, chunk, hash) {
compilation.mainTemplate.hooks.requireExtensions.tap(p, function(source, chunk, hash) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

arrow function is fine

})
compilation.mainTemplate.hooks.globalHash.tap(p, () => true)
normalModuleFactory.hooks.parser.for('javascript/auto').tap(p, addParserHooks)
normalModuleFactory.hooks.parser.for('javascript/dynamic').tap(p, addParserHooks)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no idea what's happening here with the auto/dynamic stuff?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check here for an explanation of these: https://medium.com/webpack/webpack-4-released-today-6cdb994702d4#b6a9

It essentially requires us to define in which types of files this hook should trigger.

})
compilation.mainTemplate.hooks.globalHash.tap(p, () => true)
normalModuleFactory.hooks.parser.for('javascript/auto').tap(p, addParserHooks)
normalModuleFactory.hooks.parser.for('javascript/dynamic').tap(p, addParserHooks)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I notice there's duplicate code in merge-css-plugin

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the duplication?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

compilation.dependencyFactories.set(ConstDependency, new NullFactory())
compilation.dependencyTemplates.set(ConstDependency, new ConstDependency.Template())
compilation.mainTemplate.hooks.requireExtensions.tap(p, function(source, chunk, hash) {
  // ...
}
compilation.mainTemplate.hooks.globalHash.tap(p, () => true)
normalModuleFactory.hooks.parser.for('javascript/auto').tap(p, addParserHooks)
normalModuleFactory.hooks.parser.for('javascript/dynamic').tap(p, addParserHooks)

Might be just fine like this

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahh, yeah, the code looks very similar. It even is similar, but I am unsure if I want to extract it. I'll experiment with it.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed it, despite the amount of arguments required I think it's a good abstraction. It also showed a few minor flaws so it already paid off (or proved that evaluateTypeOf was not used).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

})
compilation.mainTemplate.hooks.globalHash.tap(p, () => true)
normalModuleFactory.hooks.parser.for('javascript/auto').tap(p, addParserHooks)
normalModuleFactory.hooks.parser.for('javascript/dynamic').tap(p, addParserHooks)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

more duplicate code

@EECOLOR
Copy link
Member Author

EECOLOR commented Apr 11, 2018

Ok, I think the only thing we need to do for this release is test 😄

@klaasman klaasman merged commit b283a95 into master Apr 18, 2018
@klaasman klaasman deleted the version-update branch April 18, 2018 14:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants