Webpack Cannot read properties of null (reading 'useEffect') - reactjs

I am trying to make one React Component Package but i am getting this error after i create bundle file with webpack. I am trying to make one Component with Typescript. I didn't create project from CRA. React and React-Dom package is lastest version. when i delete the ts-loader line from webpack it is working well but decleration packages are not generating.
react.development.js:1634 Uncaught TypeError: Cannot read properties of null (reading 'useEffect')
at Object.useEffect (react.development.js:1634:1)
at l (index.js:1:1)
at renderWithHooks (react-dom.development.js:16305:1)
at mountIndeterminateComponent (react-dom.development.js:20074:1)
at beginWork (react-dom.development.js:21587:1)
at beginWork$1 (react-dom.development.js:27426:1)
at performUnitOfWork (react-dom.development.js:26557:1)
at workLoopSync (react-dom.development.js:26466:1)
at renderRootSync (react-dom.development.js:26434:1)
at recoverFromConcurrentError (react-dom.development.js:25850:1)
My Webpack File
const path = require("path");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const nodeExternals = require('webpack-node-externals');
module.exports = {
entry: path.resolve(__dirname, "./src/index.tsx"),
resolve: {
extensions: [".tsx", ".ts", ".js"],
extensionAlias: {
".js": [".js", ".ts"],
".cjs": [".cjs", ".cts"],
".mjs": [".mjs", ".mts"]
},
},
module: {
rules: [
{
test: /\.(ts|js)x?$/,
exclude: /node_modules/,
use: [
{
loader: "babel-loader",
},
],
},
{ test: /\.([cm]?ts|tsx)$/, loader: "ts-loader" },
{
test: /\.css$/,
use: ["style-loader", "css-loader"],
},
{
test: /\.(?:ico|gif|png|jpg|jpeg)$/i,
type: "asset/resource",
},
{
test: /\.(woff(2)?|eot|ttf|otf|svg|)$/,
type: "asset/inline",
},
],
},
externals: [nodeExternals()],
output: {
path: path.resolve(__dirname, "./dist"),
filename: "index.js",
libraryTarget: "commonjs",
},
plugins: [
new HtmlWebpackPlugin({
template: path.resolve(__dirname, "./src/index.html"),
}),
],
stats: "errors-only",
};
Package.json file content
{
"name": "my-app",
"version": "1.0.0",
"description": "",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "webpack serve --config webpack.config.js --open",
"build": "rm -rf ./dist && webpack --mode production"
},
"keywords": [],
"author": "",
"license": "ISC",
"peerDependencies": {
"react": "^18.2.0",
"react-dom": "^18.2.0"
},
"devDependencies": {
"#babel/core": "^7.20.12",
"#babel/plugin-transform-runtime": "^7.19.6",
"#babel/preset-env": "^7.20.2",
"#babel/preset-react": "^7.18.6",
"#babel/preset-typescript": "^7.18.6",
"#types/react": "^18.0.26",
"#types/react-dom": "^18.0.10",
"babel-loader": "^9.1.2",
"html-webpack-plugin": "^5.5.0",
"ts-loader": "^9.4.2",
"typescript": "^4.9.4",
"webpack": "^5.75.0",
"webpack-cli": "^5.0.1",
"webpack-dev-server": "^4.11.1",
"webpack-node-externals": "^3.0.0"
}
}
TS Config content is;
{
"compilerOptions": {
"target": "ES5" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */,
"module": "ESNext" /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */,
"moduleResolution": "node" /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */ /* Type declaration files to be included in compilation. */,
"declaration": true,
"outDir": "dist",
"lib": [
"DOM",
"ESNext"
] /* Specify library files to be included in the compilation. */,
"jsx": "react-jsx" /* Specify JSX code generation: 'preserve', 'react-native', 'react' or 'react-jsx'. */,
"noEmit": false /* Do not emit outputs. */,
"isolatedModules": true /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */,
"esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */,
"strict": true /* Enable all strict type-checking options. */,
"skipLibCheck": true /* Skip type checking of declaration files. */,
"forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */,
"resolveJsonModule": true,
"sourceMap": true,
// "allowJs": true /* Allow javascript files to be compiled. Useful when migrating JS to TS */,
// "checkJs": true /* Report errors in .js files. Works in tandem with allowJs. */,
},
"include": ["src/**/*"]
}

Related

Webpack 5 & Jest - Property 'toBeInTheDocument' does not exist on type 'JestMatchers<HTMLElement>'

I can't get the typings for Jest to work with Webpack 5 and TypeScript, I've tried other solutions for the same problem. The problem is only with "screen" and "toBeInTheDocument" in my example test below. I'm leaning toward it being an ESLint configuration issue.
I can't run the tests, they fail with Property 'toBeInTheDocument' does not exist on type 'JestMatchers<HTMLElement>'.. I'm using Yarn 3.1.0. I've tried this answer and many others, including importing the types through tsconfig.json. What am I doing wrong?
Example test (src/components/Example/spec/test.spec.tsx):
import * as React from 'react';
import { render, screen } from '#testing-library/react';
import { Example } from './Example';
import "#testing-library/jest-dom/extend-expect";
import "#testing-library/jest-dom";
test("Renders correctly", () => {
render(<Example />);
const example = screen.getByAltText("Example");
expect(example).toBeInTheDocument();
});
jest.config.js:
module.exports = {
// An array of directory names to be searched recursively up from the requiring module's location
moduleDirectories: ['node_modules', '<rootDir>/src'],
// A map to module names that allow stubbing out resources with a single module
moduleNameMapper: {
'\\.(css|less)$': '<rootDir>/__mocks__/styleMock.js',
'\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$':
'<rootDir>/__mocks__/fileMock.js',
},
// Preset for our Jest configuration base
preset: 'ts-jest/presets/js-with-ts',
setupFilesAfterEnv: ['<rootDir>/setupTests.ts'],
// Environment used for testing
testEnvironment: 'jsdom',
};
webpack.config.js:
/* eslint-disable */
const { ModuleFederationPlugin } = require('webpack').container;
const path = require('path');
const packageJsonName = require('./package.json').name;
const packageJsonDeps = require('./package.json').dependencies;
const TsconfigPathsPlugin = require('tsconfig-paths-webpack-plugin');
module.exports = {
mode: 'development',
entry: path.resolve(__dirname, 'src', 'index.ts'),
devServer: {
client: {
overlay: true,
},
static: {
directory: './dist',
},
port: 3001,
historyApiFallback: true
},
module: {
rules: [
{
test: /\.(tsx|ts|jsx)?$/,
//exclude: /node_modules/,
use: [
{
loader: 'ts-loader',
options: {
experimentalWatchApi: true,
transpileOnly: true,
},
},
],
},
{
test: /\.js$/,
enforce: 'pre',
use: ['source-map-loader'],
},
],
},
output: {
path: path.resolve(__dirname, 'dist'),
publicPath: 'auto',
},
resolve: {
cacheWithContext: false,
extensions: ['.js', '.ts', '.tsx', '.jsx'],
plugins: [
new TsconfigPathsPlugin({
configFile: path.resolve(__dirname, './tsconfig.json'),
}),
],
symlinks: false,
},
};
package.json:
{
"scripts": {
"start": "webpack-cli serve",
"build": "webpack --mode production",
"dev": "webpack serve --progress",
"test": "jest",
"test:coverage": "jest --coverage --watchAll=false",
"test:watch": "jest --watch"
},
"dependencies": {
"react": "17.0.2",
"react-router-dom": "^5.2.0",
},
"devDependencies": {
"#testing-library/jest-dom": "^5.14.1",
"#testing-library/react": "12.1.2",
"#testing-library/user-event": "13.5.0",
"#types/jest": "27.0.2",
"#types/react": "^17.0.33",
"#types/react-router-dom": "5.3.2",
"#typescript-eslint/eslint-plugin": "5.2.0",
"#typescript-eslint/parser": "4.33.0",
"eslint": "7.32.0",
"eslint-config-prettier": "8.3.0",
"eslint-plugin-import": "2.25.2",
"eslint-plugin-jest": "25.2.2",
"eslint-plugin-react": "7.26.1",
"eslint-plugin-react-hooks": "4.2.0",
"jest": "^27.3.1",
"prettier": "2.4.1",
"ts-jest": "^27.0.7",
"ts-loader": "^9.2.6",
"tslib": "^2.3.1",
"typescript": "~4.3.5",
"webpack": "5",
"webpack-cli": "^4.9.1",
"webpack-dev-server": "^4.3.1"
}
}
And tsconfig.json:
{
"compilerOptions": {
"allowJs": true,
"allowSyntheticDefaultImports": true,
"baseUrl": ".",
"declaration": true,
"esModuleInterop": true,
"importHelpers": true,
"jsx": "react",
"lib": ["es6", "dom"],
"module": "esnext",
"moduleResolution": "node",
"noFallthroughCasesInSwitch": true,
"noImplicitAny": true,
"noImplicitReturns": true,
"noImplicitThis": true,
"noUnusedParameters": true,
"outDir": "dist",
"resolveJsonModule": true,
"rootDir": ".",
"skipLibCheck": true,
"sourceMap": true,
"strict": true,
"target": "es6"
},
"include": ["**/*.ts", "**/*.tsx", "**/*.jsx", "**/*.js"],
"exclude": [
"dist",
"node_modules"
]
}
And setupTests.ts is just: import '#testing-library/jest-dom/extend-expect';
Thanks for any pointers.
Install the types using:
npm i #types/testing-library__jest-dom -D
Please make sure that the correct types are installed in your project. i.e.
npm i -D #testing-library/jest-dom#^4.2.4
From my experience the Typescript types seem to be missing from version 5.x

Webpack 5 bundle.js doesn't include all the src content

After I removed "dist" folder and re-build the project using webpack it starts producing 0 bytes bundle.js
Here is webpack.config.js:
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
module.exports = {
mode: 'development',
entry: './src/index.tsx',
devtool: 'source-map',
output: {
filename: 'bundle.js',
path: path.resolve(__dirname, 'dist'),
},
resolve: {
extensions: ['.tsx', '.ts', '.js'],
},
module: {
rules: [
{ test: /\.svg$|/i, use: 'raw-loader' },
{ test: /\.tsx?$/i, use: [{ loader: 'ts-loader', options: { transpileOnly: true } }], exclude: /node_modules/, },
{ test: /\.css$/i, use: ['style-loader', 'css-loader'] },
{ test: /\.s[ac]ss$/i, use: ["style-loader", "css-loader", "sass-loader"] },
],
},
devServer: {
contentBase: path.join(__dirname, 'dist'),
hot: true,
port: 9000,
},
plugins: [new HtmlWebpackPlugin()],
};
Here is 'index.tsx':
import React from 'react';
import ReactDOM from 'react-dom';
import App from './App';
import "antd/dist/antd.css";
const root = document.createElement('div');
root.setAttribute('id', 'root');
document.body.appendChild(root);
const MyApp = () => (
<React.Fragment>
<App />
</React.Fragment>
);
ReactDOM.render(<MyApp />, document.getElementById('root'));
Here is package.json scripts:
"scripts": {
"start": "node node_modules/webpack-dev-server/bin/webpack-dev-server.js --progress",
"build": "node node_modules/webpack/bin/webpack.js -p --progress --color"
},
Here are dependencies:
"devDependencies": {
"#types/react-virtualized": "^9.21.11",
"#types/react-window": "^1.8.3",
"#webpack-cli/serve": "^1.5.1",
"file-loader": "^6.2.0",
"html-webpack-plugin": "^5.3.2",
"less": "^4.1.1",
"less-loader": "^10.0.1",
"mobx-react-devtools": "^6.1.1",
"raw-loader": "^4.0.2",
"sass": "^1.35.1",
"sass-loader": "^12.1.0",
"ts-loader": "^9.2.3",
"webpack": "^5.43.0",
"webpack-cli": "^3.3.12",
"webpack-dev-server": "^3.11.2"
}
As a result when I run 'npm run build' I'm getting:
PS D:\coding\video-demo> npm run build
> video-demo#0.1.0 build D:\coding\video-demo
> node node_modules/webpack/bin/webpack.js -p --progress --color
asset index.html 243 bytes [emitted]
asset bundle.js 0 bytes [emitted] [minimized] (name: main)
./src/index.tsx 504 bytes [built] [code generated]
webpack 5.44.0 compiled successfully in 669 ms
bundle.js is 0 bytes.
What might happen that now cause issues with building bundle.js?
EDIT: after changing webpack-cli version to 4.7.2 (latest) and modifying build script to just "webpack" I was able to get bundle.js with some code inside. However, there is the only index.tsx content inside bundle.js. It seems that wepback can't build the graph of imports. Does anyone aware of why it might happen? Maybe something wrong in tsconfig.json.
tsconfig.json
{
"compilerOptions": {
"experimentalDecorators": true,
"module": "esnext",
"target": "es5",
"jsx": "react-jsx",
"sourceMap": true,
"allowJs": false,
"skipLibCheck": true,
"esModuleInterop": true,
"strict": false,
"moduleResolution": "node",
"resolveJsonModule": true
},
"include": [
"src"
],
}
Finally, after hours of applying different configurations, I was able to make it work with webpack 5. Not sure what exactly was the issue, seems it was some kind of combination of different things, from different configs.
I replaced ts-loader with babel and changed tsconfig.json to:
{
"compilerOptions": {
"experimentalDecorators": true,
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"allowSyntheticDefaultImports": true,
"skipLibCheck": true,
"esModuleInterop": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react"
},
"include": ["src"]
}

module not found - webpack ts-loader #material-ui

I get an error when importing #material-ui to my React component.
Module not found: Error: Can't resolve './utils.
I can import other libraries like lodash but with #material-ui there's issue. I tried reinstall node_modules but error still occur.
import React, { useEffect } from "react";
import _ from "lodash";
import Button from "#material-ui/core";
export default function Dashboard() {
useEffect(() => {
console.log("Test");
const testVar = "test";
console.log(_.split(testVar));
return () => {
// cleanup;
};
}, []);
return (
<div>
<Button>Login</Button>
</div>
);
package.json
{
"name": "views",
"version": "1.0.0",
"description": "",
"main": "index.js",
"dependencies": {
"#material-ui/core": "^4.10.2",
"#material-ui/icons": "^4.9.1",
"lodash": "^4.17.15",
"react": "^16.13.1",
"react-dom": "^16.13.1"
},
"devDependencies": {
"#types/lodash": "^4.14.157",
"#types/react": "^16.9.38",
"#types/react-dom": "^16.9.8",
"source-map-loader": "^1.0.0",
"ts-loader": "^7.0.5",
"typescript": "^3.9.5",
"webpack": "^4.43.0",
"webpack-cli": "^3.3.12"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"dev": "webpack --mode=development --watch --progress",
"dev:nowatch": "webpack --mode=development"
},
"keywords": [],
"author": "",
"license": "ISC"
}
webpack.config.js
var path = require("path");
module.exports = {
mode: "development",
// Enable sourcemaps for debugging webpack's output.
devtool: "source-map",
entry: {
dashboard: "./Dashboard/index",
// creator: "./Creator/index",
},
output: {
path: path.resolve(__dirname, ""),
filename: "./[name]/dist/index.js",
},
resolve: {
// Add '.ts' and '.tsx' as resolvable extensions.
extensions: [".ts", ".tsx"],
modules: [path.resolve(__dirname, "./"), "node_modules"],
},
module: {
rules: [
{
test: /\.ts(x?)$/,
exclude: /node_modules/,
use: [
{
loader: "ts-loader",
},
],
},
// All output '.js' files will have any sourcemaps re-processed by 'source-map-loader'.
{
enforce: "pre",
test: /\.js$/,
loader: "source-map-loader",
},
],
},
// When importing a module whose path matches one of the following, just
// assume a corresponding global variable exists and use that instead.
// This is important because it allows us to avoid bundling all of our
// dependencies, which allows browsers to cache those libraries between builds.
externals: {
react: "React",
"react-dom": "ReactDOM",
},
};
tsconfig.json
{
"compilerOptions": {
"lib": ["es6", "dom"],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"outDir": "./dist/",
"sourceMap": true,
"target": "es5",
"jsx": "react",
"allowJs": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true
}
}
Example errors
ERROR in ./node_modules/#material-ui/core/esm/index.js
Module not found: Error: Can't resolve './withMobileDialog' in 'C:\Users\user\Documents\Code\calendarapp\UI\Client\views\node_modules\#material-ui\core\esm'
# ./node_modules/#material-ui/core/esm/index.js 240:0-65 240:0-65 241:0-35 241:0-35
# ./Dashboard/Dashboard.tsx
# ./Dashboard/App.tsx
# ./Dashboard/index.tsx
ERROR in ./node_modules/#material-ui/core/esm/index.js
Module not found: Error: Can't resolve './withWidth' in 'C:\Users\user\Documents\Code\calendarapp\UI\Client\views\node_modules\#material-ui\core\esm'
# ./node_modules/#material-ui/core/esm/index.js 242:0-51 242:0-51 243:0-28 243:0-28
# ./Dashboard/Dashboard.tsx
# ./Dashboard/App.tsx
# ./Dashboard/index.tsx
Found solution.
In webpack.config.js add ".js", ".jsx" to resolve.
resolve: {
// Add '.ts' and '.tsx' as resolvable extensions.
extensions: [".ts", ".tsx", ".js", ".jsx"],
},
If I can add something and if I remember correctly, the import Button from "#material-ui/core"; should have curly brackets around "Button" like so import {Button} from "#material-ui/core";
First create your react app
Then
Install material ui core and icons modules
Then
Go package.json and check dependencies if found material ui core and icons then first copy icons line
Then paste on file which u use like as index.js
Then
U only add /icon name
For example:-
Import add from #material-ui/icons
You add only
#material-ui/icons/add
💯% solved with proof

TypeScript with React typings will not compile

I tried following the setup on the TypeScript page, but I get a couple of errors. Here my files:
tsconfig:
{
"compilerOptions": {
"outDir": "../scripts/",
"noImplicitAny": false,
"noEmitOnError": true,
"removeComments": true,
"sourceMap": true,
"target": "es5",
"jsx": "react",
"lib": [
"es6",
"es5",
"dom"
]
},
"exclude": [
"node_modules",
"wwwroot",
"scripts"
]
}
package.json:
{
"version": "1.0.0",
"name": "asp.net",
"private": true,
"devDependencies": {
"#types/react": "latest",
"#types/react-dom": "latest",
"typescript": "2.4.2",
"awesome-typescript-loader": "3.2.3",
"source-map-loader": "0.2.1",
"gulp": "3.9.1",
"del": "2.2.2",
"gulp-concat": "2.6.1",
"gulp-sourcemaps": "2.6.0",
"gulp-uglify": "2.1.2",
"#types/jquery": "2.0.41",
"pump": "1.0.2",
"#types/bootstrap": "3.3.33",
"gulp-typescript": "3.1.7",
"#types/knockout": "3.4.41",
"ts-loader": "2.3.2",
"webpack": "3.5.4",
"webpack-stream": "4.0.0"
},
"dependencies": {
"react": "latest",
"react-dom": "latest"
}
}
webpack.config.js:
module.exports = {
entry: "./typescripts/index.tsx",
output: {
filename: "bundle.js",
path: __dirname + "/scripts"
},
devtool: "source-map",
resolve: {
extensions: [".ts", ".tsx", ".js", ".json"]
},
module: {
rules: [
{ test: /\.tsx?$/, loader: "awesome-typescript-loader" },
{ enforce: "pre", test: /\.js$/, loader: "source-map-loader" }
]
},
externals: {
"react": "React",
"react-dom": "ReactDOM"
}
My tsx files are copy/pasted from the page linked above.
The first error I am getting is with awesome-typescript-loader.
ERROR in ./typescripts/index.tsx
Module parse failed: c:\Documents\Visual Studio 2017\Projects\DevSln\WebApplication4\node_modules\awesome-typescript-loader\dist\entry.js!C:\Documents\Visual Studio 2017\Projects\DevSln\WebApplication4\typescripts\index.tsx Unexpected token (6:16)
You may need an appropriate loader to handle this file type.
| var ReactDOM = require("react-dom");
| var Hello = require("./hello");
| ReactDOM.render(<Hello.Hello compiler="typescript" framework="React"/>, document.getElementById("example"));
|
this error goes away if I switch the loader to ts-loader, but I would still like to know if I'm doing something wrong.
The second error is with the #types\react type definition. It is throwing me all types of errors. But the first one in the list is:
Severity Code Description Project File Line Suppression State
Error Build:Module '"C:/Documents/Visual Studio 2017/Projects/DevSln/WebApplication4/node_modules/#types/react/index"' has no exported member 'DOMAttributes'. WebApplication4 C:\Documents\Visual Studio 2017\Projects\DevSln\WebApplication4\node_modules\#types\react-dom\index.d.ts 15
This is preventing me from building my solution. I am using VS2017. Any help is appreciated.
Don't know if its the correct answer, but it works and I didn't lose the typings. In order to fix it, I removed the "#types/react": "latest"
and "#types/react-dom": "latest" from the packages.json

Plugin 0 specified in 'foreign' provided an invalid property of '_c'

Getting above error with below configuration, how should I make it working?
.babelrc:
{
"passPerPreset": true,
"presets": [
{"plugins": ["./build/babelRelayPlugin"]},
"react",
"es2015",
"stage-0"
]
}
package.json:
{
"name": "1",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"babel-core": "^6.14.0",
"babel-loader": "^6.2.5",
"babel-polyfill": "^6.13.0",
"babel-preset-es2015": "^6.14.0",
"babel-preset-react": "^6.11.1",
"babel-preset-stage-0": "^6.5.0",
"babel-relay-plugin": "^0.9.2",
"express": "^4.14.0",
"express-graphql": "^0.5.3",
"graphql": "^0.6.2",
"graphql-relay": "^0.4.2",
"react": "^15.3.1",
"react-dom": "^15.3.1",
"react-relay": "^0.9.2",
"webpack": "^1.13.2",
"webpack-dev-server": "^1.15.0"
},
"devDependencies": {
"babel-cli": "^6.14.0"
}
}
server.js:
//
//
//
const compiler = webpack({
entry: path.resolve(__dirname, 'js', 'app.js'),
module: {
loaders: [
{
test: /\.js$/,
include: [ path.resolve(__dirname, "js") ],
exclude: /node_modules/,
loader: 'babel-loader',
query: {
presets: ['react', 'es2015', 'stage-0'],
},
}
],
},
output: {filename: '/app.js', path: '/', publicPath: '/js/'}
});
const appServer = new WebpackDevServer(compiler, {
contentBase: '/public/',
proxy: {'/graphql': 'http://localhost:8000'},
publicPath: '/js/',
stats: {colors: true}
});
//
//
//
Terminal Error: babel-node server.js
ERROR in ./js/app.js
Module build failed: Error: Plugin 0 specified in 'foreign' provided an invalid property of '_c'
Browser Error: localhost: 3000
in the console window:
Uncaught Invariant Violation: RelayQL: Unexpected invocation at runtime. Either the Babel transform was not set up, or it failed to identify this call site. Make sure it is being used verbatim as Relay.QL.
I have had success using the following setup. I am using the plugin with the babel loader in my webpack module rather than in .babelrc
In webpack:
query: {
presets: [
"es2015", "react", "stage-0", {
"plugins": [
"./schema-build/babelRelayPlugin"
]
}
]
}
In .babelrc:
{
"passPerPreset": true,
"presets": [
"react",
"es2015",
"stage-0"
]
}

Resources