Skip to content

Commit

Permalink
fix(gatsby): cleanup fullySpecified resolving
Browse files Browse the repository at this point in the history
  • Loading branch information
wardpeet committed Feb 18, 2021
1 parent a5210b2 commit 47a42ea
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 59 deletions.
38 changes: 0 additions & 38 deletions packages/gatsby/src/redux/actions/public.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,6 @@ const ensureWindowsDriveIsUppercase = filePath => {
: filePath
}

const deprecationWarnings = new Set()

const findChildren = initialChildren => {
const children = [...initialChildren]
const queue = [...initialChildren]
Expand Down Expand Up @@ -946,24 +944,6 @@ actions.createParentChildLink = (
* @param {Object} config partial webpack config, to be merged into the current one
*/
actions.setWebpackConfig = (config: Object, plugin?: ?Plugin = null) => {
if (config.module?.rules) {
config.module.rules.forEach(rule => {
if (!rule.resolve) {
// TODO move message to gatsbyjs.com/docs - change to structured
const key = `${plugin.name}-setWebpackConfig`
if (!deprecationWarnings.has(key)) {
report.warn(
`[deprecation] ${plugin.name} added a new module rule to the webpack config without specyfing the resolve property. This option will become mandatory in the next release. For more information go to https://webpack.js.org/configuration/module/#ruleresolve`
)
}
deprecationWarnings.add(key)
rule.resolve = {
fullySpecified: false,
}
}
})
}

return {
type: `SET_WEBPACK_CONFIG`,
plugin,
Expand All @@ -981,24 +961,6 @@ actions.setWebpackConfig = (config: Object, plugin?: ?Plugin = null) => {
* @param {Object} config complete webpack config
*/
actions.replaceWebpackConfig = (config: Object, plugin?: ?Plugin = null) => {
if (config.module?.rules && plugin) {
config.module.rules.forEach(rule => {
if (!rule.resolve) {
// TODO move message to gatsbyjs.com/docs - change to structured
const key = `${plugin.name}-setWebpackConfig`
if (!deprecationWarnings.has(key)) {
report.warn(
`[deprecation] ${plugin.name} added a new module rule to the webpack config without specyfing the resolve property. This option will become mandatory in the next release. For more information go to https://webpack.js.org/configuration/module/#ruleresolve`
)
}
deprecationWarnings.add(key)
rule.resolve = {
fullySpecified: false,
}
}
})
}

return {
type: `REPLACE_WEBPACK_CONFIG`,
plugin,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`sampleSiteForExperiment returns true or false depending on if they randomly are bucketed in or not 1`] = `true`;
exports[`sampleSiteForExperiment returns true or false depending on if they randomly are bucketed in or not 1`] = `false`;

exports[`sampleSiteForExperiment returns true or false depending on if they randomly are bucketed in or not 2`] = `false`;

exports[`sampleSiteForExperiment returns true or false depending on if they randomly are bucketed in or not 3`] = `true`;
exports[`sampleSiteForExperiment returns true or false depending on if they randomly are bucketed in or not 3`] = `false`;

exports[`sampleSiteForExperiment returns true or false depending on if they randomly are bucketed in or not 4`] = `true`;
exports[`sampleSiteForExperiment returns true or false depending on if they randomly are bucketed in or not 4`] = `false`;

exports[`sampleSiteForExperiment returns true or false depending on if they randomly are bucketed in or not 5`] = `false`;
exports[`sampleSiteForExperiment returns true or false depending on if they randomly are bucketed in or not 5`] = `true`;

exports[`sampleSiteForExperiment returns true or false depending on if they randomly are bucketed in or not 6`] = `true`;
exports[`sampleSiteForExperiment returns true or false depending on if they randomly are bucketed in or not 6`] = `false`;

exports[`sampleSiteForExperiment returns true or false depending on if they randomly are bucketed in or not 7`] = `false`;

exports[`sampleSiteForExperiment returns true or false depending on if they randomly are bucketed in or not 8`] = `false`;
exports[`sampleSiteForExperiment returns true or false depending on if they randomly are bucketed in or not 8`] = `true`;
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@
exports[`webpack utils dependencies returns default values without any options 1`] = `
Object {
"exclude": [Function],
"resolve": Object {
"fullySpecified": false,
},
"test": /\\\\\\.\\(js\\|mjs\\)\\$/,
"type": "javascript/auto",
"use": Array [
Expand Down Expand Up @@ -35,9 +32,6 @@ Object {
exports[`webpack utils js returns default values without any options 1`] = `
Object {
"include": [Function],
"resolve": Object {
"fullySpecified": false,
},
"test": /\\\\\\.\\(js\\|mjs\\|jsx\\)\\$/,
"type": "javascript/auto",
"use": Array [
Expand Down
16 changes: 7 additions & 9 deletions packages/gatsby/src/utils/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -290,15 +290,6 @@ module.exports = async (
rules.js({
modulesThatUseGatsby,
}),
// Webpack expects extensions when importing to mimic ESM spec.
// Not all libraries have adapted so we don't enforce its behaviour
// @see https://github.com/webpack/webpack/issues/11467
{
test: /\.m?js/,
resolve: {
fullySpecified: false
}
},
rules.yaml(),
rules.fonts(),
rules.images(),
Expand Down Expand Up @@ -423,6 +414,13 @@ module.exports = async (
"react-dom": getPackageRoot(`react-dom`),
},
plugins: [new CoreJSResolver()],
// https://webpack.js.org/configuration/module/#resolvefullyspecified
// Does not force extensions for ESM modules
byDependency: {
esm: {
fullySpecified: false,
},
},
}

const target =
Expand Down

0 comments on commit 47a42ea

Please sign in to comment.