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

TypeError: "h is not a function" createUploadLink #123

Closed
MANTENN opened this issue Oct 25, 2018 · 9 comments
Closed

TypeError: "h is not a function" createUploadLink #123

MANTENN opened this issue Oct 25, 2018 · 9 comments

Comments

@MANTENN
Copy link

MANTENN commented Oct 25, 2018

I ejected my web application to make apollo-upload-client work.

package.json

{
  "name": "project-snow-frontend",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "@babel/core": "7.1.0",
    "@svgr/webpack": "2.4.1",
    "apollo-cache-inmemory": "^1.3.5",
    "apollo-client": "^2.4.2",
    "apollo-link": "^1.2.3",
    "apollo-link-context": "^1.0.9",
    "apollo-link-error": "^1.1.1",
    "apollo-link-http": "^1.5.5",
    "apollo-link-state": "^0.4.2",
    "apollo-upload-client": "^9.0.0",
    "babel-core": "7.0.0-bridge.0",
    "babel-eslint": "9.0.0",
    "babel-jest": "23.6.0",
    "babel-loader": "8.0.4",
    "babel-plugin-named-asset-import": "^0.2.2",
    "babel-preset-react-app": "^5.0.2",
    "bfj": "6.1.1",
    "bootstrap": "^4.1.3",
    "case-sensitive-paths-webpack-plugin": "2.1.2",
    "chalk": "2.4.1",
    "css-loader": "1.0.0",
    "dotenv": "6.0.0",
    "dotenv-expand": "4.2.0",
    "eslint": "5.6.0",
    "eslint-config-react-app": "^3.0.3",
    "eslint-loader": "2.1.1",
    "eslint-plugin-flowtype": "2.50.1",
    "eslint-plugin-import": "2.14.0",
    "eslint-plugin-jsx-a11y": "6.1.1",
    "eslint-plugin-react": "7.11.1",
    "file-loader": "2.0.0",
    "fs-extra": "7.0.0",
    "fuse.js": "^3.2.1",
    "graphql": "^14.0.2",
    "graphql-tag": "^2.5.0",
    "html-webpack-plugin": "4.0.0-alpha.2",
    "identity-obj-proxy": "3.0.0",
    "jest": "23.6.0",
    "jest-pnp-resolver": "1.0.1",
    "jest-resolve": "23.6.0",
    "jwt-decode": "^2.2.0",
    "mini-css-extract-plugin": "0.4.3",
    "mobx": "^5.5.0",
    "mobx-react": "^5.2.8",
    "node-sass": "^4.9.3",
    "npm": "^6.4.1",
    "optimize-css-assets-webpack-plugin": "5.0.1",
    "pnp-webpack-plugin": "1.1.0",
    "postcss-flexbugs-fixes": "4.1.0",
    "postcss-loader": "3.0.0",
    "postcss-preset-env": "6.0.6",
    "postcss-safe-parser": "4.0.1",
    "react": "^16.5.2",
    "react-apollo": "^1.4.16",
    "react-app-polyfill": "^0.1.3",
    "react-dev-utils": "^6.0.3",
    "react-dom": "^16.5.2",
    "react-feather": "^1.1.4",
    "react-router-dom": "^4.3.1",
    "react-select": "^2.1.0",
    "reactstrap": "^6.5.0",
    "resolve": "1.8.1",
    "sass-loader": "7.1.0",
    "start": "^5.1.0",
    "style-loader": "0.23.0",
    "styled-components": "^3.4.9",
    "terser-webpack-plugin": "1.1.0",
    "url-loader": "1.1.1",
    "webpack": "4.19.1",
    "webpack-dev-server": "3.1.9",
    "webpack-manifest-plugin": "2.0.4",
    "workbox-webpack-plugin": "3.6.2"
  },
  "scripts": {
    "start": "node scripts/start.js",
    "build": "node scripts/build.js",
    "test": "node scripts/test.js --env=jsdom"
  },
  "browserslist": [
    ">0.2%",
    "not dead",
    "not ie <= 11",
    "not op_mini all"
  ],
  "devDependencies": {},
  "jest": {
    "collectCoverageFrom": [
      "src/**/*.{js,jsx}"
    ],
    "resolver": "jest-pnp-resolver",
    "setupFiles": [
      "react-app-polyfill/jsdom"
    ],
    "testMatch": [
      "<rootDir>/src/**/__tests__/**/*.{js,jsx}",
      "<rootDir>/src/**/?(*.)(spec|test).{js,jsx}"
    ],
    "testEnvironment": "jsdom",
    "testURL": "http://localhost",
    "transform": {
      "^.+\\.(js|jsx)$": "<rootDir>/node_modules/babel-jest",
      "^.+\\.css$": "<rootDir>/config/jest/cssTransform.js",
      "^(?!.*\\.(js|jsx|css|json)$)": "<rootDir>/config/jest/fileTransform.js"
    },
    "transformIgnorePatterns": [
      "[/\\\\]node_modules[/\\\\].+\\.(js|jsx)$",
      "^.+\\.module\\.(css|sass|scss)$"
    ],
    "moduleNameMapper": {
      "^react-native$": "react-native-web",
      "^.+\\.module\\.(css|sass|scss)$": "identity-obj-proxy"
    },
    "moduleFileExtensions": [
      "web.js",
      "js",
      "json",
      "web.jsx",
      "jsx",
      "node"
    ]
  },
  "babel": {
    "presets": [
      "react-app"
    ]
  },
  "eslintConfig": {
    "extends": "react-app"
  }
}

The app works when I run yarn start, however once it gets transpiled into ES2015, it crashes.

I have not modified anything other than webpackconfig to exclude mjs

@jaydenseric
Copy link
Owner

I have not modified anything other than webpackconfig to exclude mjs

You mean include .mjs?

@MANTENN
Copy link
Author

MANTENN commented Oct 25, 2018

Correct.
No as exclude.

        loader: require.resolve('file-loader'),
        // Exclude `js` files to keep "css" loader working as it injects
        // it's runtime that would otherwise be processed through "file" loader.
        // Also exclude `html` and `json` extensions so they get processed
        // by webpacks internal loaders.
        exclude: [/\.(js|jsx|mjs)$/, /\.html$/, /\.json$/],

@jaydenseric
Copy link
Owner

Is there a bug specific to apollo-upload-client, and can it be reproduced? If so, how?

@jaydenseric
Copy link
Owner

I don't see mjs in transformIgnorePatterns, does that mean that it is transforming the ESM to CJS, which is causing the named import to be undefined?

@jaydenseric
Copy link
Owner

CRA had bugs with Webpack and .mjs that have been fixed in new versions, are you sure you are on the latest version?

@MANTENN
Copy link
Author

MANTENN commented Oct 25, 2018

I installed create-react-app today on my machine. Running create-react-app returns 2.0.4. Yes, I went through this issue(#56) spent about 2 hours researching further info, and concluded eject is the only solution.

@MANTENN
Copy link
Author

MANTENN commented Oct 25, 2018

I don't see mjs in transformIgnorePatterns, does that mean that it is transforming the ESM to CJS, which is causing the named import to be undefined?

I am not too familiar with webpack

@MANTENN
Copy link
Author

MANTENN commented Oct 25, 2018

I didn't include mjs in the exclude option in the file webpack.config.prod.js

@MANTENN MANTENN closed this as completed Oct 25, 2018
@jaydenseric
Copy link
Owner

jaydenseric commented Oct 25, 2018

All this probably won't be necessary in CRA v2.0.5, which is in Github releases but not yet published to npm for some reason: facebook/create-react-app#5258

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants