Skip to content

PSeON/amd-ant

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

amd-ant

Tiny AMD.js loader (~2KB), similar to requirejs but with basic functionality only.

It passes all anonymous and basic tests of amdjs-tests.

Test coverage is 100%.

Four variants are available:

File name Size (bytes) Description
amdant.es5.js 8648 ES5 syntax for older browsers
amdant.es5.min.js 2351 Optimized and minified version of the above
amdant.es6.js 7984 ES6 syntax for modern browsers
amdant.es6.min.js 1861 Optimized and minified version of the above

Example usage

Example HTML document which uses this loader might look like the following:

<!DOCTYPE html>
<html>
  <head>
    <title>AMD.js loader</title>
    <link rel="preload" href="/dist/amdant.es5.min.js" as="script" />
    <link rel="preload" href="/dist/index.js" as="script" />
  </head>
  <body>
    <script src="/dist/amdant.es5.min.js"></script>
    <script>
      require(['/dist/index']);
    </script>
  </body>
</html>

Example usage with Rollup might look like the following:

import * as fs from 'fs';

/**
 * @type {import('rollup').RollupOptions}
 */
const config = {
  input: 'src/index.js',
  output: [
    {
      dir: 'dist',
      format: 'amd',
      sourcemap: true,
    },
  ],
  plugins: [
    {
      name: 'copy-loader',
      generateBundle() {
        this.emitFile({
          type: 'asset',
          fileName: 'amdant.es5.min.js',
          source: fs.readFileSync(require.resolve('amd-ant/amdant.es5.min.js')),
        });
      },
    },
  ],
};

export default config;

License

ISC

About

Tiny AMD.js loader

Resources

Stars

Watchers

Forks

Packages

No packages published