Coder Social home page Coder Social logo

lucacasonato / dext.ts Goto Github PK

View Code? Open in Web Editor NEW
241.0 7.0 8.0 577 KB

The Preact Framework for Deno

Home Page: https://deno.land/x/dext

License: MIT License

TypeScript 97.53% Dockerfile 0.98% CSS 0.03% JavaScript 1.46%
deno preact typescript web

dext.ts's Introduction

dext.ts

logo

The Preact Framework for Deno. Dext.ts is heavily inspired by Next.js.

  • Zero config
  • Pre-render pages at build time (SSG)
  • Tiny (example is only 5.75KB of JS)
  • Client hydration
  • Built-in routing
  • Zero config TypeScript support
  • File-system routing
  • Code-splitting, bundling, and tree shaking built in

Installing

To install, run the following command. This will make the dext CLI available in your path.

deno install --allow-read --allow-write --allow-env --allow-net --allow-run --unstable -f -n dext https://deno.land/x/[email protected]/cli.ts

Getting started

To create a new project run dext create myproject. This will scaffold a new dext project in the myproject folder. This folder contains a few files:

  • deps.ts contains all of your projects dependencies.
  • pages/index.tsx is the source for the / of your project.
  • pages/user/[name].tsx is the source for all routes at /user/[name] (e.g. /user/luca and /user/bartek).
  • tsconfig.json is the TypeScript configuration that the project uses.
  • .gitignore tells git to ignore the .dext folder that is created by dext dev and dext build.

Now that you have a project set up, you can start the development server using dext dev. After a few seconds you can view your built page at http://127.0.0.1:3000. When you change any of the files in the pages directory, your project will be rebuilt automatically, and the page will be automatically reloaded in the browser.

When you are ready to deploy to production, run dext build. This will generate a production optimized build. You can start a production webserver to serve this build with dext start.

Example

For an example, see the /example folder. You can create a production build it by running dext build, and then serve it by running dext start. You can also run dext dev to start watching, building, and serving.

You can also see a deployed version of this example on at https://dext.fly.dev.

dext.ts's People

Contributors

bartlomieju avatar kt3k avatar lucacasonato 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  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

dext.ts's Issues

I can't install dext, what version of Deno do I need?

I tried to install dext according to the instructions in the README, but I got an error.

Command

deno install --allow-read --allow-write --allow-env --allow-net --allow-run --unstable -f -n dext https://deno.land/x/[email protected]/cli.ts

Error

Check https://deno.land/x/[email protected]/cli.ts
error: TS2339 [ERROR]: Property 'emit' does not exist on type 'typeof Deno'.
        const result = await Deno.emit(id, {
                                  ~~~~
    at https://raw.githubusercontent.com/denofn/denopack/8bae39bef47e532a1e8d0f6700b72a2192f7bca4/plugin/typescriptTransform/mod.ts:19:35

TS2339 [ERROR]: Property 'emit' does not exist on type 'typeof Deno'.
  const { diagnostics, files: emitFiles } = await Deno.emit(importee, {
                                                       ~~~~
    at https://raw.githubusercontent.com/denofn/denopack/8bae39bef47e532a1e8d0f6700b72a2192f7bca4/plugin/typescriptCompile/mod.ts:45:56

Found 2 errors.

My environment is as below.

> deno --version

deno 1.6.3 (release, x86_64-pc-windows-msvc)
v8 8.8.294
typescript 4.1.3

Is it due to the fact that the Deno version is too low?

SyntaxError: The requested module '/polyfill/node/path.ts' does not provide an export named 'default'

While trying to install dext with the latest deno version by running deno install -r --allow-read --allow-write --allow-env --allow-net --allow-run --unstable -f -n dext https://deno.land/x/[email protected]/cli.ts, I get the following errors:

Warning Failed to get compiled source code of "https://cdn.dreg.dev/polyfill/node/path.ts".
Reason: No such file or directory (os error 2)
If the source file provides only type exports, prefer to use "import type" or "export type" syntax instead.
Warning Failed to get compiled source code of "https://cdn.dreg.dev/polyfill/node/process.ts".
Reason: No such file or directory (os error 2)
If the source file provides only type exports, prefer to use "import type" or "export type" syntax instead.
error: Uncaught SyntaxError: The requested module '/polyfill/node/path.ts' does not provide an export named 'default'

JSX not recognized in vscode

I cannot get correct JSX in vscode (despite using the deno extension)

I followed the readme, getting started
deno install // but here I added --no-check because it was not ok
dext create myproject
and
inside pages/index.ts
vscode displays the following error on the first jsx <> :
Cannot find name 'React'.deno-ts(2304)

I really have no clue how to fix this !
Thanks !

Add API routes

The user should be able to add routes to pages/api that should be treated as server side API endpoints rather than HTML pages. The signature for an API route would look something like this:

// pages/api/redirect.ts

export default async (req: Request): Promise<Response> => {
  return Response.redirect(req.headers.get("X-Redirect-To"), 307); 
}

cli installing error

Hi guys, I get this error every time I try to install dext CLI

Warning Failed to get compiled source code of "https://cdn.dreg.dev/polyfill/node/path.ts".
Reason: The system cannot find the file specified. (os error 2)
If the source file provides only type exports, prefer to use "import type" or "export type" syntax instead.
Warning Failed to get compiled source code of "https://cdn.dreg.dev/polyfill/node/process.ts".
Reason: The system cannot find the file specified. (os error 2)
If the source file provides only type exports, prefer to use "import type" or "export type" syntax instead.
error: Uncaught SyntaxError: The requested module '/polyfill/node/path.ts' does not provide an export named 'default'

deno: 1.4.4
platform: windows 10

Switch to esbuild

I am confident this is possible after the release of x/esbuild. I played around with it last weekend, and managed to write a Deno resolution module loader in only a few hundred lines. Will publish the loader plugin shortly.

isolatedModules were ignored

> rm -rf /home/ryan/.cache/deno
> cd dext.ts/example
> deno run --no-check -A --unstable https://deno.land/x/[email protected]/cli.ts build
[...]
Unsupported compiler options in "/home/ryan/src/dext.ts/example/tsconfig.json".
  The following options were ignored:
    isolatedModules

Hot refresh

As a step towards hot module reloading and prefresh, we should automatically reload the browser page after the bundle was rebuilt in dev mode. There should be a command line flag to disable this behavior (e.g. --no-hot-refresh).

Add option to export static build for netlify

Add a dext export netlify command that generates a folder with all static assets, and a _redirects file from a built .dext folder and the contained pagemap.json. This would essentially allow you to serve the project without using dext start. The _redirects file would take the place of the routing in dext start.

Custom 404 page

A user should be able to specify the look of the 404 page by creating a pages/_404.tsx file. It should support all of the same features as a regular page, including that it is pre-rendered.

Scaffold project using dext create

There should be a dext create command to scaffold a new project. This should create a pages/ directory with a index page and a dynamic page, and the tsconfig.json file.

Add getServerSideData build hook

The getServerSideProps is used to enable dynamic server side rendering. On initial request to the server, the page should be pre-rendered, and on client navigation the data should be fetched from the server, and rendered on the client.

dext road map

dext it seems be good tool for building frontend using deno ecosystem, and maintain by great dev from deno team.
some question come in mind :
will dext support ssr for be seo friendly ?
dext will have a way to be integrate with deno framwork like oak ?
....

Sourcemap and minifying is slow

I tried to measure the elapsed time of each part of bundling process of our use case with this patch, and I got the following result:

Ensure tsconfig 0.004s
findPages 0.418s
ensureDir 0s
writeTextFile 0.001s
Started building
Finished building 0.591s
Finished sourcemap 42.619s
Finished emit 0.03s
minify 9.578s
Finished bundling (all) 52.874s

80% is spent in creating sourcemap and 18% is in minifying. So if we have options for disabling these, it would be useful for certain situations.

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.