Skip to content
This repository has been archived by the owner on Apr 25, 2019. It is now read-only.

When creating a new plugin, #57

Open
prinzdezibel opened this issue Feb 12, 2018 · 2 comments
Open

When creating a new plugin, #57

prinzdezibel opened this issue Feb 12, 2018 · 2 comments

Comments

@prinzdezibel
Copy link
Contributor

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";
  1. It will throw an error in the browser's console:
    modules-runtime.js:261 Uncaught Error: Cannot find module '@reactioncommerce/reaction-components'
@jshimko
Copy link
Contributor

jshimko commented Feb 12, 2018

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
Copy link

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants