jurassix / joi-validation-strategy

Joi validator for react-validation-mixin
MIT License
9 stars 14 forks source link

npm package cannot be used with Babel 6 #7

Closed natorojr closed 8 years ago

natorojr commented 8 years ago

I recently upgraded to Babel 6 and noticed the following issues w/ your npm package:

ERROR in ~/node_modules/joi-validation-strategy/lib/joiValidationStrategy.js
Module build failed: ReferenceError: [BABEL] ~/node_modules/joi-validation-strategy/lib/joiValidationStrategy.js: Unknown option: ~/node_modules/joi-validation-strategy/.babelrc.stage

This is due to the fact that the configuration syntax/options have changed between Babel 5 and Babel 6.

However, the issue may be looked at more generally than that. It's generally considered bad practice to publish .babelrc (or any other dot config files) as part of your npm packages. Instead, you should be using the files attribute in your package.json (https://docs.npmjs.com/files/package.json#files).

natorojr commented 8 years ago

Unfortunately, it doesn't look like the existing npm package got fixed. You may have to bump the version (to 0.3.3) and publish to npm.

jurassix commented 8 years ago

Yeah I have only merged this change in. Let me release it out. I'm going to modify the files array to match my .npmigore

jurassix commented 8 years ago

Released as v0.3.3

I removed the src/ folder from the files array since it was ignored by the .npmigore already.

I'll keep this PR open till you confirm this release is correct.

natorojr commented 8 years ago

Yes! That did it for me. No more hacks in my Webpack build process :)

Here's what the new npm package installation looks like:

$ find node_modules/joi-validation-strategy
node_modules/joi-validation-strategy
node_modules/joi-validation-strategy/lib
node_modules/joi-validation-strategy/lib/joiValidationStrategy.js
node_modules/joi-validation-strategy/lib/utils
node_modules/joi-validation-strategy/lib/utils/collectErrors.js
node_modules/joi-validation-strategy/lib/utils/decodeMessages.js
node_modules/joi-validation-strategy/lib/utils/hydrate.js
node_modules/joi-validation-strategy/lib/utils/index.js
node_modules/joi-validation-strategy/lib/utils/pickMessages.js
node_modules/joi-validation-strategy/LICENSE
node_modules/joi-validation-strategy/package.json
node_modules/joi-validation-strategy/README.md

... which is exactly what I expect -- compiled library distribution.

NOTE: Looks like react-validation-mixin still has .bablerc and other source files included in the npm package. If/when you have time, you may want to use the same approach there. Although, for some reason (which I haven't investigated), that package doesn't cause my build to break.

$ find node_modules/react-validation-mixin
node_modules/react-validation-mixin
node_modules/react-validation-mixin/.babelrc
node_modules/react-validation-mixin/.eslintignore
node_modules/react-validation-mixin/.eslintrc
node_modules/react-validation-mixin/.npmignore
node_modules/react-validation-mixin/karma.conf.js
node_modules/react-validation-mixin/lib
node_modules/react-validation-mixin/lib/components
node_modules/react-validation-mixin/lib/components/validationMixin.js
node_modules/react-validation-mixin/lib/index.js
node_modules/react-validation-mixin/lib/spec
node_modules/react-validation-mixin/lib/spec/components
node_modules/react-validation-mixin/lib/spec/components/MixinSpec.js
node_modules/react-validation-mixin/lib/spec/components/Signup.js
node_modules/react-validation-mixin/lib/spec/utils
node_modules/react-validation-mixin/lib/spec/utils/isSomeSpec.js
node_modules/react-validation-mixin/lib/spec/ValidationFactorySpec.js
node_modules/react-validation-mixin/lib/utils
node_modules/react-validation-mixin/lib/utils/defined.js
node_modules/react-validation-mixin/lib/utils/flattenErrorsObject.js
node_modules/react-validation-mixin/lib/utils/index.js
node_modules/react-validation-mixin/lib/utils/isSome.js
node_modules/react-validation-mixin/lib/validationFactory.js
node_modules/react-validation-mixin/LICENSE
node_modules/react-validation-mixin/package.json
node_modules/react-validation-mixin/README.md
node_modules/react-validation-mixin/spec
node_modules/react-validation-mixin/spec/components
node_modules/react-validation-mixin/spec/components/MixinSpec.js
node_modules/react-validation-mixin/spec/components/Signup.js
node_modules/react-validation-mixin/spec/utils
node_modules/react-validation-mixin/spec/utils/isSomeSpec.js
node_modules/react-validation-mixin/spec/ValidationFactorySpec.js

Thanks @jurassix and Happy Holidays!

jurassix commented 8 years ago

@natorojr Glad it's fixed for you. I've made the same change to react-validation-mixin v5.3.3.

Happy Holidays to you! Thanks for all the help this year.