Code Monkey home page Code Monkey logo

Comments (2)

cmorten avatar cmorten commented on May 8, 2024

Hi @lowray 👋

So the first error you've reported appears to be a bug with deno bundle as far as I can see, the outputted, bundled js file appears to have placed the definition of:

request2.get = ...

on line 309, when in fact request2 is only defined later on line 23284. Hence why we get the reference error.

If you have a use-case for Opine in this bundled form then I would recommend raising an issue to report the bug with deno bundle on the main https://github.com/denoland/deno repo 😄.

...interestingly if you fix the request2 issue by moving the request2.get method to the appropriate place, then you receive the following error:

error: Uncaught ReferenceError: init is not defined
await init(read("./pkg/denoflate_bg.wasm"));
^
    at file:///~/git/asos-craigmorten/opine/opine.js:18261:1

So I sense there may be a few (or perhaps the same?) bugs with the deno bundle CLI command at the moment. This particular one is regarding a missing init method which is completely missing from the bundle, indicating that deno bundle is somehow missing the default export / import of this method within the https://github.com/hazae41/denoflate library which Opine makes use of.


The error you are seeing when not providing the --no-check is due to deno bundle stripping all type information from Opine to create your opine.js file. Without this type information Deno is unable to infer some of the properties on the app object, nor will it know what types the req and res objects have. You would either need to import the Opine types into your file and manually type the various objects, or alternatively, don't use typescript at all by changing your file extension to .js, i.e. serve.js - given you are making use of --no-check which skips typechecking, it may be simpler for you to just use plain JavaScript in the first place!

Ultimately the errors you are seeing are expected behaviour when importing objects and functions from a JS file into a TS file / project.


Given neither of these issues are (afaik) anything wrong with Opine itself I will close this - happy to re-open if something else comes to light!

from opine.

cmorten avatar cmorten commented on May 8, 2024

Having a read, I believe this will all be fixed in a next release following the merge of denoland/deno#8901 which upgrades swc which is used for bundling. So probably not worth raising a new issue as likely a duplicate of all the listed ones.

from opine.

Related Issues (20)

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.