Skip to content
This repository has been archived by the owner on Jul 3, 2020. It is now read-only.

Latest commit

 

History

History
94 lines (76 loc) · 1.96 KB

require.md

File metadata and controls

94 lines (76 loc) · 1.96 KB

View-Require

view-require

The view-require executable is useful for creating a d3-require file with dependencies matching the package.json file of your module.

For help on how to use the script in terminal

view-require -h

config

It is possible to specify a require.config.js file of the form:

module.exports = {
    out: 'build/xxxx.js',
    prepend: [
        'whatwg-fetch/fetch.js'
    ],
    append: [
        'build/require.js'
    ],
    dependencies: {
        "ace-builds": {
            main: "src-min/ace.js"
        },
        handlebars: {
            main: 'dist/handlebars.min.js'
        }
    }
};

d3-require.js

The [d3-require.js][] javascript file is a minimal, promise-based implementation to require asynchronous module definitions (AMD)

d3.require('d3-view').then(d3 => {
    ...
});

Version

The d3.libs map is useful for setting versions:

d3.libs.set('d3-selection', {
    version: '1.1'
});

The required url will be

https://unpkg.com/d3-selection@1.1

Main

THe libs map is useful for setting the main file of a distribution:

d3.libs.set('d3-selection', {
    version: '1.1',
    main: 'build/d3-selection.min.js'
});

The required url will be

https://unpkg.com/d3-selection@1.1/build/d3-selection.min.js

Local module

This example will set the mylib requirement to a local module

d3.libs.set('mylib', {
    origin: '/',
    main: 'the/main/module.js'
});