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
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'
}
}
};
The [d3-require.js][] javascript file is a minimal, promise-based implementation to require asynchronous module definitions (AMD)
d3.require('d3-view').then(d3 => {
...
});
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
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
This example will set the mylib
requirement to a local module
d3.libs.set('mylib', {
origin: '/',
main: 'the/main/module.js'
});