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

work without npm, grunt and all that stuff #8

Closed
pjebs opened this issue Mar 27, 2015 · 10 comments
Closed

work without npm, grunt and all that stuff #8

pjebs opened this issue Mar 27, 2015 · 10 comments

Comments

@pjebs
Copy link

pjebs commented Mar 27, 2015

HI There,

How Can I make this work without any of those fancy node.js dependencies.
I'm new to react. Im just including the standard react.js file in my html file. I'm although using the JSX transformer (which I will get rid of later).
I just want to drop the js files (DayPicker.js and utils.js) and possibly moment.js (I noticed you wrote in a issue that it's not strictly required).

I took out the export and import statements from the Daypicker and utils file but it still isn't working.

@pjebs
Copy link
Author

pjebs commented Mar 27, 2015

I'm assuming I have to convert the provided scss file to css too and include that in.

@gpbl
Copy link
Owner

gpbl commented Mar 27, 2015

Hi @pjebs thank you for the feedback – tbh I don't plan to make a stand-alone version. You are going to use a module loader anyway soon :-)

@pjebs
Copy link
Author

pjebs commented Mar 27, 2015

Can you give some clues on how I can do it?

@pjebs
Copy link
Author

pjebs commented Mar 27, 2015

When I look at your code, it looks like only a few lines of code need to be changed.

@pjebs
Copy link
Author

pjebs commented Mar 28, 2015

please help me.

@gpbl
Copy link
Owner

gpbl commented Mar 28, 2015

@pjebs we need to make a webpack config to expose ReactDayPicker as global var and to minify the two scripts into one. If you are planning to use other react components, it's likely you will do the same thing by yourself with webpack or browserify. Anyway, I don't have much time to look into this right now: but I suggest you to try browserify or webpack :-)

@pjebs
Copy link
Author

pjebs commented Mar 29, 2015

In that case, how can I use the compiled version you have in the dist folder: DayPicker.js and utils.js

I included those files in my html file.

Chrome keeps saying:

Uncaught ReferenceError: exports is not defined utils.js:5 (anonymous function)
Uncaught ReferenceError: require is not defined DayPicker.js:5 

What other files would I need to include?

@gpbl
Copy link
Owner

gpbl commented Mar 29, 2015

Hi @pjebs, you could use browserify or webpack to minify the lib into a single file and expose it as global var.

@pjebs
Copy link
Author

pjebs commented Mar 29, 2015

I attempted to use browserify. I don't think your code works with React 0.13 anymore.

I cd into src directory. then ran sudo browserify DayPicker.js -o pj.js

And it spits out this error:

Error: Parsing file /Users/PJ20/Desktop/react-day-picker-master/src/DayPicker.js: Unexpected token (101:6)
    at Deps.parseDeps (/usr/local/lib/node_modules/browserify/node_modules/module-deps/index.js:418:28)
    at fromSource (/usr/local/lib/node_modules/browserify/node_modules/module-deps/index.js:361:48)
    at /usr/local/lib/node_modules/browserify/node_modules/module-deps/index.js:356:17
    at ConcatStream.<anonymous> (/usr/local/lib/node_modules/browserify/node_modules/concat-stream/index.js:32:43)
    at ConcatStream.emit (events.js:129:20)
    at finishMaybe (/usr/local/lib/node_modules/browserify/node_modules/readable-stream/lib/_stream_writable.js:460:14)
    at endWritable (/usr/local/lib/node_modules/browserify/node_modules/readable-stream/lib/_stream_writable.js:469:3)
    at ConcatStream.Writable.end (/usr/local/lib/node_modules/browserify/node_modules/readable-stream/lib/_stream_writable.js:436:5)
    at DuplexWrapper.onend (/usr/local/lib/node_modules/browserify/node_modules/readable-stream/lib/_stream_readable.js:537:10)
    at DuplexWrapper.g (events.js:199:16)

@gpbl
Copy link
Owner

gpbl commented Mar 30, 2015

@pjebs the src is written in babeljs, so if you want to compile from the source you need to use babelify. You go better with the dist version:

browserify ./dist/DayPicker.js -o pj.js

actually you shouldn't need to run it with sudo.

Beware this won't be enough for your goal, because you need to make the module accessibile from the global scope (honestly i have no idea on how to make this with browserify).

But again I suggest you to adopt the module from npm, and use browserify or webpack for writing your app – instead of messing up with this single module. You need to read some docs before, but it's worth the time spent.

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