Skip to content
/ import Public

A dynamic imports polyfill for Deno Deploy and compiled executables

License

Notifications You must be signed in to change notification settings

ayoreis/import

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

42 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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!