React-color: Converting to AMD (requirejs)

Created on 20 Jun 2017  路  4Comments  路  Source: casesandberg/react-color

Does anyone have any advice on how i can load this library using RequireJS? I've tried creating a wrapper (http://requirejs.org/docs/commonjs.html#autoconversion) and converting the module, but am still getting "Error: undefinedModule" in index.js any where "require('./components/xxx/xxxx') is used.

I installed via npm install react-color. I am referencing the /lib directory.

Thanks,
J

need more info question

Most helpful comment

[email protected] introduces a minified UMD bundle, you will be able to use that in an AMD project!

You can find it at dist/react-color.min.js when installing.

All 4 comments

What command did you use to convert the module? From what I understand r.js should convert all of the files to have define() wrappers.

Thanks. I think i've gotten this to work now. Initially i used:
node r.js -convert path/to/commonjs/modules/ path/to/output

but after a bit of fooling around with getting things to work, I ended up using a babel command:
babel --plugins transform-es2015-modules-amd src --out-dir lib

Not sure if that was the correct approach..I may visit the r.js command again.

I am trying consume react-color in a <script> tag, because my app is dynamically generated. I've been struggling for two days to find a solution where react-color just assumes it's external dependencies from a global context (react, tinycolor, etc) and runs.

Is there any known command which I can follow? or at least a lead?

[email protected] introduces a minified UMD bundle, you will be able to use that in an AMD project!

You can find it at dist/react-color.min.js when installing.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

dsumer picture dsumer  路  4Comments

amkoehler picture amkoehler  路  3Comments

imsheng picture imsheng  路  6Comments

YashalShakti picture YashalShakti  路  3Comments

nevendyulgerov picture nevendyulgerov  路  3Comments