Skip to content
This repository has been archived by the owner on Oct 8, 2024. It is now read-only.

Latest commit

 

History

History
39 lines (25 loc) · 1.18 KB

README.md

File metadata and controls

39 lines (25 loc) · 1.18 KB

Dynamic import ponyfill

RepositoryRegistryDocumentation

A dynamic imports polyfill for Deno Deploy and compiled executables.

Example

Note

JSX and import maps will work if configured in deno.json[c].

Important

Use statically analyzable imports when posible to avoid unnecessary work.

import { dynamicImport } from 'https://deno.land/x/import/mod.ts';

await dynamicImport(Math.random() < 0.5 ? './foo.ts' : './bar.ts');

It also has a function to evaluate modules from strings.

import { importString } from 'https://deno.land/x/import/mod.ts';

console.log(await importString('export const foo = "bar"'));

And you can pass parameters to them.

console.log(
	await importString('console.log(foo)', { parameters: { foo: 'bar' } }),
);

🦕 Happy dynamic importing!