<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Dale Shoulders on Medium]]></title>
        <description><![CDATA[Stories by Dale Shoulders on Medium]]></description>
        <link>https://medium.com/@daleshoulders_73362?source=rss-65bfef3ed6d5------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/2*dMdSmR9DKXUtI-7yXr_smg.jpeg</url>
            <title>Stories by Dale Shoulders on Medium</title>
            <link>https://medium.com/@daleshoulders_73362?source=rss-65bfef3ed6d5------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 18 Nov 2026 19:16:44 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@daleshoulders_73362/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[How I got to grips with authoring npm packages]]></title>
            <link>https://medium.com/dell-boomi-engineering/how-i-got-to-grips-with-authoring-npm-packages-e5e8e0efcad2?source=rss-65bfef3ed6d5------2</link>
            <guid isPermaLink="false">https://medium.com/p/e5e8e0efcad2</guid>
            <category><![CDATA[npm]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[open-source]]></category>
            <category><![CDATA[dell-boomi]]></category>
            <dc:creator><![CDATA[Dale Shoulders]]></dc:creator>
            <pubDate>Wed, 01 May 2019 15:35:28 GMT</pubDate>
            <atom:updated>2019-05-03T10:05:07.613Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BXkX0ShzT4usgUKGvAwI8g.jpeg" /></figure><h3>Dell Boomi Flow embraces the open source ‘spirit’</h3><p>Many of our projects here at Dell Boomi are open source, and we like to embrace the open source spirit as much as we can. Our code is available publicly on <a href="https://github.com/manywho">GitHub</a>, which is a great start, but we are looking to actively drive our communication and collaboration with the open source community, and also start being fully open on some of the things we produce.</p><p>So, to make some of our JavaScript projects more accessible to others and potentially more useful outside of any Dell Boomi products, we decided a good starting point was to break the large single repositories down into smaller reusable component parts, and send them out into the wider, open source world!</p><h3>Breaking out components and publishing to npm</h3><p>As we use React the most obvious first step was to break out some of our React components and get them published to npm, a tool used by JavaScript developers around the world. (<a href="https://www.npmjs.com/"><em>www.npmjs.com</em></a>).</p><p>We initially took two components, a <strong>login form</strong> and a <strong>file upload</strong> to begin our journey. While other members of the team worked on getting them into separate, documented repositories on GitHub, my focus was to package and publish them to npm.</p><p>You can check out the packages below:</p><ul><li><a href="https://www.npmjs.com/package/@boomi/react-login-form">@boomi/react-login-form</a></li><li><a href="https://www.npmjs.com/package/@boomi/react-file-upload">@boomi/react-file-upload</a></li></ul><p>Now, onto my experience of getting to grips with authoring npm packages…</p><h3>Step 1. Get an npm account</h3><p>The first thing I realized was that although I’d been using npm packages for years, I had never set up an account! To publish a package to npm I’m going to need an account. A quick bit of form filling and ten minutes later, I was ready to go.</p><h3>Step 2. Create an ‘org’</h3><p>Another thing I had never really thought about, but is actually quite obvious, is that all npm packages have <strong><em>unique </em></strong>names. File uploads and login forms are already all over npm so rather than trying to come up with yet another name for effectively the same thing we could do with a way of grouping and namespacing our components — luckily, npm has just the thing: <strong>scopes</strong>.</p><p>However, to use a scope you first need to create an <strong>org</strong>. Orgs allow teams of contributors to read, write, and publish public or private scoped packages. Seems like a good idea, as all our packages can then be grouped under the same scope. We’ll see how to use the scope later.</p><h3>Step 3. Login</h3><p>To enable publishing to npm you first need to be logged in. To login with the terminal use npm login and follow the prompts.</p><h3>Step 4. Publish</h3><p>All a package needs to be published to npm is a <strong><em>package.json</em></strong> containing <em>name </em>and <em>version </em>properties. If using a scope make sure your package name includes it, for example:</p><pre>@scope/package-name</pre><p>Otherwise you’ll end up publishing the package directly under your username and as I found out, <strong><em>removing a published package from npm is not as easy as you’d expect</em></strong>. You will also want to add a “main” property which should be a path pointing to the package entry point.</p><p>Okay, we’re ready.</p><p>Oh no, hang on…</p><p>Packages published with a scope will be <strong><em>private </em></strong>by default. This is not what we want, the whole point was to embrace the open source community and make it public, so we need:</p><pre>npm publish -<strong>access=public</strong></pre><p>Or alternatively, you could add this to the <strong><em>package.json</em></strong>:</p><pre>“publishConfig”: {<br>    “access”: “public”<br>}</pre><p>Go…</p><p>…wow! There it is, we have a published npm package.</p><p>Sweet!</p><h3>What’s in the box?</h3><p>So, npm created a tarball with the contents of our package folder and sent it up to npm. That raises a question:</p><p><em>What exactly did it package up and send?</em></p><p>Looking back at the terminal it tells me that my package size is around 300kb.</p><p>Woah! Why so big?</p><p>Well, helpfully it also lists the files it included.</p><p><em>Just. About. Everything.</em></p><p>This is clearly not what we want, but what should we be packaging? Our component code should be compiled to ES5 so people don’t have to process it themselves. Most people will ignore <em>node_modules</em> in their babel config.</p><p>The only thing consumers of the package will need is what is output from the webpack build. Now, there are two ways we can filter this; a blacklist of files in an .npmignore file, or more suited to us, a file’s whitelist property in our <strong><em>package.json</em></strong>.</p><pre>“files”: [<br>    “/dist”<br>],</pre><p>Much better!</p><p>Ok, what’s the size now? My component JavaScript file is still around 140kb!</p><p>What’s going on? Let’s take a look inside…</p><p>As it turns out, webpack has included <strong><em>react </em></strong>and <strong><em>react-dom</em></strong> libraries into my component. We don’t want this — anyone using the component should be packaging react themselves.</p><p>We should instead add them to the externals in the webpack config:</p><pre>externals: {<br>    // Don’t bundle react or react-dom<br>    react: {<br>        commonjs: ‘react’,<br>        commonjs2: ‘react’,<br>        amd: ‘React’,<br>        root: ‘React’,<br>    },<br>    ‘react-dom’: {<br>        commonjs: ‘react-dom’,<br>        commonjs2: ‘react-dom’,<br>        amd: ‘ReactDOM’,<br>        root: ‘ReactDOM’,<br>    },<br>},</pre><p><strong><em>Side note:</em></strong><em> To make sure our component is declared as a module and therefore importable we’ll need to add two entries to the output section:</em></p><pre>library: ‘react-file-upload’,<br>libraryTarget: ‘umd’,</pre><p>We’re now down to around 10kb — phew! Much better!</p><p>We should also move <strong><em>react </em></strong>and <strong><em>react-dom</em></strong> libraries out of dependencies and into <em>devDependencies </em>and <em>peerDependencies </em>in our <strong><em>package.json</em></strong>. This will mean multiple copies of those packages won’t end up installed in consuming app’s node_modules.</p><p><strong>Note: </strong>Having multiple copies of react loaded can cause some strange bugs:</p><p><a href="https://stackoverflow.com/a/30454133/725500">What is the correct way of adding a dependency to react in your package.json for a react component</a></p><p>To ensure we always publish a freshly built component file we’ll need to add a script to <strong><em>package.json</em></strong> that will run whenever we publish, or in fact just before:</p><pre>“prepublishOnly”: “npm run dist”</pre><p><strong>Further reading: </strong>npm have some useful notes on Prepublish and Prepare: <a href="https://docs.npmjs.com/misc/scripts#prepublish-and-prepare">https://docs.npmjs.com/misc/scripts#prepublish-and-prepare</a></p><h3>Local development</h3><p>While developing the component, it’s helpful to run an application that actually <em>uses </em>it to get a real feel for how it behaves. Although it’s possible to directly install a local tarball file created with “npm pack”, or even run npm install with a directory e.g. <em>npm install ‘./path/to/some/directory’</em>, there is a command that makes things easier: <strong>npm link</strong>.</p><p><strong>Further reading: </strong><a href="https://docs.npmjs.com/cli/link.html">https://docs.npmjs.com/cli/link.html</a></p><ol><li>In the package directory, run npm link with no arguments.</li><li>Then in the consuming application directory run npm link ‘your-package-name’.</li></ol><p>The app now has a symlink to the package. A shortcut for this is to just run npm link <em>‘./path/to/some/directory’</em> in the app’s directory. Any changes made to the code in the package directory will automatically be reflected in the linked package. So, running <em>webpack — watch</em> in the package directory will auto build into our dist folder, this will then trigger a reload of the package in the containing app.</p><blockquote><strong>Yay, hot reloading!</strong></blockquote><p>We still don’t have debugging with sourcemaps. That would be helpful.</p><p>After some trial and error and hair pulling, I found that some <em>webpack sourcemap</em> options didn’t work with linked packages. One I found that does work well is ‘<em>cheap-module-eval-source-map</em>’. Sourcemaps can be tricky to get working on the entry file too (main property in <strong><em>package.json</em></strong>), this lead me to have my code in another module and simply import and export that module in my entry file.</p><h3>Versioning</h3><p>After making a couple of simple non-breaking changes to a package I made the mistake of republishing it <strong><em>without changing the version number</em></strong>.</p><blockquote>Do. Not. Do. This.</blockquote><blockquote>Ever.</blockquote><p>Someone else in the team was uninstalling and reinstalling the package to try to get the update. No matter what they did, <strong>old version</strong>.</p><p>Of course — <strong><em>VERSION!</em></strong></p><p><strong>Heed my warning and always change your version when publishing,</strong> otherwise people who already have the package won’t get the update.</p><h3>Conclusion of the journey</h3><p>Between <strong>package.json</strong>, npm CLI and webpack config (if using webpack) there are a lot of settings and options to get working together. npm does have good docs though and there is a lot of other info all over the web. It can be difficult, however, to pull it all together and focus on what applies to your scenario.</p><p><strong>Further reading:</strong></p><ul><li>NPM docs: <a href="https://docs.npmjs.com/">https://docs.npmjs.com/</a></li><li>And this developer guide is also very useful: <a href="https://docs.npmjs.com/misc/developers">https://docs.npmjs.com/misc/developers</a></li></ul><blockquote>And there we have it. That was my journey.</blockquote><p>So, it’s over to you guys now to prove the value of the open source community to us here at Dell Boomi…</p><ol><li>Have you done this?</li><li>How was your journey?</li><li>What could I have done to make my life simpler?</li></ol><p>You can check out the packages below:</p><ul><li><a href="https://www.npmjs.com/package/@boomi/react-login-form">@boomi/react-login-form</a></li><li><a href="https://www.npmjs.com/package/@boomi/react-file-upload">@boomi/react-file-upload</a></li></ul><p>Enjoy!</p><h3>About Dell Boomi</h3><p>Dell Boomi (Boomi), one of the Dell group of companies, is the leading provider of cloud integration and workflow automation for building The Connected Business.</p><p>Our cloud-native, low-code platform helps more than 7,500 organizations run better, faster and smarter. Our technologies connect applications, assure data quality and automate business processes.</p><p><strong>Please visit </strong><a href="https://www.boomi.com/"><strong>www.boomi.com</strong></a><strong> for more information.</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e5e8e0efcad2" width="1" height="1" alt=""><hr><p><a href="https://medium.com/dell-boomi-engineering/how-i-got-to-grips-with-authoring-npm-packages-e5e8e0efcad2">How I got to grips with authoring npm packages</a> was originally published in <a href="https://medium.com/dell-boomi-engineering">Dell Boomi Engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>