node-url-imports
v0.3.0
Published
Transform browser URL imports into Node compatible import/require statements using local dependencies.
Downloads
9
Readme
NodeURLImports
Transform browser URL
import
s into Node compatibleimport
/require
statements 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.js
Using 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.js
Afterwards you can include other transpilers such as esm
.