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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: resolve style fields in package json #17346
Changes from 2 commits
9e896d2
21b9bb1
15e1e2a
dcd2d51
4db1194
ba6ba46
8234b14
47fa1dd
9f27e75
d61b29b
dcfa518
2669437
98d1f9c
426f90c
f0678c1
537f303
80743de
57318df
805b9b6
3c4c535
b9d3359
5f56793
e1de2dc
6cf449c
c76418a
5d1fdf7
078ce2c
0798a75
c350779
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -704,24 +704,16 @@ const applyModuleDefaults = ( | |||
}); | ||||
} | ||||
if (css) { | ||||
const styleResolutionDefaults = { | ||||
conditionNames: ["style"], | ||||
mainFields: ["style", "main", "..."], | ||||
mainFiles: ["index", "..."], | ||||
extensions: [".css", "..."] | ||||
}; | ||||
const cssRule = { | ||||
type: CSS_MODULE_TYPE, | ||||
resolve: { | ||||
...styleResolutionDefaults, | ||||
fullySpecified: true, | ||||
preferRelative: true | ||||
} | ||||
}; | ||||
const cssModulesRule = { | ||||
type: "css/module", | ||||
resolve: { | ||||
...styleResolutionDefaults, | ||||
fullySpecified: true | ||||
} | ||||
}; | ||||
|
@@ -1443,6 +1435,14 @@ const getResolveDefaults = ({ cache, context, targetProperties, mode }) => { | |||
extensions: [...jsExtensions] | ||||
}); | ||||
|
||||
/** @type {function(): ResolveOptions} */ | ||||
const styleDeps = () => ({ | ||||
conditionNames: ["style"], | ||||
mainFields: ["style", "main", "..."], | ||||
mainFiles: ["index", "..."], | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think we need it here, becaue it will resolve There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So we need a test case here too |
||||
extensions: [".css", "..."] | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure about There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Based on it webpack/lib/config/defaults.js Line 1417 in d61b29b
css should be
|
||||
}); | ||||
|
||||
/** @type {ResolveOptions} */ | ||||
const resolveOptions = { | ||||
cache, | ||||
|
@@ -1472,7 +1472,8 @@ const getResolveDefaults = ({ cache, context, targetProperties, mode }) => { | |||
// for backward-compat: Custom Dependency | ||||
unknown: cjsDeps(), | ||||
// for backward-compat: getResolve without dependencyType | ||||
undefined: cjsDeps() | ||||
undefined: cjsDeps(), | ||||
"css-import": styleDeps() | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What do you think rename it to just There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. CSS is already a module type. Wont that cause a collision? After renaming css-import to css in ExternalModule and CSSModule, the snapshots are failing. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should not because, it is just a dependecy type |
||||
} | ||||
}; | ||||
|
||||
|
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.
Don't think we need the
main
here, because it already in list, please try to remove it from here and test it