Link Search Menu Expand Document

Export shared dependencies

Table of contents

  1. Our exports
  2. Export shared dependencies
  3. Deploy exported dependencies
  4. Next

There are 2 steps necessary to take advantage of radpack:

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

Our exports

We can export anything, but for the sake of this example we’ll keep it simple.

Example

// export1.js
export default () => 'export1';
// export2.js
export default () => 'export2';

Export shared dependencies

Building your application with radpack will not benefit you until you’ve exported something.

Example

// RadpackExports / rollup.config.js
import radpack from '@radpack/rollup-plugin';

export default {
  , // your rollup config
  input: { export1: ./export1.js, export2: ./export2.js },
  plugins: [radpack({ /*register: radpackUrl*/ })]
}

In the above contrived rollup example, we’re exporting two entries, and rollup will take care of the rest. If you’ve not yet deployed anything, you have no need to register.

Deploy exported dependencies

Once you’re ready to deploy your exported dependencies, you can copy the dist folder to wherever you host your assets. In this folder you’ll see radpack.json and the bundled asset files in export1 and export2 folders. You can copy as-is, and overwrite any existing files. radpack.json file is the only mutable file in dist, so if you’re leveraging a CDN you may want to optimize accordingly. All *.js files are immutable as their content hash will reside in their filename, and as a result can be cached for any length you desire.

Next

Let’s take a look at how building an application works.