0.3.0 • Published 5 years ago

node-url-imports v0.3.0

Weekly downloads
3
License
MIT
Repository
github
Last release
5 years ago

NodeURLImports

Transform browser URL imports into Node compatible import/require statements using local dependencies.

Travis   npm   License MIT   code style: prettier

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.