vue-form-generator icon indicating copy to clipboard operation
vue-form-generator copied to clipboard

Fix fieldComponents exposure

Open muschottkey opened this issue 5 years ago • 2 comments

Exposing fieldComponents was broken because we were exporting named exports in the fieldsLoader.js while we were importing as though it was exported as a default export.

  • Please check if the PR fulfills these requirements
  • [ ] The commit message follows our guidelines
  • [ ] Tests for the changes have been added (for bug fixes / features)
  • [ ] Docs have been added / updated (for bug fixes / features)
  • What kind of change does this PR introduce? (Bug fix, feature, docs update, ...) Bug fix
  • What is the current behavior? (You can also link to an open issue here)

In export (utils/fieldsLoader.js):

module.exports = fieldComponents;

In import time inside (index.js)

const fieldComponents = require("./utils/fieldsLoader").default;

This meant that this code would not be doing the right thing.

import { fieldComponents } from 'vue-form-generator'

Because

// fieldComponents === undefined; because we imported it as if it was a default export

I'm sure this is not intended.

fieldComponents would always be undefined, which isn't very nice because for some usecases, you might actually want to have access to the components.

  • What is the new behavior (if this is a feature change)?

Changes the importing to

const fieldComponents = require("./utils/fieldsLoader");
  • Does this PR introduce a breaking change? (What changes might users need to make in their application due to this PR?)

No breaking changes introduced.

  • Other information:

Nothing else to add.

muschottkey avatar Jun 20 '19 10:06 muschottkey

Coverage Status

Coverage remained the same at 89.979% when pulling c7448b3c79b1814ea73b94ca1638a86cba3573e4 on muschottkey:master into 721a4eebbde77040a1318e60aa9ef21229bbcf99 on vue-generators:master.

coveralls avatar Jun 20 '19 10:06 coveralls

I am also experiencing this as an issue - namely, i am building another component that wraps around FieldCleave, but I have no way of importing FieldCleave directly except perhaps by adding all the necessary dependencies that VueFormGenerator uses internally. Ideally, I'd like to be able to grab the built definition off of fieldComponents but as mentioned above, fieldComponents is undefined because it is imported / exported incorrectly.

hunterae avatar Aug 18 '20 18:08 hunterae