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

aurelia-cli 1.0.0 - .NET Core project with Aurelia built-in bundler does not start #1108

Open
nenadvicentic opened this issue Jun 3, 2019 · 6 comments

Comments

@nenadvicentic
Copy link

I'm submitting a bug report

  • Library Version:
    1.0.0

Please tell us about your environment:

  • Operating System:
    Windows 10

  • Browser:
    all

  • Language:
    TypeScript 3.4.5

  • Loader/bundler:
    RequireJS/Aurelia build-in bundler

Current behavior:

  • What is the expected behavior?
    When selecting .NET Core project with Aurelia built-in bundler, configuration does not work, because .NET Startup.cs class contains code for Webpack Dev Middleware, which should not be used with Aurelia built-in bundler.

Bellow are full project options selected:

Global aurelia-cli v1.0.0
_ _ ____ _ ___
__ _ _ _ _ __ | () __ _ / | | | |
/ | | | | '__/ _ \ | |/ _ | | | | | | |
| (
| | |
| | | | __/ | | (
| | | |
| |___ | |
_,|_,|| ___|||_,| _|||

√ Please enter a name for your new project: · WebApplication-Aureli-Cli
√ Would you like to use the default setup or customize your choices? · Custom App
√ Which bundler would you like to use? · CLI's built-in bundler with an AMD module loader
√ Which AMD module loader would you like to use? · RequireJS
√ What platform are you targeting? · .NET Core
√ What transpiler would you like to use? · TypeScript
√ How would you like to setup your HTML template? · Minimum Minification
√ What css preprocessor would you like to use? · Sass
√ Do you want to add PostCSS processing · Typical
√ Which unit test runner would you like to use? · Jest
√ Would you like to configure integration testing? · Protractor
√ What is your default code editor? · Visual Studio Code
√ Which features do you want scaffolded into your project? · Navigation App

Error is:
---> (Inner Exception #0) Microsoft.AspNetCore.NodeServices.HostingModels.NodeInvocationException: Webpack dev middleware failed because of an error while loading 'aspnet-webpack'. Error was: Error: Cannot find module 'aspnet-webpack'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:582:15)
at Function.Module._load (internal/modules/cjs/loader.js:508:25)
at Module.require (internal/modules/cjs/loader.js:637:17)
at require (internal/modules/cjs/helpers.js:22:18)
at Object. (C:\Users\Nenad\AppData\Local\Temp\pd2rae2s.bpj:83:19)
at webpack_require (C:\Users\Nenad\AppData\Local\Temp\pd2rae2s.bpj:20:30)
at createWebpackDevServer (C:\Users\Nenad\AppData\Local\Temp\pd2rae2s.bpj:62:26)
at C:\Users\Nenad\AppData\Local\Temp\1vtizutj.5vx:114:19
at IncomingMessage. (C:\Users\Nenad\AppData\Local\Temp\1vtizutj.5vx:133:38)
at IncomingMessage.emit (events.js:194:15)
Current directory is: c:\Users\Nenad\source\repos\WebApplication-Aureli-Cli

  • What is the motivation / use case for changing the behavior?
    This is bug. Project with selected options should work from the get go.
@3cp
Copy link
Member

3cp commented Jun 4, 2019

So there is only instruction on how to hook up webpack. That's probably why old cli didn't have cli-bundler option for dotnet-core app.

I am not a dotnet user, I cannot even got a sample dotnet 2.2 app with aurelia+webpack working, dotnet run still renders old dotnet page, not aurelia app page.

@brandonseydel @artmasa @arjendeblok do you guys knows how to hook up cli-bundler front-end in the Startup.cs? If it's too troublesome, we have to turn off cli-bundler for dotnet-core skeleton.

@brandonseydel
Copy link
Member

brandonseydel commented Jun 4, 2019

https://github.com/aurelia/dotnet/blob/master/README.md

You can download the night package and follow the readme to patch an existing cli project. You can also download the templates and start from there.

https://www.nuget.org/packages/Aurelia.DotNet.Templates/

@nenadvicentic
Copy link
Author

@3cp I think combination of cli-bundler and dotnet-core project is valid to have, even without tight development integration and hot-module-replacement in place. I am actually using it like this for years.

Bigger problem is that so many project template combinations in aurelia-cli are not setup correctly and do not work from get-go, so new users have no clue what to do.

@brandonseydel I'll take a look at those templates. Thx.

@3cp
Copy link
Member

3cp commented Jun 4, 2019

@nenadvicentic if you know how to hook them up, please send a PR :-)

@nenadvicentic
Copy link
Author

@3cp I did not manage to connect aurelia-cli with dev middleware myself, but project templates for .NET Core which @brandonseydel suggested above have implementation that works. It uses middleware from aurelia/dotnet:

app.UseStaticFiles();
app.UseSpaStaticFiles();
app.UseSpa(spa => {
    spa.Options.SourcePath = "%replaceWithAureliaCLIRoot%";

    if (env.IsDevelopment())
    {
        spa.UseAureliaCliServer(); // Optional HMR (Hot Module Reload)
    }
});

@3cp
Copy link
Member

3cp commented Jun 4, 2019

Oh, I didn't know @brandonseydel's solution works for cli-bundler too. We probably should use the middleware in default cli template offering, if someone can create a PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants