-
-
Notifications
You must be signed in to change notification settings - Fork 26.9k
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
Fix wp loaders #1077
Fix wp loaders #1077
Conversation
This may need changes based on issue comments. |
@@ -21,7 +21,7 @@ module.exports = (resolve, rootDir, isEjecting) => { | |||
collectCoverageFrom: ['src/**/*.{js,jsx}'], | |||
moduleFileExtensions: ['jsx', 'js', 'json'], | |||
moduleNameMapper: { | |||
'^.+\\.(ico|jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$': resolve('config/jest/FileStub.js'), | |||
'^.+\\.(?!(js|jsx|css|json|html)$)[^\\.]+$': resolve('config/jest/FileStub.js'), |
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.
The .html
extension shouldn't be needed here because importing .html
files is not supported.
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.
ok - if you think this works otherwise I'll just remove the html
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.
The reason we use moduleNameMapper
is just so that imports with these file types get stubbed by Jest, instead of failing because Node.js can't import them. But the only HTML file we handle is index.html
, and never imported in code. So yes, it should work.
@@ -124,6 +124,7 @@ module.exports = { | |||
// A missing `test` is equivalent to a match. | |||
{ | |||
exclude: [ | |||
/\.(html)$/, |
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.
You can omit the parentheses around html
.
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.
yes :)
Revert webpack prod config comments to not refer to dev server.
Looks good to me! |
Revert webpack prod config comments to not refer to dev server.
Jest matches moduleNameMapper regexes with module names, not the full file path, so the negative lookahead doesn’t work for filtering out JS files, because they can be imported without the extension. So paths like `lodash.assign` and `../utils/range` were mislabeled as resources with unknown file extensions because they have a dot in the name. As a stopgap measure, revert the moduleNameMapper regex added in facebook#1077.
Jest matches moduleNameMapper regexes with module names, not the full file path, so the negative lookahead doesn’t work for filtering out JS files, because they can be imported without the extension. So paths like `lodash.assign` and `../utils/range` were mislabeled as resources with unknown file extensions because they have a dot in the name. As a stopgap measure, revert the moduleNameMapper regex added in #1077.
Revert webpack prod config comments to not refer to dev server.
Jest matches moduleNameMapper regexes with module names, not the full file path, so the negative lookahead doesn’t work for filtering out JS files, because they can be imported without the extension. So paths like `lodash.assign` and `../utils/range` were mislabeled as resources with unknown file extensions because they have a dot in the name. As a stopgap measure, revert the moduleNameMapper regex added in facebook#1077.
Revert webpack prod config comments to not refer to dev server.
Jest matches moduleNameMapper regexes with module names, not the full file path, so the negative lookahead doesn’t work for filtering out JS files, because they can be imported without the extension. So paths like `lodash.assign` and `../utils/range` were mislabeled as resources with unknown file extensions because they have a dot in the name. As a stopgap measure, revert the moduleNameMapper regex added in facebook#1077.
Addresses #667.