Link Search Menu Expand Document

Build application to consume radpack exports

Table of contents

  1. Hello World
  2. Webpack
  3. That’s it
  4. Next

There are 2 steps necessary to take advantage of radpack:

  1. Export shared dependencies
  2. Build application to consume radpack exports

Hello World

A hello-world app referencing our dependencies that have been exported to radpack.

No code change required!

Example

// hello-world.js
import export1 from 'export1';
import export2 from 'export2';

console.log(`Hello ${export1} and ${export2}!`);

Webpack

Now that you’ve exported your shared dependencies, you’ll need to update your Webpack configuration. Now when your application is built, any dependencies/exports that exist within radpack will no longer be bundled with your application. If at any time more than one application consumes a given export, you’ve effectively deduplicated and may not even be aware when it happens.

Example

const RadpackPlugin = require('@radpack/webpack-plugin');

module.exports = {
  entry: { entry1: './hello-world.js' },
  plugins: [
    RadpackPlugin({
      register: 'http://{MYCDN}/radpack/radpack.json'
    })
  ]
};

That’s it

While there’s much more we can do with Radpack, you’ve now completed the basics of your first application powered by radpack exports.

Next

See how the dependency graph works.