kt3k / packup

📦 Zero-config web application packager for Deno
https://packup.deno.dev/
MIT License
327 stars 18 forks source link

Use 'npm:...' style imports with packup #59

Closed emin63 closed 11 months ago

emin63 commented 11 months ago

Is your feature request related to a problem? Please describe.

I would like to use deno style imports in code I bundle for the client.

I can do something like

import * as fjs from 'npm:formulajs' // works in deno but not when running packup

in code I run with deno (e.g., in a jupyter notebook) but that does not work in packup when bundling for the client.

Describe the solution you'd like A clear and concise description of what you want to happen.

I would like to be able to use something like import * as fjs from 'npm:formulajs' in client side code and bundle it with packup.

Describe alternatives you've considered

I'm just getting started with deno and packup so don't really know what alternatives I could try. If there is a better way to have code that works with both client and server side via deno/packup, that would be great.

Additional context

I am trying to learn how to use deno both on the server and client side. Packup seems like a great tool to bundle the HTML and javascript for the client but it seems like it does now quite support deno style imports (or I don't know how to use them).

emin63 commented 11 months ago

Never mind. This is possible via something like:

import * as fjs from 'https://esm.sh/gh/formulajs/formulajs@2.9.3/dist/formula.min.js';
const data = [1, 2, 3]
var result = fjs.default.AVERAGE(data);

which works as expected everywhere.

Sorry for the trouble and thanks for a great project!