-
Notifications
You must be signed in to change notification settings - Fork 309
Conversation
…ght result in lib
The Problem We do rely on the export default Radium; to: exports.default = Radium;
module.exports = exports['default']; // plugin adds this for our legacy compatibility. However, if we have any other named export, like: // ESM re-exports
export {Plugins, Style, StyleRoot, getState, keyframes}; That I added, the As far as I can tell, only |
…s/radium into task/es-build-ryan
You can require `Radium` on the server / using CommonJS with: | ||
|
||
```jsx | ||
var Radium = require('radium'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we not need .default
on this import?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct. That is the change with the new root index.js
file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it. 👍
@alexlande @exogen -- I've got this branch and a separate experiment repo for all of the consumption scenarios I could think of. Can you take a look at that (and this PR) and let me know if we're missing anything or anything needs changing for this approach / PR? https://github.com/FormidableLabs/radium-experiments-v0.22 Thanks!!! |
Went through the experiments, everything looks good as far as I can tell. Thanks for all of the work here, module system interop is so complicated 👍 |
Released in |
- **Breaking Change**: Radium now exports defaults as `.default`, so for runtimes like Node.js for all files in `lib/**`. We have changed `package.json:main` to point to `/index.js` instead of `/lib/index.js` as a convenience wrapper to expose mostly what was there before so behavior of `const Radium = require('radium');` works mostly as it did before. Caveats: - Add `es` ESM module export files. - Fix `package.json:scrtips.postinstall` task to correctly work for git-based dependencies.
This builds on @kale-stew 's #967 and goes further down the rabbit hole.
Working Items
babel-preset-add-module-exports
does not seem to work in producingmodule.exports = exports["default"]
in e.g.lib/index.js
Confusingly, the plugin is needed for our frontend Karma test stuff and seems to work there! 😕 And we have mocked stuff like
that plays poorly with removing
babel-preset-add-module-exports
(I tried replacing allrequire("foo")
withrequire("foo").default
)Tasks
@kale-stew --
require('radium')
withrequire('radium').default
.README.md
,docs/**
,examples/**
...require()
s and convert client code / babel'ed code examples toimport Radium from 'radium';
or other analogous thing.@ryan-roemer --
dist
works as expected withglobal.Radium
variable in prod + dev modes.yarn run test-frontend
to pass.Try to remove all legacy things likeRadium.PROPERTY_NAME =
Done
babel-preset-add-module-exports
module.exports
thingnode4
works in Travis and Appveyor.Changes
es
build to Radium. #966babel-preset-env
require()
sbuilder concurrent
to parallelize a lot of our build / test stuff{__clearStateForTests, __setTestMode}
as named ESM exports because they're not. Switch to just usingresolveStyles
object directly.package-lock.json
(we'll stick with yarn)/cc @alexlande @kale-stew