Coder Social home page Coder Social logo

esbuildnx's People

Contributors

brian-mcbride avatar gozmanyoni avatar pmb0 avatar saevarma avatar sindrig avatar vim-daniel 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

Watchers

 avatar  avatar  avatar  avatar

esbuildnx's Issues

Not work with esbuild-runner

config

// esbuild-runner.config.js
/* eslint-disable import/no-extraneous-dependencies */
const path = require('path');
const { esbuildDecorators } = require('@anatine/esbuild-decorators');

const tsconfig = path.resolve(__dirname, './tsconfig.json');
const getEsbuildOptions = async () => ({
    // Any esbuild build or transform options go here
    platform: 'node',
    target: 'esnext',
    sourcemap: false,
    plugins: [esbuildDecorators({ tsconfig, cwd: process.cwd() })],
});
const getConfig = async () => ({
    type: 'bundle', // bundle or transform (see description above)
    esbuild: await getEsbuildOptions(),
});
module.exports = getConfig();

bin.js

if (typeof process.env.NODE_ENV === 'undefined') {
    process.env.NODE_ENV = 'development';
}
require('esbuild-runner/register');
require('module-alias/register');

error

ColumnTypeUndefinedError: Column type for PostEntity#title is not defined and cannot be guessed. Make sure you have turned on an "emitDecoratorMetadata": true option in tsconfig.json. Also make sure you have imported "reflect-metadata" on top of the main entry file in your application (before any entity imported).If you are using JavaScript instead of TypeScript you must explicitly provide a column type.
    at new Co

Source maps not generated correctly

When I'm using the plugin I saw that the resulting sourcemaps are incorrect,
I'm opening this issue with a reproduction.

And I'll open a PR with a suggested fix ๐Ÿ˜„

Reproduction

https://stackblitz.com/edit/nestjs-typescript-starter-hrbgzh?file=dist/main.js.map

It should automatically run npm run build.
Then go to dist/main.js.map

And you can see that in the sourceContent instead of the decorator e.g.

@Controller()

it has the transpiled code:

var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {\n    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\n    if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\n    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;

A warning occurred at build time

code

import path from 'path';
import { esbuildDecorators } from '@anatine/esbuild-decorators';
import { build } from "esbuild"
build({
    entryPoints: [path.resolve('src/server/main.ts')],
    bundle: true,
    outfile: 'out.js',
    platform: 'node',
    target: 'node14',
    bundle: true,
    sourcemap: 'external',
    plugins: [
        esbuildDecorators({
            tsconfigPath: path.resolve('tsconfig.server.json'),
            force: true,
        }),
    ],
})
.catch(() => process.exit(1));

warning

โ–ฒ [WARNING] Top-level "this" will be replaced with undefined since this file is an ECMAScript module

    src/server/controller/HomeController.ts:1:18:
      1 โ”‚ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
        โ”‚                   ~~~~
        โ•ต                   undefined

  This file is considered to be an ECMAScript module because of the "export" keyword here:

    src/server/controller/HomeController.ts:25:0:
      25 โ”‚ export { HomeController };
         โ•ต ~~~~~~

Done in 1.67s.

"esbuild" Peer dependency version

Hello!

We used this plugin for our project, but It seems that the peer dependency of esbuild is very specific "esbuild": "~0.12.17". We upgraded to 0.14.25 and I'm wondering if you have any idea or we could tackle this? Did you test already this plugin with the latest version of esbuild?

Thank you ๐Ÿ˜Š

Working with Google libs (grpc proto files)

Getting build errors (Error: ENOENT: no such file or directory, open /protos/app_engine_key.proto'. I have seen some discussions around this. Wondering if there is a workaround for this?

Cannot find module 'typescript'

I install this package and I used typescript in global and when run show error:
Error: Cannot find module 'typescript'

when I install typescript in project this error gone

There is a bug about decorators support in esbuild

Code Position: esbuild-decorators.ts

Regular expressions don't work when decorator functions start with '$'. for example:

function Test(target: any, key?: string, pKey?: any) {
  if(!key) {
    return
  }
  console.log(">>>", Reflect.getMetadata("design:type", target, key))
}

@$Test
class Nardy {

  @$Test
  private name: Date = new Date()

  @$Test
  setName() {}

}

I think we should judge the legal function name instead of limiting it to letters, numbers and underscores next the '@' character

Plugin usage in esbuildnx

Hi, I've been trying to use your nx build executor and wanted to use your plugin for decorators.

The matter is that the executor only supports a json config which is not enough to import a plugin.
What do you think of a js / ts config file that would use a default export to provide an usable config ?

Problems with Genrics on Lambda-functions

There is a problem when compiling files with generics on lambda-functions.
Example:

const fn = <T>(Dependency: Constructable<T>, hint?: string): T =>
        ensureInjector().get(Dependency, hint);

It transpiles to this:

const fn = React.createElement(
      T,
      null,
      "(Dependency: Constructable",
      React.createElement(
        T,
        null,
        ", hint?: string): T => ensureInjector().get(Dependency, hint); // function fn",
        React.createElement(
          T,
          null,
          "(Dependency: Constructable",
          React.createElement(
            T,
            null,
            ", hint?: string): T ",
            fn.reset = () => {
              injector = void 0;
            },
            "; return fn; })();"
          )
        )
      )
    );

When changing the function to this it works:

function fn<T>(Dependency: Constructable<T>, hint?: string): T {
    return ensureInjector().get(Dependency, hint);
}

@nrwl/nx e2e test issues

Nx creates a project in the /tmp directory to run e2e tests against.
There is a consistent issue with the monorepo requiring packages from one another failing to be found in the e2e testing.

Currently, creating a link from @anatine/esbuild-decorators to the build directory of @anatine/esbuildnx then removing it after the test. The E2E testing should properly find package dependencies that exist within the same mono repo.

Might be loosely related to: nrwl/nx#5065

Issue with Nx here: nrwl/nx#5639

Create CI/CD pipelines

Need CI/CD pipelines for the following processes

  • Unit and e2e testing on PRs
  • Test coverage reports
  • Integrate with Nx Cloud for faster testing
  • Automatic changelog updates
  • Proper version & release tagging
  • Publish to NPM

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.