0.3.0 • Published 7 years ago
node-url-imports v0.3.0
NodeURLImports
Transform browser URL
imports into Node compatibleimport/requirestatements using local dependencies.
npm: npm install typified --save
cdn: https://cdn.jsdelivr.net/npm/typified@latest/src/index.js
Getting Started
As only require statements are catchable, all import statements first need to be transformed into their require equivalents – using something like Babel.
foo@bar:~$ node -r @babel/register index.jsUsing the following .babelrc configuration:
{
"ignore": [],
"plugins": ["@babel/plugin-transform-modules-commonjs"]
}With the @babel/plugin-transform-modules-commonjs dependency loaded Babel only transform the import statements. After that you can include the node-url-imports module that'll monkey-patch the require function and transform all URL imports into their local dependency equivalents.
foo@bar:~$ node -r @babel/register -r node-url-imports index.jsAfterwards you can include other transpilers such as esm.