Skip to content
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

library is incorrectly packaged for npm #136

Closed
davydnorris opened this issue Nov 17, 2019 · 9 comments · Fixed by #137
Closed

library is incorrectly packaged for npm #136

davydnorris opened this issue Nov 17, 2019 · 9 comments · Fixed by #137

Comments

@davydnorris
Copy link

By default, nodejs currently does not support ES6 syntax such as export, and packages that are published via npm need to transpile themselves using Babel as part of the packaging process, otherwise the library is unusable out of the box.

The current release of the library will work fine in most browsers, but fails as an npm package, making it really difficult to use for any sort of enterprise application where connections are managed by a server.

This is quite a nice guide on packaging a library for npm: https://medium.com/@TeeFouad/a-simple-guide-to-publishing-an-npm-package-506dd7f3c47a

@davydnorris
Copy link
Author

Just FYI, I repackaged the library in my local mode_modules, and ended up changing two lines in package.json as so:


  .
  .
  "main": "dist/index.js",         <= use dist here as package root
  "name": "@wiotp/sdk",
  "nyc": {
  .
  .
  .
  .
  "repository": {
    "type": "git",
    "url": "git+https://github.com/ibm-watson-iot/iot-nodejs.git"
  },
  "scripts": {
    "build": "npm run clean && npm run build:commonjs",
    "build:commonjs": "babel . --out-dir dist --presets=@babel/env",   <= include top level and preset
  .
  .
  .

@durera
Copy link
Contributor

durera commented Nov 24, 2019

Thanks, I’ll take a look at this on Monday and try to get the next release working as expected with a new release on npm 👍

@tanganellilore
Copy link
Contributor

Hi @durera ,

news on this topic?

@durera
Copy link
Contributor

durera commented Dec 23, 2019

Sorry, various other things took me away from SDK work. I'm using today to try to catch up on some of the outstanding issues across the SDKs, including this one.

@durera durera reopened this Dec 23, 2019
@durera
Copy link
Contributor

durera commented Dec 23, 2019

Re-opened because issue was closed automatically from the commit & I want to keep this open until after a new release is available on NPM and has been verified packaged correctly

@durera
Copy link
Contributor

durera commented Dec 23, 2019

I have published v0.6.1 with these changes in place ... https://www.npmjs.com/package/@wiotp/sdk/v/0.6.1

Please let me know if this works for you/if any further changes are needed 👍

@tanganellilore
Copy link
Contributor

tanganellilore commented Dec 24, 2019

Hi @durera ,

the package not work because the dist folder are not populated.
Probably there are some problem on npm build or config file for npm.

I create a PR to add dist folder into npm pack.

I don't know how you manage the npm run build function (is automatically or not) but for sure we need to have dist folder in our npm package.

Thanks

@durera
Copy link
Contributor

durera commented Dec 24, 2019

Ah, I hadn't noticed that files list in package.json, was only looking at /npmignore :)

0.6.2 looks like it has everything now. I've pulled it down via the sample app (https://github.com/ibm-watson-iot/iot-nodejs/tree/master/samples/webpack/statusconsole) and can see the dist folder, and it all works in the context of a webpack app at least.

@tanganellilore
Copy link
Contributor

hi @durera ,

now for me work perfect on nodejs >= 6.10 and ES2015.

Thanks

@durera durera closed this as completed Dec 24, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants