Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Genrule refuses to build when adding Typescript support #10884

Closed
anthanh opened this issue Mar 2, 2020 · 3 comments
Closed

Genrule refuses to build when adding Typescript support #10884

anthanh opened this issue Mar 2, 2020 · 3 comments

Comments

@anthanh
Copy link

anthanh commented Mar 2, 2020

Description of the problem / feature request:

Hi there!

Building NextJS projects seems to work with plain JS, but not with Typescript support.
You can try it here.
FYI: NextJS generates artifacts in .next folder. Sources and node_modules still needed to run the NextJS webapp.

It works with nodejs_binary, but no output management.
Can't use npm_package_bin because NextJS build directory has several run-time generated hashed files, or cannot zip it (no cmd attr).
So I ended up using genrule.

Feature requests: what underlying problem are you trying to solve with this feature?

next-cli under genrule with Typescript support.

Bugs: what's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

Here you can find an example project with 2 NextJS appplications:

  • webapp: NextJS with JS => bazelisk //packages/webapp:start works.
  • webapp2: NextJS with TS. => bazelist //packages/webapp2:start fail.

What operating system are you running Bazel on?

OSX 10.14.6

What's the output of bazel info release?

release 2.1.1

What's the output of git remote get-url origin ; git rev-parse master ; git rev-parse HEAD ?

[email protected]:anthanh/bazel-next-typescript-monorepo.git
8d15f1a6dd1a48d63188cef2bef24bc45d81e870
8d15f1a6dd1a48d63188cef2bef24bc45d81e870

Have you found anything relevant by searching the web?

Not really, maybe related to this? bazel-contrib/rules_nodejs#312

Any other information, logs, or outputs that you want to share?

yarn run v1.17.3
$ bazelisk run //packages/webapp2:start
INFO: Analyzed target //packages/webapp2:start (2 packages loaded, 11 targets configu
red).
INFO: Found 1 target...
ERROR: /Users/anthanh/code/github/bazel-js-monorepo/packages/webapp2/BUILD:49:1: Exec
uting genrule //packages/webapp2:build failed (Exit 1) bash failed: error executing c
ommand /bin/bash -c ... (remaining 1 argument(s) skipped)

Use --sandbox_debug to see verbose messages from the sandbox
It looks like you're trying to use TypeScript but do not have the required package(s)
 installed.

Please install typescript, @types/react, and @types/node by running:

        npm install --save-dev typescript @types/react @types/node

If you are not trying to use TypeScript, please remove the tsconfig.json file from your package root (and any TypeScript files).

Creating an optimized production build...
Target //packages/webapp2:start failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 11.772s, Critical Path: 10.94s
INFO: 0 processes.
FAILED: Build did NOT complete successfully
FAILED: Build did NOT complete successfully
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
@anthanh anthanh changed the title Genrule refuses to build when adding Typescript support: Please install typescript, @types/react, and @types/node Genrule refuses to build when adding Typescript support Mar 2, 2020
@irengrig
Copy link
Contributor

irengrig commented Mar 6, 2020

Hi @anthanh , thank you for reporting the problem!

It is quite a long description so I did not really read it deeply, but just in case - there is this part in the reported error:

"Please install typescript, @types/react, and @types/node by running:
npm install --save-dev typescript @types/react @types/node"

  • does it help?

Also, it seems that this is completely rules_nodejs related and there is nothing we can do in Bazel itself.
Please report the issue for rules_nodejs.

@anthanh
Copy link
Author

anthanh commented Mar 17, 2020

The reported error is pretty weird since @types/node, typescript are part of the devDependencies (@types/react is a dependency of @types/react-dom).
as defined here https://github.com/anthanh/bazel-next-typescript-monorepo/blob/master/packages/webapp2/package.json#L20
Looks like the rule cannot find it somehow.

Thanks @irengrig for your response 😅 .

@jin
Copy link
Member

jin commented Mar 26, 2020

Please reopen this issue in rules_nodejs as it's not Bazel related.

@jin jin closed this as completed Mar 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants