E
E
Edward2016-04-05 17:11:42
Node.js
Edward, 2016-04-05 17:11:42

Webpack loader swears. How to use jsx source files inside node_modules?

structure:

./node_modules/packageName/file.jsx
./main.js

main.js
import * as CUSTOM from './node_modules/packageName/file.jsx'

file.jsx
export function custom() {

}

webpack error
ERROR in ./~/packageName/src/js/custom.jsx
Module parse failed:PATH_TO_PROJECT/node_modules/packageName/file.jsx Line 1: Unexpected token
You may need an appropriate loader to handle this file type.
| export function CUSTOM() {
| }
| 
 @ ./src/js/main.js

At the same time, importing the same file, if it lies next to main.js, works successfully

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander, 2016-04-05
@edtoken

Delete the line in werbpack.config where it says exclude: /node_modules/

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question