Code Monkey home page Code Monkey logo

denopack's Introduction

denofn logo

denofn-selfhosted

Self-hosted Deno functions, made with Deno and Docker

denofn UI screenshot


Preface

Combining a love for Typescript and all things serverless, denofn started as a little project to also get reaquainted with Deno and Docker. It's currently running stable locally on UNIX development machines and on a Digitalocean droplet+volume.

Documentation

The old docs are quite outdated and in need of a big rewrite, but it's currently the best place to get started.

denopack's People

Contributors

ericpoggel avatar jeroenptrs avatar lucacasonato avatar ohmlnz avatar probins avatar soremwar avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

denopack's Issues

[BUG] Ignores directories in output filename/sourcemap

Describe the bug
If the output filename includes a directory - subdir/output.js - it is ignored, and the file written to the current directory

To Reproduce
Enter subdir/output.js in output file config.

Expected behavior
FIle and sourcemap should be put in subdir.

Desktop (please complete the following information):

  • Deno version 1.6.2
  • denopack version 0.10.0

Additional context
emitFiles.ts seems to be confusing the dir and file options. dir is for code splitting chunks, and isn't used for single build file. This bit of code needs rewriting.

Support for top-level await

Hey, thanks for this project, it looks like a great way to bring nice Deno code to the browser!

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

I'd like to use denopack to bundle any deno std library not using the Deno APIs.

I tried bundling a project but it fails with Uncaught Error: Terser is not supposed to return nothing!.
I narrowed down the problem to having export { createHash } from 'https://deno.land/[email protected]/hash/mod.ts' in my deps.ts file and my assumption, comparing with other imports from std that can get compiled correctly, is that it's because the std/hash module uses WASM imports.

Describe the solution you'd like

Rollup has a WASM plugin that would be great to support in denopack, either as a plugin or in core.
Alternatively, if there is an easy way to convert/wrap existing Rollup plugins to denopack ones it could be a good option.

Describe alternatives you've considered

Using deno bundle + minifier

Thanks!

[BUG] pluginCssBundle doesn't resolve locations correctly

Describe the bug
Css plugin paths are not being resolved correctly

To Reproduce
Specify any route in the css configuration output option that isn't located in the root of the output folder.

Expected behavior
Should create the folder and emit the file

Similar solution to #16

TS error in rollup dependency on package install/run

I was actually thinking of building a bundler for Deno because its internal bundler isn't great for client-side output...

On that note I tried to install this package globally while also trying to just run the CLI via velociraptor. But I get this error:

error: TS1031 at https://unpkg.com/[email protected]/dist/es/rollup.browser.js:11:39947,Unexpected token Some(LParen) at https://unpkg.com/[email protected]/dist/es/rollup.browser.js:11:39954

Are you aware of this?

Move readme to docs site

  • create static docs site on gh pages
  • expand on examples (go through the entire CLI api)
  • add recipes will be done differently

DENO_DIR is not set

error: Uncaught Error: DENO_DIR is not set
if (!deno_dir) throw new Error(DENO_DIR is not set);
^
at mod.ts:2:22

as far as I know, DENO_DIR env is not exist

[BUG] Getting a 500 Internal Server Error while installing

Describe the bug

I'm getting a 500 Internal Server Error when running:

deno run --allow-run --allow-read https://x.nest.land/[email protected]/install.ts

Screenshots

Download https://cdn.dreg.dev/polyfill/node/path.ts
Download https://cdn.dreg.dev/package/@types/[email protected]
error: Import 'https://cdn.dreg.dev/package/[email protected]' failed: 500 Internal Server Error
    at https://cdn.dreg.dev/package/@rollup/[email protected]/dist/es/index.js:2:0
error: Uncaught (in promise) AssertionError: Failed to install plugin dependencies.
    throw new AssertionError(msg);
          ^
    at assert (asserts.ts:156:11)
    at install.ts:63:1

Desktop (please complete the following information):

  • OS: macOS Catalina
  • Deno version: 1.5.4
  • denopack version: 0.10.0

Additional context

The issue appears to be at the CDN level given that this is not reachable: https://cdn.dreg.dev/package/[email protected]. Not sure if I should have opened this issue on the Dreg repo instead.

Checklist

  • I am using Deno version 1.2.0 or higher

Multiple decorators are not getting called

Multiple decorators are not getting called.

Reproduce the behavior with test.ts:

function A() {
  console.log("@A evaluated");
  return function (
    target: any,
    propertyKey: string,
    descriptor: PropertyDescriptor,
  ) {
    console.log("@A called");
    const fn = descriptor.value;
    descriptor.value = function() {
      console.log("fn() called from @A");
      fn();  
    };
  };
}

function B() {
  console.log("@B evaluated");
  return function (
    target: any,
    propertyKey: string,
    descriptor: PropertyDescriptor,
  ) {
    console.log("@B called");
    const fn = descriptor.value;
    descriptor.value = function() {
      console.log("fn() called from @B");
      fn();  
    };
  };
}

class C {
  @A()
  @B()
  static test() {
    console.log("C.test() called");
  }
}

C.test();
denopack -i test.ts
denopack completed in 405ms
deno run bundle.js   
@A evaluated
@B evaluated
@B called
@B called
fn() called from @B
fn() called from @B
C.test() called

Expected behavior

@A evaluated
@B evaluated
@B called
@A called
fn() called from @A
fn() called from @B
C.test() called
  • OS: macOS
  • Deno version 1.5.2
  • denopack version 0.10.0

Remote debugging in VS Code

Remote debugging in VS Code and Google Chrome not working properly after denopack bundling.

Operating system: MacOS Catalina 10.15.6
Deno version: 1.3.3
VS Code version: 1.49.0

Steps to reproduce the issue:

  • Open react-template in VS Code.

  • Create "dist" folder in the root directory.

  • Run denopack -c denopack.config.ts to bundle the project and serve files from the dist directory on port 3000.

  • Open Google Chrome with remote debugging enabled with this command:
    /Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --remote-debugging-port=9222 --user-data-dir=/tmp/chrome-debug

  • Open http://localhost:9222/json to verify if Chrome is running with remote debugging enabled on port 9222.

  • Add this configuration to launch.json file in .vscode folder:

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Attach to Chrome",
            "port": 9222,
            "request": "attach",
            "type": "pwa-chrome",
            "webRoot": "${workspaceFolder}"
        },
    ]
}
  • Attach some breakpoints to src/App.tsx
  • Open localhost:3000.
  • Run debugger with "Attach to Chrome" configuration.

Result: All breakpoints are unbounded and inaccessible from the debugger.

Can you please, give me some guidance, how to setup and use remote debugging with VSCode, Chrome, and Denopack?

The same configuration is working fine with the create-react-app typescript template.

[BUG] Cannot destructure property 'output'

Describe the bug

When using the CLI, I have encountered the following runtime error.

deno run --unstable --allow-read --allow-write --allow-env --allow-net https://deno.land/x/[email protected]/cli.ts --config ./bundle.config.ts

error: Uncaught (in promise) TypeError: Cannot destructure property 'output' of 'opts' as it is undefined.
  const { output: _outputOpts, ...rollupOpts } = opts;
                  ^
    at mergeOptions (options.ts:64:19)
    at runBundler (runBundler.ts:30:53)

To Reproduce
Steps to reproduce the behavior:

  1. Run the above command.
  2. Error! ๐Ÿ‘ป

Expected behavior

I expected it to work. ๐Ÿ˜›

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: Fedora 33
  • Deno version: see below.
deno 1.5.4 (bc79d55, release, x86_64-unknown-linux-gnu)
v8 8.8.278.2
typescript 4.0.5
  • denopack version: 0.10.0

Checklist

  • I am using Deno version 1.2.0 or higher

Frontend related roadmap

After denopack 0.5.0, focus will shift a bit to frontend related plugins

Must haves (short term)

  • append bundle/input file to custom HTML file
  • css support
  • JSX transpiling (babel, ...) <- actually already supported

Must haves (long term)

  • full React support
  • full PostCSS support
  • Vue / Svelte support
  • Typescene support
  • create-XYZ-app like templates from CLI for popular apps

Nice to haves

  • read JS/TS entry file from HTML file (f.e. like Parcel does)
  • multiple entry support
  • static generation (will probably need something NextJS-/Gatsby-like, might be more than a plugin) [needs multiple entry support and markdown support]

Polyfilled Node version of Rollup

Since jspm support for Deno is way in the future for now, this will probably have to be done manually or through the Dreg project (denofn/dreg).

Ultimately this would allow denopack's CLI to become more of a wrapper for functionality proposed in #8 rather than a Denoified version of the Rollup CLI.

Since the future of dreg is still undecided, I'm opening an issue here as well.

[BUG] Debugging experience is very poor

Describe the bug

When Rollup encounters a runtime error, it leaves you with very little to go on -- aside from a stack trace, containing mangled function names and hard-to-reach line numbers.

This doesn't really help:

[resynth@synthcave synth-di]$ time deno run --unstable --allow-read --allow-write --allow-env --allow-net https://deno.land/x/[email protected]/cli.ts --config ./build/base.config.ts
error: Uncaught (in promise) TypeError: Cannot read property 'split' of undefined
    at Ve (https://unpkg.com/[email protected]/dist/es/rollup.browser.js:11:31514)
    at Ra (https://unpkg.com/[email protected]/dist/es/rollup.browser.js:11:318386)
    at async Ua.loadEntryModule (https://unpkg.com/[email protected]/dist/es/rollup.browser.js:11:327081)
    at async Promise.all (index 0)

To Reproduce
Steps to reproduce the behavior:

  1. Encounter a runtime error in Rollup
  2. See error

Expected behavior

You get an un-minifed error.
The Rollup module you're importing does not come with a source map, btw.

[BUG] Can't install (No such host is known.)

Describe the bug
The installation fails

To Reproduce
Execute the command on the readme (deno run --allow-run --allow-read https://deno.land/x/[email protected]/install.ts)

Expected behavior
I expect the installation to success

Screenshots
image

Desktop (please complete the following information):

  • OS: Windows 11
  • Deno version 1.33.1
  • denopack version latest?

Additional context

โฏ deno run --allow-run --allow-read https://deno.land/x/[email protected]/install.ts
error: error sending request for url (https://cdn.dreg.dev/package/@rollup/[email protected]): error trying to connect: dns error: No such host is known. (os error 11001)
    at https://deno.land/x/[email protected]/plugin/deps.ts:8:8
error: Uncaught (in promise) AssertionError: Failed to install plugin dependencies.
    throw new AssertionError(msg);
          ^
    at assert (https://deno.land/[email protected]/testing/asserts.ts:156:11)
    at https://deno.land/x/[email protected]/install.ts:63:1
    at eventLoopTick (ext:core/01_core.js:166:11)

Checklist

  • I am using Deno version 1.2.0 or higher

[BUG] Installation error in Deno 1.5.x: CertNotValidForName

Describe the bug
When trying to install latest denopack v0.10.0 in Deno 1.5.0 and 1.5.2, the installation failed with error CertNotValidForName

Screenshots

$ deno --version
deno 1.5.2 (71d7482, release, x86_64-apple-darwin)
v8 8.7.220.3
typescript 4.0.5

$ deno run --allow-run --allow-read https://x.nest.land/[email protected]/install.ts
Check https://x.nest.land/[email protected]/install.ts
Download https://lr4vbhbl66orzg7pmpep4hflo5kmcvpd4jgwsz6uch5hvv4xproa.arweave.net/XHlQnCv3nRyb72PI_hyrd1TBVePiTWln1BH6eteXfFw/deps.ts
Download https://unpkg.com/[email protected]/dist/es/rollup.browser.js
Download https://unpkg.com/[email protected]/dist/rollup.d.ts
...
Download https://lr4vbhbl66orzg7pmpep4hflo5kmcvpd4jgwsz6uch5hvv4xproa.arweave.net/XHlQnCv3nRyb72PI_hyrd1TBVePiTWln1BH6eteXfFw/plugin/deps.ts
Download https://cdn.dreg.dev/package/@rollup/[email protected]
Sending fatal alert BadCertificate
error: error sending request for url (https://cdn.dreg.dev/package/@rollup/[email protected]): error trying to connect: invalid certificate: CertNotValidForName
    at https://lr4vbhbl66orzg7pmpep4hflo5kmcvpd4jgwsz6uch5hvv4xproa.arweave.net/XHlQnCv3nRyb72PI_hyrd1TBVePiTWln1BH6eteXfFw/plugin/deps.ts:1:0
error: Uncaught (in promise) AssertionError: Failed to install plugin dependencies.
    throw new AssertionError(msg);
          ^
    at assert (asserts.ts:156:11)
    at install.ts:63:1

However, when browsing to the URL: https://cdn.dreg.dev/package/@rollup/[email protected], the browser shows certificate as valid.

Desktop (please complete the following information):

  • OS: macOS Mojave 10.14.6
  • Deno version 1.5.0-1.5.2
  • denopack version 0.10.0

Checklist

  • I am using Deno version 1.2.0 or higher

bug: non root html emit does not work

A config that emits a HTML file like so:

    html({
      template: createHtmlTemplate,
      title: "React App",
      meta: [
        { charset: "utf-8" },
        {
          name: "viewport",
          content: "width=device-width, initial-scale=1",
        },
        {
          name: "description",
          content: "Web site created using create-react-app",
        },
      ],
      fileName: "x/test.html",
    }),

leads to three issues:

  1. The emitted <script src="mod.js" type="module"></script> should look like <script src="../mod.js" type="module"></script>
  2. The emitted <link href="mod.css" rel="stylesheet"> should look like <link href="../mod.css" rel="stylesheet">
  3. mkdir -r dist/x has to be run before denopack, because denopack does not create the directory itself.

Meta

> denopack --version
denopack/0.8.0 linux-x86_64 deno-1.3.3

deno fmt precommit hook

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

Describe the solution you'd like
see title

Describe alternatives you've considered
manual... lol

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.