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

Fix wp loaders #1077

Merged
merged 1 commit into from
Nov 21, 2016
Merged

Fix wp loaders #1077

merged 1 commit into from
Nov 21, 2016

Conversation

bebbi
Copy link
Contributor

@bebbi bebbi commented Nov 21, 2016

Addresses #667.

@bebbi
Copy link
Contributor Author

bebbi commented Nov 21, 2016

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'),
Copy link
Contributor

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.

Copy link
Contributor Author

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

Copy link
Contributor

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)$/,
Copy link
Contributor

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.

Copy link
Contributor Author

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.
@fson
Copy link
Contributor

fson commented Nov 21, 2016

Looks good to me!

@fson fson merged commit 6e00813 into facebook:master Nov 21, 2016
jarlef pushed a commit to jarlef/create-react-app that referenced this pull request Nov 28, 2016
Revert webpack prod config comments to not refer to dev server.
fson added a commit to fson/create-react-app that referenced this pull request Dec 4, 2016
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.
fson added a commit that referenced this pull request Dec 4, 2016
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.
alexdriaguine pushed a commit to alexdriaguine/create-react-app that referenced this pull request Jan 23, 2017
Revert webpack prod config comments to not refer to dev server.
alexdriaguine pushed a commit to alexdriaguine/create-react-app that referenced this pull request Jan 23, 2017
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.
randycoulman pushed a commit to CodingZeal/create-react-app that referenced this pull request May 8, 2017
Revert webpack prod config comments to not refer to dev server.
randycoulman pushed a commit to CodingZeal/create-react-app that referenced this pull request May 8, 2017
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.
@lock lock bot locked and limited conversation to collaborators Jan 22, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants