Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,302 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`commonsChunkPlugin transforms correctly using "commonsChunkPlugin-0" data 1`] = `
"module.exports = {
entry: {
app: './src/app.js',
vendor: './src/vendors.js',
},

optimizations: {
splitChunks: {
cacheGroups: {
app: {
name: 'app',
chunks: 'initial',
enforce: true,
test: 'app'
},

vendor: {
name: 'vendor',
chunks: 'initial',
enforce: true,
test: 'vendor'
}
}
}
}
}
"
`;

exports[`commonsChunkPlugin transforms correctly using "commonsChunkPlugin-1" data 1`] = `
"module.exports = {
entry: {
vendor: './src/vendors.js',
},

optimizations: {
splitChunks: {
cacheGroups: {
common: {
name: 'common',
chunks: 'initial',

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The default minChunks for the CCP is the number of selected chunks. So you may count the number of entrypoints here.

enforce: true
},

vendor: {
name: 'vendor',
chunks: 'initial',
enforce: true,
test: 'vendor'
}
}
}
}
}
"
`;

exports[`commonsChunkPlugin transforms correctly using "commonsChunkPlugin-2" data 1`] = `
"module.exports = {
entry: {
vendor: './src/vendors.js',
},

optimizations: {
splitChunks: {
cacheGroups: {
vendor: {
name: 'vendor',
chunks: 'initial',
enforce: true,
test: 'vendor'
}
}
}
}
}
"
`;

exports[`commonsChunkPlugin transforms correctly using "commonsChunkPlugin-3" data 1`] = `
"module.exports = {
optimizations: {
splitChunks: {
cacheGroups: {
commons: {
name: 'commons',
chunks: 'initial',

This comment was marked as resolved.

enforce: true,
filename: 'commons.js'
}
}
}
}
}
"
`;

exports[`commonsChunkPlugin transforms correctly using "commonsChunkPlugin-4" data 1`] = `
"module.exports = {
entry: {
main: './src/index.js',
},

optimizations: {
splitChunks: {
cacheGroups: {
main: {
name: 'main',
enforce: true,
test: 'main',
chunks: 'async',
minSize: 2000
}
}
}
}
}
"
`;

exports[`commonsChunkPlugin transforms correctly using "commonsChunkPlugin-5" data 1`] = `
"module.exports = {
entry: {
main: './src/index.js',
},

optimizations: {
splitChunks: {
cacheGroups: {
main: {
name: 'main',
chunks: 'initial',
enforce: true,
test: 'main'
}
}
},

runtimeChunk: {
name: 'runtime'
}
}
}
"
`;

exports[`commonsChunkPlugin transforms correctly using "commonsChunkPlugin-6a" data 1`] = `
"module.exports = {
entry: {
main: './src/index.js',
},

optimizations: {
splitChunks: {
cacheGroups: {
main: {
name: 'main',
chunks: 'initial',
enforce: true,

test: module => {
if (module.getChunks().some(chunk => chunk.name === 'main'))
return true;

const fn = ({ resource }) => /node_modules/.test(resource);
return fn(module);
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks correct to me

}
}
}
}
}
"
`;

exports[`commonsChunkPlugin transforms correctly using "commonsChunkPlugin-6b" data 1`] = `
"module.exports = {
entry: {
main: './src/index.js',
},

optimizations: {
splitChunks: {
cacheGroups: {
main: {
name: 'main',
chunks: 'initial',
enforce: true,

test: module => {
if (module.getChunks().some(chunk => chunk.name === 'main'))
return true;

const fn = ({ resource }) => {
// some code
return /node_modules/.test(resource);
};

return fn(module);
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks correct to me

}
}
}
}
}
"
`;

exports[`commonsChunkPlugin transforms correctly using "commonsChunkPlugin-6c" data 1`] = `
"module.exports = {
entry: {
main: './src/index.js',
},

optimizations: {
splitChunks: {
cacheGroups: {
main: {
name: 'main',
chunks: 'initial',
enforce: true,

test: module => {
if (module.getChunks().some(chunk => chunk.name === 'main'))
return true;

const fn = function ({ resource }) {
// some code
return /node_modules/.test(resource);
};

return fn(module);
}
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks correct to me

}
}
}
}
"
`;

exports[`commonsChunkPlugin transforms correctly using "commonsChunkPlugin-6d" data 1`] = `
"module.exports = {
entry: {
main: './src/index.js',
},

optimizations: {
splitChunks: {
cacheGroups: {
main: {
name: 'main',
chunks: 'initial',
enforce: true,

test: module => {
if (module.getChunks().some(chunk => chunk.name === 'main'))
return true;

const fn = function ({ resource }) {
if (foo) {
return /node_modulesfoo/.test(resource);
} else {
return /node_modulesbaz/.test(resource);
}
};

return fn(module);
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks correct to me

}
}
}
}
}
"
`;

exports[`commonsChunkPlugin transforms correctly using "commonsChunkPlugin-7" data 1`] = `
"module.exports = {
entry: {
main: './src/index.js',
},

optimizations: {
splitChunks: {
cacheGroups: {
main: {
name: 'main',
chunks: 'initial',
enforce: true,
test: 'main',
minSize: 3000
}
}
}
}
}
"
`;
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
module.exports = {
entry: {
app: './src/app.js',
vendor: './src/vendors.js',
},
plugins: [
new webpack.optimize.CommonsChunkPlugin({
names: ["app", "vendor"],
minChunks: 2
})
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module.exports = {
entry: {
vendor: './src/vendors.js',
},

plugins: [
new webpack.optimize.CommonsChunkPlugin({
names: ["common", "vendor"]
})
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module.exports = {
entry: {
vendor: './src/vendors.js',
},

plugins: [
new webpack.optimize.CommonsChunkPlugin({
names: ["vendor"]
})
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module.exports = {
plugins: [
new webpack.optimize.CommonsChunkPlugin({
name: "commons",
filename: "commons.js",
})
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module.exports = {
entry: {
main: './src/index.js',
},

plugins: [
new webpack.optimize.CommonsChunkPlugin({
name: "main",
async: true,
minSize: 2000,
})
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module.exports = {
entry: {
main: './src/index.js',
},

plugins: [
new webpack.optimize.CommonsChunkPlugin({
names: ["main", "runtime"],
})
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
module.exports = {
entry: {
main: './src/index.js',
},

plugins: [
new webpack.optimize.CommonsChunkPlugin({
name: "main",
minChunks: ({ resource }) => /node_modules/.test(resource),
})
]
}
Loading