reactioncommerce / reaction-cli

A command line tool for working with Reaction Commerce.
33 stars 20 forks source link

When creating a new plugin, #57

Open prinzdezibel opened 6 years ago

prinzdezibel commented 6 years ago

the generated package.json does not define our common @reactioncommerce aliases.

This makes it impossible to write:

import { registerComponent, getHOCs, getRawComponent } from "@reactioncommerce/reaction-components";

Reproduce:

1) Create new plugin via reaction plugins create --name my-plugin 2) Put this snippet into imports/plugins/custom/my-plugin/client/index.js

import { registerComponent, getHOCs, getRawComponent } from "@reactioncommerce/reaction-components";

3) It will throw an error in the browser's console: modules-runtime.js:261 Uncaught Error: Cannot find module '@reactioncommerce/reaction-components'

jshimko commented 6 years ago

Yep. An unfortunate side effect of nested package.json files. They overwrite those aliases. The only solution I currently know of is checking every plugin's package.json and altering it if the root level package.json has an alias that the plugin's file doesn't. That could get a little messy because people would need to know why that's happening and make sure to commit that change to their repos. Certainly not impossible to automate, but it'd take some planning/testing to get something reliable working. And we're making efforts toward migrating to an entirely npm package plugin system, so that would also make this problem go away.

rohit-elevar commented 6 years ago

I'm having this issue currently, but I'm new to reaction. @jshimko Can you please guide me on how to go about creating aliases in the plugin's package.json like the one in root