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

Nest cannot be bundled using nexe #391

Closed
lizardruss opened this issue Feb 2, 2018 · 6 comments
Closed

Nest cannot be bundled using nexe #391

lizardruss opened this issue Feb 2, 2018 · 6 comments

Comments

@lizardruss
Copy link

lizardruss commented Feb 2, 2018

I'm submitting a...


[ ] Regression 
[x] Bug report
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behavior

With our project, we are using nexe to bundle the Nest application into an executable. This allows us to simplify our deployment process by not needing to manage different versions of node.

nexe uses the fuse-box bundler to package the application. Unfortunately, bundlers don't always interpret the meaning of this correctly, which is where the bug manifests itself. The next application can be packaged without error, but then encounters runtime errors when starting up.

The error on start up appears below:

TypeError: this.isClass is not a function
    at Object.exports.mapToClass.middleware [as mapToClass]

Expected behavior

The nest application should be executable once bundled.

Minimal reproduction of the problem with instructions

The steps to reproduce are as follows:

  1. Create a basic nest application
  2. Compile the application if needed.
  3. Install nexe: npm install nexe@^2.0.0-rc.22
  4. Use nexe to bundle it. If the compiled entry-point to your application is ./dist/index.js then run npx nexe ./dist/index.js
  5. Run the resulting executable, and observe the error mentioned above.

What is the motivation / use case for changing the behavior?

Remove the usage of the this keyword to avoid ambiguous interpretations by bundling tools (webpack, nexe, pkg, etc)

Typically I would expect the packaging tool to be fixed, and indeed there is a similar issue reported for fuse-box. However, after upgrading to a version including the fix, the issue still persists.

Environment


Nest version: 4.5.10

 
For Tooling issues:
- Node version: v8.9.0
- Platform:  Mac

Others:
- nexe@2.0.0-rc.22
- fuse-box@3.1.0-next.23 (implicit dependency of `nexe`, upgraded to explore a potential fix)
@lizardruss
Copy link
Author

PR: #392 submitted

@wbhob
Copy link
Contributor

wbhob commented Feb 3, 2018

This sounds like more of a bundler issue. If the bundler doesn't understand this, that's its own problem, not Nest.

@shekohex
Copy link
Contributor

shekohex commented Feb 3, 2018

I used pkg to make an Bundled Version of My Application, and it works Perfectly.
believe me or not, I'm also using webpack 2+ to make a bundled and smaller version of it !
Ridiculous Huh ?
I think that's not a problem with Nest, did you tried to transpile your code base to a lower version of ES ?
like ES5 ?

@lizardruss
Copy link
Author

@wbhob I agree, it's a bundler issue, but it also struck me as an odd usage of this, so I submitted a PR. I've since found a workaround for this issue, so I'm ok with closing it. Up to y'all whether you want to review the PR.

@shekohex I've used pkg as well, but switched to nexe when publishReplay() on an RxJS Observable didn't work correctly. Switching to nexe solved that issue, so I didn't look into it much further. fuse-box has since fixed the issue with this, but the new version hasn't been added to nexe. I fixed my issue by bundling with the new version of fuse-box.

@Dhaya06
Copy link

Dhaya06 commented Feb 14, 2019

[https://github.com/shkohexe)] Can you please share the steps of making exe with pkg. I tried as it explained in their document, i'm running into errors. Please share the steps . Thanks

@lock
Copy link

lock bot commented Sep 24, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Sep 24, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants