wojtekmaj / react-time-picker

A time picker for your React app.
https://projects.wojtekmaj.pl/react-time-picker
MIT License
337 stars 63 forks source link

build fail #35

Closed kiran-bhalerao closed 5 years ago

kiran-bhalerao commented 5 years ago
/node_modules/react-clock/dist/Clock.css:1
(function (exports, require, module, __filename, __dirname) { .react-clock {
                                                              ^
SyntaxError: Unexpected token .
williejay2017 commented 5 years ago

react version?

kiran-bhalerao commented 5 years ago

react 16.8.4

wojtekmaj commented 5 years ago

If you're using Webpack, you need to teach it how to support CSS files. in module.resolve, either add the following:

    {
      test: /\.css$/,  
      include: /node_modules/,  
      loaders: ['style-loader', 'css-loader'],
    }

or, if you already have a config for styling, modify test RegExp so that it would cover *.css files, too.

focux commented 5 years ago

I'm having this same issue with NextJS.

EDIT. I was able to fix it importing the no-style version and then importing styles manually right into app:

import 'react-clock/dist/Clock.css';
import 'react-time-picker/dist/TimePicker.css';
import TP, { TimePickerProps } from 'react-time-picker/dist/entry.nostyle';
dorklord23 commented 4 years ago

@focux could you provide a working example for this solution please? Thanks

vfonic commented 3 years ago

I'm having a similar issue except that I'm using Vitejs as bundler.

If I try to skip importing css, here's the error I get:

`import { TimePicker } from "react-time-picker/dist/entry.nostyle";` ``` Input.js:20 Uncaught TypeError: Cannot set property default of # which has only a getter at _interopRequireWildcard (Input.js:20) at node_modules/react-time-picker/dist/TimeInput/Input.js (Input.js:16) at __require2 (chunk-G3IZEHTJ.js?v=095d3dcc:17) at node_modules/react-time-picker/dist/TimeInput/Hour12Input.js (Hour12Input.js:14) at __require2 (chunk-G3IZEHTJ.js?v=095d3dcc:17) at node_modules/react-time-picker/dist/TimeInput.js (TimeInput.js:16) at __require2 (chunk-G3IZEHTJ.js?v=095d3dcc:17) at node_modules/react-time-picker/dist/TimePicker.js (TimePicker.js:20) at __require2 (chunk-G3IZEHTJ.js?v=095d3dcc:17) at node_modules/react-time-picker/dist/entry.nostyle.js (entry.nostyle.js:8) ```
`import TimePicker from "react-time-picker";` ``` Uncaught Error: Dynamic require of "/Users/viktor/Developer/atlas/node_modules/react-clock/dist/Clock.css" is not supported at __require (chunk-G3IZEHTJ.js?v=095d3dcc:11) at node_modules/react-time-picker/dist/entry.js (entry.js:8) at __require2 (chunk-G3IZEHTJ.js?v=095d3dcc:17) at dep:react-time-picker:1 ```