-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for npm package #184
Conversation
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.
If I don't have development.local.json
, it won't compile and complain: http://cld.wthms.co/K5ttNz. I thought having it is optional. Or not?
What's the command |
Nice catch, it should be optional but webpack will fail at build time because it resolves the requires bypassing the try/catch. I added a
Most likely the error appears because the happychat-client is not linked. The Calypso PR adds the |
package.json
Outdated
"start": "run-p dev:standalone", | ||
"dev:standalone": "run-p dev:standalone:*", | ||
"dev:standalone:js": "NODE_ENV=development webpack-dev-server --config webpack.standalone.config.js", | ||
"dev:standalone:css": "node-sass src/form.scss | postcss --config postcss.config.json -u autoprefixer -u postcss-custom-properties -o targets/standalone/happychat.css", | ||
"dev:npm": "run-p dev:npm:*", | ||
"dev:npm:js": "NODE_ENV=development ./node_modules/babel-cli/bin/babel.js --watch src --out-dir targets/npm", |
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.
isn't babel in node_modules/.bin/
? If so, you can actually do NODE_ENV=development babel --watch src --out-dir targets/npm
because the scripts will search in node_module/.bin
path for "binaries".
merge( configFile, localConfig ); | ||
} catch ( e ) {} | ||
// check if we have local git ignored config and use it to override the development.json | ||
const localConfig = require( 'src/config/development.local.json' ); |
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.
Instead of creating a fake development.local.json
file, wouldn't it be better to check whether it exists here?
webpack.npm.config.js
Outdated
case 'production': | ||
config.plugins.push( new webpack.optimize.ModuleConcatenationPlugin() ); | ||
config.plugins.push( new UglifyJsPlugin() ); | ||
config.plugins.push( new LodashModuleReplacementPlugin( { |
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.
We no longer use the lodash-webpack-plugin
.
Tried and it works! 🎉 As far as I know, |
That is correct but the Calypso branch was just an experiment, and for that
Currently working on this :) |
Thanks for taking the time 🏅 |
Built on top of #183
Summary
This PR prepares
happychat-client
to be exposed as a npm package. Paths are resolved usingbabel-plugin-module-resolver
and configuration json files are inlined usingbabel-plugin-inline-json
.Testing
try/happychat-client
branch (Use happychat-client npm package wp-calypso#23630)npm link
in this foldernpm link happychat-client
in calypso foldernpm install
in this branchnpm run dev:standalone
in this repoAuthorization
header afterBearer
npm dev:npm