mirror of
https://github.com/aspnet/JavaScriptServices.git
synced 2025-12-23 10:08:57 +00:00
Compare commits
99 Commits
2.1.0-prev
...
pakrym/no-
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
366d65a614 | ||
|
|
8027397d67 | ||
|
|
f024e779a6 | ||
|
|
7819c2f950 | ||
|
|
f47c5901b6 | ||
|
|
cdfa5d85f6 | ||
|
|
3265b92086 | ||
|
|
9c6a1b577f | ||
|
|
25e9c50585 | ||
|
|
ef999a57fd | ||
|
|
0050b505ec | ||
|
|
e231b29e58 | ||
|
|
ec82df4287 | ||
|
|
e9621c8add | ||
|
|
59ca023f46 | ||
|
|
d8662392a0 | ||
|
|
78a8bbf783 | ||
|
|
587ead92e4 | ||
|
|
28798452a9 | ||
|
|
622be9084a | ||
|
|
cd009006c8 | ||
|
|
817c0e4f24 | ||
|
|
f0e66325c3 | ||
|
|
c2f15f4199 | ||
|
|
cfd3a19279 | ||
|
|
24ebd9ff3e | ||
|
|
a4be7b3898 | ||
|
|
15884cbadb | ||
|
|
ae7b7c2663 | ||
|
|
e47f15fdc8 | ||
|
|
4bc67d6a60 | ||
|
|
bc50741043 | ||
|
|
1af86b7ba8 | ||
|
|
9281cbaf72 | ||
|
|
cd2b52bbd0 | ||
|
|
97022a1ff2 | ||
|
|
78dd174aed | ||
|
|
040a58578c | ||
|
|
4d7485bba2 | ||
|
|
02383cd614 | ||
|
|
a4bb72e58c | ||
|
|
df85010938 | ||
|
|
9c741600d2 | ||
|
|
4763ad5b8c | ||
|
|
dd9957bc39 | ||
|
|
601909865f | ||
|
|
d9d4359a1e | ||
|
|
5f44de86f6 | ||
|
|
c8342594a8 | ||
|
|
ea3a7bc897 | ||
|
|
578124e1ce | ||
|
|
0da7460fa2 | ||
|
|
0dc570a0c8 | ||
|
|
5fa87a0313 | ||
|
|
b1d04c99c9 | ||
|
|
d742bea01e | ||
|
|
7a04134345 | ||
|
|
c177cc001c | ||
|
|
067298bead | ||
|
|
cf659b3fda | ||
|
|
1e85713d75 | ||
|
|
a04813edc3 | ||
|
|
e49b0e439e | ||
|
|
d65a4f3b6d | ||
|
|
47828ee727 | ||
|
|
0d1c99c1d1 | ||
|
|
240dd82473 | ||
|
|
b616db4918 | ||
|
|
436cdb0e96 | ||
|
|
2698d77487 | ||
|
|
447359af84 | ||
|
|
823630c508 | ||
|
|
c35a3a17c0 | ||
|
|
98c47a1c70 | ||
|
|
0a1c83ab81 | ||
|
|
2167b28ffd | ||
|
|
966bfcb172 | ||
|
|
b8f85dc2d9 | ||
|
|
8c84e35392 | ||
|
|
944e8d396d | ||
|
|
6ba3014c57 | ||
|
|
961619c5c9 | ||
|
|
da66cc1fee | ||
|
|
b7ba837d6e | ||
|
|
7d30f2bbc3 | ||
|
|
424e5ed91a | ||
|
|
67267eabf7 | ||
|
|
1e5b6f864e | ||
|
|
8ddacb8b73 | ||
|
|
2c81117b4b | ||
|
|
4d151a599e | ||
|
|
78f7dccfab | ||
|
|
7f550fb469 | ||
|
|
087a459c9c | ||
|
|
61b4951961 | ||
|
|
02beb11a5c | ||
|
|
04b8c17bdd | ||
|
|
e6af1b892e | ||
|
|
24766621e1 |
@@ -4,7 +4,7 @@ install:
|
||||
- ps: Install-Product node 6.9.2 x64
|
||||
branches:
|
||||
only:
|
||||
- dev
|
||||
- master
|
||||
- /^release\/.*$/
|
||||
- /^(.*\/)?ci-.*$/
|
||||
build_script:
|
||||
|
||||
@@ -19,6 +19,6 @@ script:
|
||||
- ./build.sh
|
||||
branches:
|
||||
only:
|
||||
- dev
|
||||
- master
|
||||
- /^release\/.*$/
|
||||
- /^(.*\/)?ci-.*$/
|
||||
|
||||
13
.vsts-pipelines/builds/ci-internal.yml
Normal file
13
.vsts-pipelines/builds/ci-internal.yml
Normal file
@@ -0,0 +1,13 @@
|
||||
trigger:
|
||||
- master
|
||||
- release/*
|
||||
|
||||
resources:
|
||||
repositories:
|
||||
- repository: buildtools
|
||||
type: git
|
||||
name: aspnet-BuildTools
|
||||
ref: refs/heads/master
|
||||
|
||||
phases:
|
||||
- template: .vsts-pipelines/templates/project-ci.yml@buildtools
|
||||
15
.vsts-pipelines/builds/ci-public.yml
Normal file
15
.vsts-pipelines/builds/ci-public.yml
Normal file
@@ -0,0 +1,15 @@
|
||||
trigger:
|
||||
- master
|
||||
- release/*
|
||||
|
||||
# See https://github.com/aspnet/BuildTools
|
||||
resources:
|
||||
repositories:
|
||||
- repository: buildtools
|
||||
type: github
|
||||
endpoint: DotNet-Bot GitHub Connection
|
||||
name: aspnet/BuildTools
|
||||
ref: refs/heads/master
|
||||
|
||||
phases:
|
||||
- template: .vsts-pipelines/templates/project-ci.yml@buildtools
|
||||
@@ -1,4 +1,4 @@
|
||||
Contributing
|
||||
======
|
||||
|
||||
Information on contributing to this repo is in the [Contributing Guide](https://github.com/aspnet/Home/blob/dev/CONTRIBUTING.md) in the Home repo.
|
||||
Information on contributing to this repo is in the [Contributing Guide](https://github.com/aspnet/Home/blob/master/CONTRIBUTING.md) in the Home repo.
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
<RepositoryRoot>$(MSBuildThisFileDirectory)</RepositoryRoot>
|
||||
<AssemblyOriginatorKeyFile>$(MSBuildThisFileDirectory)build\Key.snk</AssemblyOriginatorKeyFile>
|
||||
<SignAssembly>true</SignAssembly>
|
||||
<PublicSign Condition="'$(OS)' != 'Windows_NT'">true</PublicSign>
|
||||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
<Project>
|
||||
<Project>
|
||||
<PropertyGroup>
|
||||
<RuntimeFrameworkVersion Condition=" '$(TargetFramework)' == 'netcoreapp2.0' ">$(MicrosoftNETCoreApp20PackageVersion)</RuntimeFrameworkVersion>
|
||||
<RuntimeFrameworkVersion Condition=" '$(TargetFramework)' == 'netcoreapp2.1' ">$(MicrosoftNETCoreApp21PackageVersion)</RuntimeFrameworkVersion>
|
||||
<RuntimeFrameworkVersion Condition=" '$(TargetFramework)' == 'netcoreapp3.0' ">$(MicrosoftNETCoreApp30PackageVersion)</RuntimeFrameworkVersion>
|
||||
<NETStandardImplicitPackageVersion Condition=" '$(TargetFramework)' == 'netstandard2.0' ">$(NETStandardLibrary20PackageVersion)</NETStandardImplicitPackageVersion>
|
||||
<!-- aspnet/BuildTools#662 Don't police what version of NetCoreApp we use -->
|
||||
<NETCoreAppMaximumVersion>99.9</NETCoreAppMaximumVersion>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
|
||||
207
LICENSE.txt
207
LICENSE.txt
@@ -1,14 +1,201 @@
|
||||
Copyright (c) .NET Foundation and Contributors
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
All rights reserved.
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
||||
this file except in compliance with the License. You may obtain a copy of the
|
||||
License at
|
||||
1. Definitions.
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software distributed
|
||||
under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
||||
CONDITIONS OF ANY KIND, either express or implied. See the License for the
|
||||
specific language governing permissions and limitations under the License.
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright (c) .NET Foundation and Contributors
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
18
README.md
18
README.md
@@ -17,11 +17,11 @@ Read [Building Single Page Applications on ASP.NET Core with JavaScriptServices]
|
||||
This repo contains:
|
||||
|
||||
* A set of NuGet/NPM packages that implement functionality for:
|
||||
* Invoking arbitrary NPM packages at runtime from .NET code ([docs](https://github.com/aspnet/JavaScriptServices/tree/dev/src/Microsoft.AspNetCore.NodeServices#simple-usage-example))
|
||||
* Server-side prerendering of SPA components ([docs](https://github.com/aspnet/JavaScriptServices/tree/dev/src/Microsoft.AspNetCore.SpaServices#server-side-prerendering))
|
||||
* Webpack dev middleware ([docs](https://github.com/aspnet/JavaScriptServices/tree/dev/src/Microsoft.AspNetCore.SpaServices#webpack-dev-middleware))
|
||||
* Hot module replacement (HMR) ([docs](https://github.com/aspnet/JavaScriptServices/tree/dev/src/Microsoft.AspNetCore.SpaServices#webpack-hot-module-replacement))
|
||||
* Server-side and client-side routing integration ([docs](https://github.com/aspnet/JavaScriptServices/tree/dev/src/Microsoft.AspNetCore.SpaServices#routing-helper-mapspafallbackroute))
|
||||
* Invoking arbitrary NPM packages at runtime from .NET code ([docs](/src/Microsoft.AspNetCore.NodeServices#simple-usage-example))
|
||||
* Server-side prerendering of SPA components ([docs](/src/Microsoft.AspNetCore.SpaServices#server-side-prerendering))
|
||||
* Webpack dev middleware ([docs](/src/Microsoft.AspNetCore.SpaServices#webpack-dev-middleware))
|
||||
* Hot module replacement (HMR) ([docs](/src/Microsoft.AspNetCore.SpaServices#webpack-hot-module-replacement))
|
||||
* Server-side and client-side routing integration ([docs](/src/Microsoft.AspNetCore.SpaServices#routing-helper-mapspafallbackroute))
|
||||
* Server-side and client-side validation integration
|
||||
* "Lazy loading" for Knockout apps
|
||||
* Samples and docs
|
||||
@@ -44,7 +44,7 @@ In an empty directory, run (for example) `dotnet new angular`. Other supported S
|
||||
Once the generator has run and restored all the dependencies, you can start up your new ASP.NET Core SPA:
|
||||
|
||||
npm install
|
||||
dotnet run
|
||||
dotnet run
|
||||
|
||||
### Option 2: Creating Angular/React/Redux applications using Visual Studio 2017 Update 3 or later (Windows only)
|
||||
|
||||
@@ -63,10 +63,10 @@ If you have an existing ASP.NET Core application, or if you just want to use the
|
||||
* `Microsoft.AspNetCore.NodeServices`
|
||||
* This provides a fast and robust way for .NET code to run JavaScript on the server inside a Node.js environment. You can use this to consume arbitrary functionality from NPM packages at runtime in your ASP.NET Core app.
|
||||
* Most applications developers don't need to use this directly, but you can do so if you want to implement your own functionality that involves calling Node.js code from .NET at runtime.
|
||||
* Find [documentation and usage examples here](https://github.com/aspnet/JavaScriptServices/tree/dev/src/Microsoft.AspNetCore.NodeServices#microsoftaspnetcorenodeservices).
|
||||
* Find [documentation and usage examples here](/src/Microsoft.AspNetCore.NodeServices#microsoftaspnetcorenodeservices).
|
||||
* `Microsoft.AspNetCore.SpaServices`
|
||||
* This provides infrastructure that's generally useful when building Single Page Applications (SPAs) with technologies such as Angular or React (for example, server-side prerendering and webpack middleware). Internally, it uses the `NodeServices` package to implement its features.
|
||||
* Find [documentation and usage examples here](https://github.com/aspnet/JavaScriptServices/tree/dev/src/Microsoft.AspNetCore.SpaServices#microsoftaspnetcorespaservices)
|
||||
* Find [documentation and usage examples here](/src/Microsoft.AspNetCore.SpaServices#microsoftaspnetcorespaservices)
|
||||
|
||||
There were previously other packages called `Microsoft.AspNetCore.AngularServices` and `Microsoft.AspNetCore.ReactServices` but these are not currently needed - all applicable functionality is in `Microsoft.AspNetCore.SpaServices`, because it's sufficiently general.
|
||||
|
||||
@@ -74,7 +74,7 @@ If you want to build a helper library for some other SPA framework, you can do s
|
||||
|
||||
## Samples
|
||||
|
||||
The [`samples` directory](https://github.com/aspnet/JavaScriptServices/tree/dev/samples) contains examples of:
|
||||
The [`samples` directory](/samples) contains examples of:
|
||||
|
||||
- Using the JavaScript services family of packages with Angular and React.
|
||||
- A standalone `NodeServices` usage for runtime code transpilation and image processing.
|
||||
|
||||
@@ -3,25 +3,29 @@
|
||||
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Label="Package Versions">
|
||||
<InternalAspNetCoreSdkPackageVersion>2.1.0-preview2-15749</InternalAspNetCoreSdkPackageVersion>
|
||||
<MicrosoftAspNetCoreDiagnosticsPackageVersion>2.1.0-preview2-30478</MicrosoftAspNetCoreDiagnosticsPackageVersion>
|
||||
<MicrosoftAspNetCoreHostingAbstractionsPackageVersion>2.1.0-preview2-30478</MicrosoftAspNetCoreHostingAbstractionsPackageVersion>
|
||||
<MicrosoftAspNetCoreHostingPackageVersion>2.1.0-preview2-30478</MicrosoftAspNetCoreHostingPackageVersion>
|
||||
<MicrosoftAspNetCoreMvcPackageVersion>2.1.0-preview2-30478</MicrosoftAspNetCoreMvcPackageVersion>
|
||||
<MicrosoftAspNetCoreMvcTagHelpersPackageVersion>2.1.0-preview2-30478</MicrosoftAspNetCoreMvcTagHelpersPackageVersion>
|
||||
<MicrosoftAspNetCoreMvcViewFeaturesPackageVersion>2.1.0-preview2-30478</MicrosoftAspNetCoreMvcViewFeaturesPackageVersion>
|
||||
<MicrosoftAspNetCoreServerIISIntegrationPackageVersion>2.1.0-preview2-30478</MicrosoftAspNetCoreServerIISIntegrationPackageVersion>
|
||||
<MicrosoftAspNetCoreServerKestrelPackageVersion>2.1.0-preview2-30478</MicrosoftAspNetCoreServerKestrelPackageVersion>
|
||||
<MicrosoftAspNetCoreStaticFilesPackageVersion>2.1.0-preview2-30478</MicrosoftAspNetCoreStaticFilesPackageVersion>
|
||||
<MicrosoftAspNetCoreWebSocketsPackageVersion>2.1.0-preview2-30478</MicrosoftAspNetCoreWebSocketsPackageVersion>
|
||||
<MicrosoftExtensionsDependencyInjectionPackageVersion>2.1.0-preview2-30478</MicrosoftExtensionsDependencyInjectionPackageVersion>
|
||||
<MicrosoftExtensionsFileProvidersPhysicalPackageVersion>2.1.0-preview2-30478</MicrosoftExtensionsFileProvidersPhysicalPackageVersion>
|
||||
<MicrosoftExtensionsLoggingConsolePackageVersion>2.1.0-preview2-30478</MicrosoftExtensionsLoggingConsolePackageVersion>
|
||||
<MicrosoftExtensionsLoggingDebugPackageVersion>2.1.0-preview2-30478</MicrosoftExtensionsLoggingDebugPackageVersion>
|
||||
<MicrosoftNETCoreApp20PackageVersion>2.0.0</MicrosoftNETCoreApp20PackageVersion>
|
||||
<MicrosoftNETCoreApp21PackageVersion>2.1.0-preview2-26326-03</MicrosoftNETCoreApp21PackageVersion>
|
||||
<InternalAspNetCoreSdkPackageVersion>3.0.0-alpha1-20181031.6</InternalAspNetCoreSdkPackageVersion>
|
||||
<MicrosoftAspNetCoreDiagnosticsPackageVersion>3.0.0-alpha1-10670</MicrosoftAspNetCoreDiagnosticsPackageVersion>
|
||||
<MicrosoftAspNetCoreHostingAbstractionsPackageVersion>3.0.0-alpha1-10670</MicrosoftAspNetCoreHostingAbstractionsPackageVersion>
|
||||
<MicrosoftAspNetCoreHostingPackageVersion>3.0.0-alpha1-10670</MicrosoftAspNetCoreHostingPackageVersion>
|
||||
<MicrosoftAspNetCoreMvcPackageVersion>3.0.0-a-alpha1-react-razor-design-19157</MicrosoftAspNetCoreMvcPackageVersion>
|
||||
<MicrosoftAspNetCoreMvcTagHelpersPackageVersion>3.0.0-a-alpha1-react-razor-design-19157</MicrosoftAspNetCoreMvcTagHelpersPackageVersion>
|
||||
<MicrosoftAspNetCoreMvcViewFeaturesPackageVersion>3.0.0-a-alpha1-react-razor-design-19157</MicrosoftAspNetCoreMvcViewFeaturesPackageVersion>
|
||||
<MicrosoftAspNetCoreServerIISIntegrationPackageVersion>2.2.0-rtm-10670</MicrosoftAspNetCoreServerIISIntegrationPackageVersion>
|
||||
<MicrosoftAspNetCoreServerKestrelPackageVersion>3.0.0-alpha1-10670</MicrosoftAspNetCoreServerKestrelPackageVersion>
|
||||
<MicrosoftAspNetCoreStaticFilesPackageVersion>3.0.0-alpha1-10670</MicrosoftAspNetCoreStaticFilesPackageVersion>
|
||||
<MicrosoftAspNetCoreWebSocketsPackageVersion>3.0.0-alpha1-10670</MicrosoftAspNetCoreWebSocketsPackageVersion>
|
||||
<MicrosoftExtensionsDependencyInjectionPackageVersion>3.0.0-alpha1-10670</MicrosoftExtensionsDependencyInjectionPackageVersion>
|
||||
<MicrosoftExtensionsFileProvidersPhysicalPackageVersion>3.0.0-alpha1-10670</MicrosoftExtensionsFileProvidersPhysicalPackageVersion>
|
||||
<MicrosoftExtensionsLoggingAbstractionsPackageVersion>3.0.0-alpha1-10670</MicrosoftExtensionsLoggingAbstractionsPackageVersion>
|
||||
<MicrosoftExtensionsLoggingConsolePackageVersion>3.0.0-alpha1-10670</MicrosoftExtensionsLoggingConsolePackageVersion>
|
||||
<MicrosoftExtensionsLoggingDebugPackageVersion>3.0.0-alpha1-10670</MicrosoftExtensionsLoggingDebugPackageVersion>
|
||||
<MicrosoftNETCoreApp20PackageVersion>2.0.9</MicrosoftNETCoreApp20PackageVersion>
|
||||
<MicrosoftNETCoreApp30PackageVersion>3.0.0-preview1-26907-05</MicrosoftNETCoreApp30PackageVersion>
|
||||
<MicrosoftNETSdkRazorPackageVersion>3.0.0-a-alpha1-sdk-31823</MicrosoftNETSdkRazorPackageVersion>
|
||||
<NETStandardLibrary20PackageVersion>2.0.3</NETStandardLibrary20PackageVersion>
|
||||
<NewtonsoftJsonPackageVersion>11.0.2</NewtonsoftJsonPackageVersion>
|
||||
<SystemThreadingTasksDataflowPackageVersion>4.9.0-preview2-26326-04</SystemThreadingTasksDataflowPackageVersion>
|
||||
<SystemThreadingTasksDataflowPackageVersion>4.10.0-preview1-26907-04</SystemThreadingTasksDataflowPackageVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(DotNetPackageVersionPropsPath)" Condition=" '$(DotNetPackageVersionPropsPath)' != '' " />
|
||||
<PropertyGroup Label="Package Versions: Pinned" />
|
||||
</Project>
|
||||
|
||||
@@ -4,11 +4,11 @@
|
||||
<PropertyGroup>
|
||||
<!-- These properties are use by the automation that updates dependencies.props -->
|
||||
<LineupPackageId>Internal.AspNetCore.Universe.Lineup</LineupPackageId>
|
||||
<LineupPackageRestoreSource>https://dotnet.myget.org/F/aspnetcore-release/api/v3/index.json</LineupPackageRestoreSource>
|
||||
<LineupPackageRestoreSource>https://dotnet.myget.org/F/aspnetcore-dev/api/v3/index.json</LineupPackageRestoreSource>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<DotNetCoreRuntime Include="$(MicrosoftNETCoreApp20PackageVersion)" />
|
||||
<DotNetCoreRuntime Include="$(MicrosoftNETCoreApp21PackageVersion)" />
|
||||
<DotNetCoreRuntime Include="$(MicrosoftNETCoreApp22PackageVersion)" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<RestoreSources Condition="'$(DotNetBuildOffline)' != 'true' AND '$(AspNetUniverseBuildOffline)' != 'true' ">
|
||||
$(RestoreSources);
|
||||
https://dotnet.myget.org/F/dotnet-core/api/v3/index.json;
|
||||
https://dotnet.myget.org/F/aspnetcore-release/api/v3/index.json;
|
||||
https://dotnet.myget.org/F/aspnetcore-dev/api/v3/index.json;
|
||||
https://dotnet.myget.org/F/aspnetcore-tools/api/v3/index.json;
|
||||
</RestoreSources>
|
||||
<RestoreSources Condition="'$(DotNetBuildOffline)' != 'true'">
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
version:2.1.0-preview2-15749
|
||||
commithash:5544c9ab20fa5e24b9e155d8958a3c3b6f5f9df9
|
||||
version:3.0.0-alpha1-20181031.6
|
||||
commithash:dc9e2ae2d294184c7c7da383e62c7c400099d1d0
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"$schema": "https://raw.githubusercontent.com/aspnet/BuildTools/release/2.1/tools/korebuild.schema.json",
|
||||
"channel": "release/2.1",
|
||||
"$schema": "https://raw.githubusercontent.com/aspnet/BuildTools/master/tools/korebuild.schema.json",
|
||||
"channel": "master",
|
||||
"toolsets": {
|
||||
"nodejs": {
|
||||
"required": true,
|
||||
|
||||
31
run.ps1
31
run.ps1
@@ -26,12 +26,18 @@ The base url where build tools can be downloaded. Overrides the value from the c
|
||||
.PARAMETER Update
|
||||
Updates KoreBuild to the latest version even if a lock file is present.
|
||||
|
||||
.PARAMETER Reinstall
|
||||
Re-installs KoreBuild
|
||||
|
||||
.PARAMETER ConfigFile
|
||||
The path to the configuration file that stores values. Defaults to korebuild.json.
|
||||
|
||||
.PARAMETER ToolsSourceSuffix
|
||||
The Suffix to append to the end of the ToolsSource. Useful for query strings in blob stores.
|
||||
|
||||
.PARAMETER CI
|
||||
Sets up CI specific settings and variables.
|
||||
|
||||
.PARAMETER Arguments
|
||||
Arguments to be passed to the command
|
||||
|
||||
@@ -46,8 +52,8 @@ in the file are overridden by command line parameters.
|
||||
Example config file:
|
||||
```json
|
||||
{
|
||||
"$schema": "https://raw.githubusercontent.com/aspnet/BuildTools/dev/tools/korebuild.schema.json",
|
||||
"channel": "dev",
|
||||
"$schema": "https://raw.githubusercontent.com/aspnet/BuildTools/master/tools/korebuild.schema.json",
|
||||
"channel": "master",
|
||||
"toolsSource": "https://aspnetcore.blob.core.windows.net/buildtools"
|
||||
}
|
||||
```
|
||||
@@ -65,8 +71,10 @@ param(
|
||||
[string]$ToolsSource,
|
||||
[Alias('u')]
|
||||
[switch]$Update,
|
||||
[string]$ConfigFile,
|
||||
[switch]$Reinstall,
|
||||
[string]$ToolsSourceSuffix,
|
||||
[string]$ConfigFile = $null,
|
||||
[switch]$CI,
|
||||
[Parameter(ValueFromRemainingArguments = $true)]
|
||||
[string[]]$Arguments
|
||||
)
|
||||
@@ -93,6 +101,10 @@ function Get-KoreBuild {
|
||||
$version = $version.TrimStart('version:').Trim()
|
||||
$korebuildPath = Join-Paths $DotNetHome ('buildtools', 'korebuild', $version)
|
||||
|
||||
if ($Reinstall -and (Test-Path $korebuildPath)) {
|
||||
Remove-Item -Force -Recurse $korebuildPath
|
||||
}
|
||||
|
||||
if (!(Test-Path $korebuildPath)) {
|
||||
Write-Host -ForegroundColor Magenta "Downloading KoreBuild $version"
|
||||
New-Item -ItemType Directory -Path $korebuildPath | Out-Null
|
||||
@@ -101,9 +113,9 @@ function Get-KoreBuild {
|
||||
try {
|
||||
$tmpfile = Join-Path ([IO.Path]::GetTempPath()) "KoreBuild-$([guid]::NewGuid()).zip"
|
||||
Get-RemoteFile $remotePath $tmpfile $ToolsSourceSuffix
|
||||
if (Get-Command -Name 'Expand-Archive' -ErrorAction Ignore) {
|
||||
if (Get-Command -Name 'Microsoft.PowerShell.Archive\Expand-Archive' -ErrorAction Ignore) {
|
||||
# Use built-in commands where possible as they are cross-plat compatible
|
||||
Expand-Archive -Path $tmpfile -DestinationPath $korebuildPath
|
||||
Microsoft.PowerShell.Archive\Expand-Archive -Path $tmpfile -DestinationPath $korebuildPath
|
||||
}
|
||||
else {
|
||||
# Fallback to old approach for old installations of PowerShell
|
||||
@@ -167,8 +179,9 @@ if (Test-Path $ConfigFile) {
|
||||
}
|
||||
}
|
||||
catch {
|
||||
Write-Warning "$ConfigFile could not be read. Its settings will be ignored."
|
||||
Write-Warning $Error[0]
|
||||
Write-Host -ForegroundColor Red $Error[0]
|
||||
Write-Error "$ConfigFile contains invalid JSON."
|
||||
exit 1
|
||||
}
|
||||
}
|
||||
|
||||
@@ -179,7 +192,7 @@ if (!$DotNetHome) {
|
||||
else { Join-Path $PSScriptRoot '.dotnet'}
|
||||
}
|
||||
|
||||
if (!$Channel) { $Channel = 'dev' }
|
||||
if (!$Channel) { $Channel = 'master' }
|
||||
if (!$ToolsSource) { $ToolsSource = 'https://aspnetcore.blob.core.windows.net/buildtools' }
|
||||
|
||||
# Execute
|
||||
@@ -188,7 +201,7 @@ $korebuildPath = Get-KoreBuild
|
||||
Import-Module -Force -Scope Local (Join-Path $korebuildPath 'KoreBuild.psd1')
|
||||
|
||||
try {
|
||||
Set-KoreBuildSettings -ToolsSource $ToolsSource -DotNetHome $DotNetHome -RepoPath $Path -ConfigFile $ConfigFile
|
||||
Set-KoreBuildSettings -ToolsSource $ToolsSource -DotNetHome $DotNetHome -RepoPath $Path -ConfigFile $ConfigFile -CI:$CI
|
||||
Invoke-KoreBuildCommand $Command @Arguments
|
||||
}
|
||||
finally {
|
||||
|
||||
35
run.sh
35
run.sh
@@ -14,10 +14,12 @@ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
[ -z "${DOTNET_HOME:-}" ] && DOTNET_HOME="$HOME/.dotnet"
|
||||
verbose=false
|
||||
update=false
|
||||
reinstall=false
|
||||
repo_path="$DIR"
|
||||
channel=''
|
||||
tools_source=''
|
||||
tools_source_suffix=''
|
||||
ci=false
|
||||
|
||||
#
|
||||
# Functions
|
||||
@@ -38,6 +40,8 @@ __usage() {
|
||||
echo " -s|--tools-source|-ToolsSource <URL> The base url where build tools can be downloaded. Overrides the value from the config file."
|
||||
echo " --tools-source-suffix|-ToolsSourceSuffix <SUFFIX> The suffix to append to tools-source. Useful for query strings."
|
||||
echo " -u|--update Update to the latest KoreBuild even if the lock file is present."
|
||||
echo " --reinstall Reinstall KoreBuild."
|
||||
echo " --ci Apply CI specific settings and environment variables."
|
||||
echo ""
|
||||
echo "Description:"
|
||||
echo " This function will create a file \$DIR/korebuild-lock.txt. This lock file can be committed to source, but does not have to be."
|
||||
@@ -62,6 +66,10 @@ get_korebuild() {
|
||||
version="$(echo "${version#version:}" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')"
|
||||
local korebuild_path="$DOTNET_HOME/buildtools/korebuild/$version"
|
||||
|
||||
if [ "$reinstall" = true ] && [ -d "$korebuild_path" ]; then
|
||||
rm -rf "$korebuild_path"
|
||||
fi
|
||||
|
||||
{
|
||||
if [ ! -d "$korebuild_path" ]; then
|
||||
mkdir -p "$korebuild_path"
|
||||
@@ -175,6 +183,12 @@ while [[ $# -gt 0 ]]; do
|
||||
-u|--update|-Update)
|
||||
update=true
|
||||
;;
|
||||
--reinstall|-[Rr]einstall)
|
||||
reinstall=true
|
||||
;;
|
||||
--ci|-[Cc][Ii])
|
||||
ci=true
|
||||
;;
|
||||
--verbose|-Verbose)
|
||||
verbose=true
|
||||
;;
|
||||
@@ -206,26 +220,37 @@ if [ -f "$config_file" ]; then
|
||||
config_channel="$(jq -r 'select(.channel!=null) | .channel' "$config_file")"
|
||||
config_tools_source="$(jq -r 'select(.toolsSource!=null) | .toolsSource' "$config_file")"
|
||||
else
|
||||
__warn "$config_file is invalid JSON. Its settings will be ignored."
|
||||
__error "$config_file contains invalid JSON."
|
||||
exit 1
|
||||
fi
|
||||
elif __machine_has python ; then
|
||||
if python -c "import json,codecs;obj=json.load(codecs.open('$config_file', 'r', 'utf-8-sig'))" >/dev/null ; then
|
||||
config_channel="$(python -c "import json,codecs;obj=json.load(codecs.open('$config_file', 'r', 'utf-8-sig'));print(obj['channel'] if 'channel' in obj else '')")"
|
||||
config_tools_source="$(python -c "import json,codecs;obj=json.load(codecs.open('$config_file', 'r', 'utf-8-sig'));print(obj['toolsSource'] if 'toolsSource' in obj else '')")"
|
||||
else
|
||||
__warn "$config_file is invalid JSON. Its settings will be ignored."
|
||||
__error "$config_file contains invalid JSON."
|
||||
exit 1
|
||||
fi
|
||||
elif __machine_has python3 ; then
|
||||
if python3 -c "import json,codecs;obj=json.load(codecs.open('$config_file', 'r', 'utf-8-sig'))" >/dev/null ; then
|
||||
config_channel="$(python3 -c "import json,codecs;obj=json.load(codecs.open('$config_file', 'r', 'utf-8-sig'));print(obj['channel'] if 'channel' in obj else '')")"
|
||||
config_tools_source="$(python3 -c "import json,codecs;obj=json.load(codecs.open('$config_file', 'r', 'utf-8-sig'));print(obj['toolsSource'] if 'toolsSource' in obj else '')")"
|
||||
else
|
||||
__error "$config_file contains invalid JSON."
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
__warn 'Missing required command: jq or pyton. Could not parse the JSON file. Its settings will be ignored.'
|
||||
__error 'Missing required command: jq or python. Could not parse the JSON file.'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
[ ! -z "${config_channel:-}" ] && channel="$config_channel"
|
||||
[ ! -z "${config_tools_source:-}" ] && tools_source="$config_tools_source"
|
||||
fi
|
||||
|
||||
[ -z "$channel" ] && channel='dev'
|
||||
[ -z "$channel" ] && channel='master'
|
||||
[ -z "$tools_source" ] && tools_source='https://aspnetcore.blob.core.windows.net/buildtools'
|
||||
|
||||
get_korebuild
|
||||
set_korebuildsettings "$tools_source" "$DOTNET_HOME" "$repo_path" "$config_file"
|
||||
set_korebuildsettings "$tools_source" "$DOTNET_HOME" "$repo_path" "$config_file" "$ci"
|
||||
invoke_korebuild_command "$command" "$@"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>netcoreapp2.1;net461</TargetFrameworks>
|
||||
<TargetFrameworks>netcoreapp3.0;net461</TargetFrameworks>
|
||||
<IsPackable>false</IsPackable>
|
||||
<OutputType>exe</OutputType>
|
||||
</PropertyGroup>
|
||||
@@ -13,6 +13,7 @@
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="$(MicrosoftExtensionsDependencyInjectionPackageVersion)" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="$(MicrosoftExtensionsLoggingConsolePackageVersion)" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>netcoreapp2.1;net461</TargetFrameworks>
|
||||
<TargetFrameworks>netcoreapp3.0;net461</TargetFrameworks>
|
||||
<TypeScriptCompileBlocked>true</TypeScriptCompileBlocked>
|
||||
<IsPackable>false</IsPackable>
|
||||
</PropertyGroup>
|
||||
@@ -18,6 +18,8 @@
|
||||
<PackageReference Include="Microsoft.AspNetCore.Server.Kestrel" Version="$(MicrosoftAspNetCoreServerKestrelPackageVersion)" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="$(MicrosoftAspNetCoreStaticFilesPackageVersion)" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="$(MicrosoftExtensionsLoggingDebugPackageVersion)" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="$(MicrosoftExtensionsLoggingConsolePackageVersion)" />
|
||||
<PackageReference Include="Microsoft.NET.Sdk.Razor" Version="$(MicrosoftNETSdkRazorPackageVersion)" PrivateAssets="All" />
|
||||
</ItemGroup>
|
||||
|
||||
<Target Name="PrepublishScript" BeforeTargets="PrepareForPublish">
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>netcoreapp2.1;net461</TargetFrameworks>
|
||||
<TargetFrameworks>netcoreapp3.0;net461</TargetFrameworks>
|
||||
<TypeScriptCompileBlocked>true</TypeScriptCompileBlocked>
|
||||
<IsPackable>false</IsPackable>
|
||||
</PropertyGroup>
|
||||
@@ -18,6 +18,8 @@
|
||||
<PackageReference Include="Microsoft.AspNetCore.Server.Kestrel" Version="$(MicrosoftAspNetCoreServerKestrelPackageVersion)" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="$(MicrosoftAspNetCoreStaticFilesPackageVersion)" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="$(MicrosoftExtensionsLoggingDebugPackageVersion)" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="$(MicrosoftExtensionsLoggingConsolePackageVersion)" />
|
||||
<PackageReference Include="Microsoft.NET.Sdk.Razor" Version="$(MicrosoftNETSdkRazorPackageVersion)" PrivateAssets="All" />
|
||||
</ItemGroup>
|
||||
|
||||
<Target Name="PrepublishScript" BeforeTargets="PrepareForPublish">
|
||||
|
||||
28
scripts/Regenerate-JSFiles.ps1
Normal file
28
scripts/Regenerate-JSFiles.ps1
Normal file
@@ -0,0 +1,28 @@
|
||||
[cmdletbinding(SupportsShouldProcess = $true)]
|
||||
param(
|
||||
)
|
||||
|
||||
$ErrorActionPreference = 'Stop'
|
||||
Set-StrictMode -Version 2
|
||||
|
||||
Push-Location "src"
|
||||
try {
|
||||
$dirs = Get-ChildItem -Directory
|
||||
foreach($dir in $dirs)
|
||||
{
|
||||
Push-Location $dir
|
||||
try{
|
||||
if(Test-Path -Path "package.json")
|
||||
{
|
||||
npm install
|
||||
npm run build
|
||||
}
|
||||
}
|
||||
finally{
|
||||
Pop-Location
|
||||
}
|
||||
}
|
||||
}
|
||||
finally {
|
||||
Pop-Location
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -27,7 +27,7 @@ export class VirtualConnection extends Duplex {
|
||||
|
||||
public _write(chunk: Buffer | string, encodingIfString: string, callback: EndWriteCallback) {
|
||||
if (typeof chunk === 'string') {
|
||||
chunk = new Buffer(chunk as string, encodingIfString);
|
||||
chunk = Buffer.from(chunk as string, encodingIfString);
|
||||
}
|
||||
|
||||
this._beginWriteCallback(chunk as Buffer, callback);
|
||||
|
||||
@@ -113,7 +113,7 @@ class VirtualConnectionsCollection {
|
||||
newVirtualConnection.on('finish', () => {
|
||||
// The virtual connection was closed locally. Clean up locally, and notify the remote that we're done.
|
||||
this._onVirtualConnectionWasClosed(header.connectionIdString);
|
||||
this._sendFrame(header.connectionIdBinary, new Buffer(0));
|
||||
this._sendFrame(header.connectionIdBinary, Buffer.alloc(0));
|
||||
});
|
||||
|
||||
this._virtualConnections[header.connectionIdString] = newVirtualConnection;
|
||||
@@ -180,7 +180,7 @@ class VirtualConnectionsCollection {
|
||||
* Sends a number serialized in the correct format for .NET to receive as a System.Int32
|
||||
*/
|
||||
private _sendInt32LE(value: number, callback?: EndWriteCallback) {
|
||||
const buf = new Buffer(4);
|
||||
const buf = Buffer.alloc(4);
|
||||
buf.writeInt32LE(value, 0);
|
||||
this._socket.write(buf, callback);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"AssemblyIdentity": "Microsoft.AspNetCore.NodeServices.Sockets, Version=2.0.3.0, Culture=neutral, PublicKeyToken=adb9793829ddae60",
|
||||
"AssemblyIdentity": "Microsoft.AspNetCore.NodeServices.Sockets, Version=2.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60",
|
||||
"Types": [
|
||||
{
|
||||
"Name": "Microsoft.AspNetCore.NodeServices.Sockets.NodeServicesOptionsExtensions",
|
||||
|
||||
4230
src/Microsoft.AspNetCore.NodeServices.Sockets/package-lock.json
generated
Normal file
4230
src/Microsoft.AspNetCore.NodeServices.Sockets/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
@@ -5,14 +5,15 @@
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1",
|
||||
"build": "./node_modules/.bin/webpack"
|
||||
"build": "webpack --mode production"
|
||||
},
|
||||
"author": "Microsoft",
|
||||
"license": "Apache-2.0",
|
||||
"devDependencies": {
|
||||
"@types/node": "^6.0.42",
|
||||
"ts-loader": "^0.8.2",
|
||||
"typescript": "^2.0.0",
|
||||
"webpack": "^1.13.1"
|
||||
"@types/node": "^10.9.2",
|
||||
"ts-loader": "^4.5.0",
|
||||
"typescript": "^3.0.1",
|
||||
"webpack": "^4.17.1",
|
||||
"webpack-cli": "^3.1.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
const path = require('path');
|
||||
|
||||
module.exports = {
|
||||
target: 'node',
|
||||
externals: ['fs', 'net', 'events', 'readline', 'stream'],
|
||||
resolve: {
|
||||
extensions: [ '.ts' ]
|
||||
},
|
||||
module: {
|
||||
loaders: [
|
||||
{ test: /\.ts$/, loader: 'ts-loader' },
|
||||
rules: [
|
||||
{ test: /\.ts$/, use: 'ts-loader' },
|
||||
]
|
||||
},
|
||||
entry: {
|
||||
@@ -14,7 +15,10 @@ module.exports = {
|
||||
},
|
||||
output: {
|
||||
libraryTarget: 'commonjs',
|
||||
path: './Content/Node',
|
||||
path: path.join(__dirname, 'Content', 'Node'),
|
||||
filename: '[name].js'
|
||||
},
|
||||
optimization: {
|
||||
minimize: false
|
||||
}
|
||||
};
|
||||
|
||||
@@ -6,7 +6,7 @@ using Microsoft.AspNetCore.NodeServices.HostingModels;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.Extensions.Logging.Console;
|
||||
using Microsoft.Extensions.Logging.Abstractions;
|
||||
|
||||
namespace Microsoft.AspNetCore.NodeServices
|
||||
{
|
||||
@@ -58,8 +58,7 @@ namespace Microsoft.AspNetCore.NodeServices
|
||||
var loggerFactory = serviceProvider.GetService<ILoggerFactory>();
|
||||
NodeInstanceOutputLogger = loggerFactory != null
|
||||
? loggerFactory.CreateLogger(LogCategoryName)
|
||||
: new ConsoleLogger(LogCategoryName, null, false);
|
||||
|
||||
: NullLogger.Instance;
|
||||
// By default, we use this package's built-in out-of-process-via-HTTP hosting/transport
|
||||
this.UseHttpHosting();
|
||||
}
|
||||
|
||||
@@ -1,361 +1,416 @@
|
||||
(function(e, a) { for(var i in a) e[i] = a[i]; }(exports, /******/ (function(modules) { // webpackBootstrap
|
||||
/******/ // The module cache
|
||||
/******/ var installedModules = {};
|
||||
|
||||
/******/
|
||||
/******/ // The require function
|
||||
/******/ function __webpack_require__(moduleId) {
|
||||
|
||||
/******/
|
||||
/******/ // Check if module is in cache
|
||||
/******/ if(installedModules[moduleId])
|
||||
/******/ if(installedModules[moduleId]) {
|
||||
/******/ return installedModules[moduleId].exports;
|
||||
|
||||
/******/ }
|
||||
/******/ // Create a new module (and put it into the cache)
|
||||
/******/ var module = installedModules[moduleId] = {
|
||||
/******/ exports: {},
|
||||
/******/ id: moduleId,
|
||||
/******/ loaded: false
|
||||
/******/ i: moduleId,
|
||||
/******/ l: false,
|
||||
/******/ exports: {}
|
||||
/******/ };
|
||||
|
||||
/******/
|
||||
/******/ // Execute the module function
|
||||
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
|
||||
|
||||
/******/
|
||||
/******/ // Flag the module as loaded
|
||||
/******/ module.loaded = true;
|
||||
|
||||
/******/ module.l = true;
|
||||
/******/
|
||||
/******/ // Return the exports of the module
|
||||
/******/ return module.exports;
|
||||
/******/ }
|
||||
|
||||
|
||||
/******/
|
||||
/******/
|
||||
/******/ // expose the modules object (__webpack_modules__)
|
||||
/******/ __webpack_require__.m = modules;
|
||||
|
||||
/******/
|
||||
/******/ // expose the module cache
|
||||
/******/ __webpack_require__.c = installedModules;
|
||||
|
||||
/******/
|
||||
/******/ // define getter function for harmony exports
|
||||
/******/ __webpack_require__.d = function(exports, name, getter) {
|
||||
/******/ if(!__webpack_require__.o(exports, name)) {
|
||||
/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
|
||||
/******/ }
|
||||
/******/ };
|
||||
/******/
|
||||
/******/ // define __esModule on exports
|
||||
/******/ __webpack_require__.r = function(exports) {
|
||||
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
|
||||
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
||||
/******/ }
|
||||
/******/ Object.defineProperty(exports, '__esModule', { value: true });
|
||||
/******/ };
|
||||
/******/
|
||||
/******/ // create a fake namespace object
|
||||
/******/ // mode & 1: value is a module id, require it
|
||||
/******/ // mode & 2: merge all properties of value into the ns
|
||||
/******/ // mode & 4: return value when already ns object
|
||||
/******/ // mode & 8|1: behave like require
|
||||
/******/ __webpack_require__.t = function(value, mode) {
|
||||
/******/ if(mode & 1) value = __webpack_require__(value);
|
||||
/******/ if(mode & 8) return value;
|
||||
/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
|
||||
/******/ var ns = Object.create(null);
|
||||
/******/ __webpack_require__.r(ns);
|
||||
/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
|
||||
/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
|
||||
/******/ return ns;
|
||||
/******/ };
|
||||
/******/
|
||||
/******/ // getDefaultExport function for compatibility with non-harmony modules
|
||||
/******/ __webpack_require__.n = function(module) {
|
||||
/******/ var getter = module && module.__esModule ?
|
||||
/******/ function getDefault() { return module['default']; } :
|
||||
/******/ function getModuleExports() { return module; };
|
||||
/******/ __webpack_require__.d(getter, 'a', getter);
|
||||
/******/ return getter;
|
||||
/******/ };
|
||||
/******/
|
||||
/******/ // Object.prototype.hasOwnProperty.call
|
||||
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
|
||||
/******/
|
||||
/******/ // __webpack_public_path__
|
||||
/******/ __webpack_require__.p = "";
|
||||
|
||||
/******/
|
||||
/******/
|
||||
/******/ // Load entry module and return exports
|
||||
/******/ return __webpack_require__(0);
|
||||
/******/ return __webpack_require__(__webpack_require__.s = 1);
|
||||
/******/ })
|
||||
/************************************************************************/
|
||||
/******/ ([
|
||||
/* 0 */
|
||||
/***/ function(module, exports, __webpack_require__) {
|
||||
/***/ (function(module, exports) {
|
||||
|
||||
module.exports = __webpack_require__(1);
|
||||
module.exports = require("path");
|
||||
|
||||
|
||||
/***/ },
|
||||
/***/ }),
|
||||
/* 1 */
|
||||
/***/ function(module, exports, __webpack_require__) {
|
||||
/***/ (function(module, exports, __webpack_require__) {
|
||||
|
||||
"use strict";
|
||||
// Limit dependencies to core Node modules. This means the code in this file has to be very low-level and unattractive,
|
||||
// but simplifies things for the consumer of this module.
|
||||
__webpack_require__(2);
|
||||
__webpack_require__(4);
|
||||
var http = __webpack_require__(5);
|
||||
var path = __webpack_require__(3);
|
||||
var ArgsUtil_1 = __webpack_require__(6);
|
||||
var ExitWhenParentExits_1 = __webpack_require__(7);
|
||||
// Webpack doesn't support dynamic requires for files not present at compile time, so grab a direct
|
||||
// reference to Node's runtime 'require' function.
|
||||
var dynamicRequire = eval('require');
|
||||
var server = http.createServer(function (req, res) {
|
||||
readRequestBodyAsJson(req, function (bodyJson) {
|
||||
var hasSentResult = false;
|
||||
var callback = function (errorValue, successValue) {
|
||||
if (!hasSentResult) {
|
||||
hasSentResult = true;
|
||||
if (errorValue) {
|
||||
respondWithError(res, errorValue);
|
||||
}
|
||||
else if (typeof successValue !== 'string') {
|
||||
// Arbitrary object/number/etc - JSON-serialize it
|
||||
var successValueJson = void 0;
|
||||
try {
|
||||
successValueJson = JSON.stringify(successValue);
|
||||
}
|
||||
catch (ex) {
|
||||
// JSON serialization error - pass it back to .NET
|
||||
respondWithError(res, ex);
|
||||
return;
|
||||
}
|
||||
res.setHeader('Content-Type', 'application/json');
|
||||
res.end(successValueJson);
|
||||
}
|
||||
else {
|
||||
// String - can bypass JSON-serialization altogether
|
||||
res.setHeader('Content-Type', 'text/plain');
|
||||
res.end(successValue);
|
||||
}
|
||||
}
|
||||
};
|
||||
// Support streamed responses
|
||||
Object.defineProperty(callback, 'stream', {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
if (!hasSentResult) {
|
||||
hasSentResult = true;
|
||||
res.setHeader('Content-Type', 'application/octet-stream');
|
||||
}
|
||||
return res;
|
||||
}
|
||||
});
|
||||
try {
|
||||
var resolvedPath = path.resolve(process.cwd(), bodyJson.moduleName);
|
||||
var invokedModule = dynamicRequire(resolvedPath);
|
||||
var func = bodyJson.exportedFunctionName ? invokedModule[bodyJson.exportedFunctionName] : invokedModule;
|
||||
if (!func) {
|
||||
throw new Error('The module "' + resolvedPath + '" has no export named "' + bodyJson.exportedFunctionName + '"');
|
||||
}
|
||||
func.apply(null, [callback].concat(bodyJson.args));
|
||||
}
|
||||
catch (synchronousException) {
|
||||
callback(synchronousException, null);
|
||||
}
|
||||
});
|
||||
});
|
||||
var parsedArgs = ArgsUtil_1.parseArgs(process.argv);
|
||||
var requestedPortOrZero = parsedArgs.port || 0; // 0 means 'let the OS decide'
|
||||
server.listen(requestedPortOrZero, 'localhost', function () {
|
||||
// Signal to HttpNodeHost which port it should make its HTTP connections on
|
||||
console.log('[Microsoft.AspNetCore.NodeServices.HttpNodeHost:Listening on port ' + server.address().port + '\]');
|
||||
// Signal to the NodeServices base class that we're ready to accept invocations
|
||||
console.log('[Microsoft.AspNetCore.NodeServices:Listening]');
|
||||
});
|
||||
ExitWhenParentExits_1.exitWhenParentExits(parseInt(parsedArgs.parentPid), /* ignoreSigint */ true);
|
||||
function readRequestBodyAsJson(request, callback) {
|
||||
var requestBodyAsString = '';
|
||||
request.on('data', function (chunk) { requestBodyAsString += chunk; });
|
||||
request.on('end', function () { callback(JSON.parse(requestBodyAsString)); });
|
||||
}
|
||||
function respondWithError(res, errorValue) {
|
||||
res.statusCode = 500;
|
||||
res.end(JSON.stringify({
|
||||
errorMessage: errorValue.message || errorValue,
|
||||
errorDetails: errorValue.stack || null
|
||||
}));
|
||||
}
|
||||
module.exports = __webpack_require__(2);
|
||||
|
||||
|
||||
/***/ },
|
||||
/***/ }),
|
||||
/* 2 */
|
||||
/***/ function(module, exports, __webpack_require__) {
|
||||
/***/ (function(module, exports, __webpack_require__) {
|
||||
|
||||
"use strict";
|
||||
var path = __webpack_require__(3);
|
||||
var startsWith = function (str, prefix) { return str.substring(0, prefix.length) === prefix; };
|
||||
var appRootDir = process.cwd();
|
||||
function patchedLStat(pathToStatLong, fsReqWrap) {
|
||||
try {
|
||||
// If the lstat completes without errors, we don't modify its behavior at all
|
||||
return origLStat.apply(this, arguments);
|
||||
}
|
||||
catch (ex) {
|
||||
var shouldOverrideError = startsWith(ex.message, 'EPERM') // It's a permissions error
|
||||
&& typeof appRootDirLong === 'string'
|
||||
&& startsWith(appRootDirLong, pathToStatLong) // ... for an ancestor directory
|
||||
&& ex.stack.indexOf('Object.realpathSync ') >= 0; // ... during symlink resolution
|
||||
if (shouldOverrideError) {
|
||||
// Fake the result to give the same result as an 'lstat' on the app root dir.
|
||||
// This stops Node failing to load modules just because it doesn't know whether
|
||||
// ancestor directories are symlinks or not. If there's a genuine file
|
||||
// permissions issue, it will still surface later when Node actually
|
||||
// tries to read the file.
|
||||
return origLStat.call(this, appRootDir, fsReqWrap);
|
||||
}
|
||||
else {
|
||||
// In any other case, preserve the original error
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
}
|
||||
;
|
||||
// It's only necessary to apply this workaround on Windows
|
||||
var appRootDirLong = null;
|
||||
var origLStat = null;
|
||||
if (/^win/.test(process.platform)) {
|
||||
try {
|
||||
// Get the app's root dir in Node's internal "long" format (e.g., \\?\C:\dir\subdir)
|
||||
appRootDirLong = path._makeLong(appRootDir);
|
||||
// Actually apply the patch, being as defensive as possible
|
||||
var bindingFs = process.binding('fs');
|
||||
origLStat = bindingFs.lstat;
|
||||
if (typeof origLStat === 'function') {
|
||||
bindingFs.lstat = patchedLStat;
|
||||
}
|
||||
}
|
||||
catch (ex) {
|
||||
}
|
||||
}
|
||||
"use strict";
|
||||
|
||||
exports.__esModule = true;
|
||||
// Limit dependencies to core Node modules. This means the code in this file has to be very low-level and unattractive,
|
||||
// but simplifies things for the consumer of this module.
|
||||
__webpack_require__(3);
|
||||
__webpack_require__(4);
|
||||
var http = __webpack_require__(5);
|
||||
var path = __webpack_require__(0);
|
||||
var ArgsUtil_1 = __webpack_require__(6);
|
||||
var ExitWhenParentExits_1 = __webpack_require__(7);
|
||||
// Webpack doesn't support dynamic requires for files not present at compile time, so grab a direct
|
||||
// reference to Node's runtime 'require' function.
|
||||
var dynamicRequire = eval('require');
|
||||
var server = http.createServer(function (req, res) {
|
||||
readRequestBodyAsJson(req, function (bodyJson) {
|
||||
var hasSentResult = false;
|
||||
var callback = function (errorValue, successValue) {
|
||||
if (!hasSentResult) {
|
||||
hasSentResult = true;
|
||||
if (errorValue) {
|
||||
respondWithError(res, errorValue);
|
||||
}
|
||||
else if (typeof successValue !== 'string') {
|
||||
// Arbitrary object/number/etc - JSON-serialize it
|
||||
var successValueJson = void 0;
|
||||
try {
|
||||
successValueJson = JSON.stringify(successValue);
|
||||
}
|
||||
catch (ex) {
|
||||
// JSON serialization error - pass it back to .NET
|
||||
respondWithError(res, ex);
|
||||
return;
|
||||
}
|
||||
res.setHeader('Content-Type', 'application/json');
|
||||
res.end(successValueJson);
|
||||
}
|
||||
else {
|
||||
// String - can bypass JSON-serialization altogether
|
||||
res.setHeader('Content-Type', 'text/plain');
|
||||
res.end(successValue);
|
||||
}
|
||||
}
|
||||
};
|
||||
// Support streamed responses
|
||||
Object.defineProperty(callback, 'stream', {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
if (!hasSentResult) {
|
||||
hasSentResult = true;
|
||||
res.setHeader('Content-Type', 'application/octet-stream');
|
||||
}
|
||||
return res;
|
||||
}
|
||||
});
|
||||
try {
|
||||
var resolvedPath = path.resolve(process.cwd(), bodyJson.moduleName);
|
||||
var invokedModule = dynamicRequire(resolvedPath);
|
||||
var func = bodyJson.exportedFunctionName ? invokedModule[bodyJson.exportedFunctionName] : invokedModule;
|
||||
if (!func) {
|
||||
throw new Error('The module "' + resolvedPath + '" has no export named "' + bodyJson.exportedFunctionName + '"');
|
||||
}
|
||||
func.apply(null, [callback].concat(bodyJson.args));
|
||||
}
|
||||
catch (synchronousException) {
|
||||
callback(synchronousException, null);
|
||||
}
|
||||
});
|
||||
});
|
||||
var parsedArgs = ArgsUtil_1.parseArgs(process.argv);
|
||||
var requestedPortOrZero = parsedArgs.port || 0; // 0 means 'let the OS decide'
|
||||
server.listen(requestedPortOrZero, 'localhost', function () {
|
||||
var addressInfo = server.address();
|
||||
// Signal to HttpNodeHost which loopback IP address (IPv4 or IPv6) and port it should make its HTTP connections on
|
||||
console.log('[Microsoft.AspNetCore.NodeServices.HttpNodeHost:Listening on {' + addressInfo.address + '} port ' + addressInfo.port + '\]');
|
||||
// Signal to the NodeServices base class that we're ready to accept invocations
|
||||
console.log('[Microsoft.AspNetCore.NodeServices:Listening]');
|
||||
});
|
||||
ExitWhenParentExits_1.exitWhenParentExits(parseInt(parsedArgs.parentPid), /* ignoreSigint */ true);
|
||||
function readRequestBodyAsJson(request, callback) {
|
||||
var requestBodyAsString = '';
|
||||
request.on('data', function (chunk) { requestBodyAsString += chunk; });
|
||||
request.on('end', function () { callback(JSON.parse(requestBodyAsString)); });
|
||||
}
|
||||
function respondWithError(res, errorValue) {
|
||||
res.statusCode = 500;
|
||||
res.end(JSON.stringify({
|
||||
errorMessage: errorValue.message || errorValue,
|
||||
errorDetails: errorValue.stack || null
|
||||
}));
|
||||
}
|
||||
|
||||
|
||||
/***/ },
|
||||
/***/ }),
|
||||
/* 3 */
|
||||
/***/ function(module, exports) {
|
||||
/***/ (function(module, exports, __webpack_require__) {
|
||||
|
||||
module.exports = require("path");
|
||||
"use strict";
|
||||
|
||||
/***/ },
|
||||
exports.__esModule = true;
|
||||
var path = __webpack_require__(0);
|
||||
var startsWith = function (str, prefix) { return str.substring(0, prefix.length) === prefix; };
|
||||
var appRootDir = process.cwd();
|
||||
function patchedLStat(pathToStatLong, fsReqWrap) {
|
||||
try {
|
||||
// If the lstat completes without errors, we don't modify its behavior at all
|
||||
return origLStat.apply(this, arguments);
|
||||
}
|
||||
catch (ex) {
|
||||
var shouldOverrideError = startsWith(ex.message, 'EPERM') // It's a permissions error
|
||||
&& typeof appRootDirLong === 'string'
|
||||
&& startsWith(appRootDirLong, pathToStatLong) // ... for an ancestor directory
|
||||
&& ex.stack.indexOf('Object.realpathSync ') >= 0; // ... during symlink resolution
|
||||
if (shouldOverrideError) {
|
||||
// Fake the result to give the same result as an 'lstat' on the app root dir.
|
||||
// This stops Node failing to load modules just because it doesn't know whether
|
||||
// ancestor directories are symlinks or not. If there's a genuine file
|
||||
// permissions issue, it will still surface later when Node actually
|
||||
// tries to read the file.
|
||||
return origLStat.call(this, appRootDir, fsReqWrap);
|
||||
}
|
||||
else {
|
||||
// In any other case, preserve the original error
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
}
|
||||
;
|
||||
// It's only necessary to apply this workaround on Windows
|
||||
var appRootDirLong = null;
|
||||
var origLStat = null;
|
||||
if (/^win/.test(process.platform)) {
|
||||
try {
|
||||
// Get the app's root dir in Node's internal "long" format (e.g., \\?\C:\dir\subdir)
|
||||
appRootDirLong = path._makeLong(appRootDir);
|
||||
// Actually apply the patch, being as defensive as possible
|
||||
var bindingFs = process.binding('fs');
|
||||
origLStat = bindingFs.lstat;
|
||||
if (typeof origLStat === 'function') {
|
||||
bindingFs.lstat = patchedLStat;
|
||||
}
|
||||
}
|
||||
catch (ex) {
|
||||
// If some future version of Node throws (e.g., to prevent use of process.binding()),
|
||||
// don't apply the patch, but still let the application run.
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/***/ }),
|
||||
/* 4 */
|
||||
/***/ function(module, exports) {
|
||||
/***/ (function(module, exports) {
|
||||
|
||||
// When Node writes to stdout/strerr, we capture that and convert the lines into calls on the
|
||||
// active .NET ILogger. But by default, stdout/stderr don't have any way of distinguishing
|
||||
// linebreaks inside log messages from the linebreaks that delimit separate log messages,
|
||||
// so multiline strings will end up being written to the ILogger as multiple independent
|
||||
// log messages. This makes them very hard to make sense of, especially when they represent
|
||||
// something like stack traces.
|
||||
//
|
||||
// To fix this, we intercept stdout/stderr writes, and replace internal linebreaks with a
|
||||
// marker token. When .NET receives the lines, it converts the marker tokens back to regular
|
||||
// linebreaks within the logged messages.
|
||||
//
|
||||
// Note that it's better to do the interception at the stdout/stderr level, rather than at
|
||||
// the console.log/console.error (etc.) level, because this takes place after any native
|
||||
// message formatting has taken place (e.g., inserting values for % placeholders).
|
||||
var findInternalNewlinesRegex = /\n(?!$)/g;
|
||||
var encodedNewline = '__ns_newline__';
|
||||
encodeNewlinesWrittenToStream(process.stdout);
|
||||
encodeNewlinesWrittenToStream(process.stderr);
|
||||
function encodeNewlinesWrittenToStream(outputStream) {
|
||||
var origWriteFunction = outputStream.write;
|
||||
outputStream.write = function (value) {
|
||||
// Only interfere with the write if it's definitely a string
|
||||
if (typeof value === 'string') {
|
||||
var argsClone = Array.prototype.slice.call(arguments, 0);
|
||||
argsClone[0] = encodeNewlinesInString(value);
|
||||
origWriteFunction.apply(this, argsClone);
|
||||
}
|
||||
else {
|
||||
origWriteFunction.apply(this, arguments);
|
||||
}
|
||||
};
|
||||
}
|
||||
function encodeNewlinesInString(str) {
|
||||
return str.replace(findInternalNewlinesRegex, encodedNewline);
|
||||
}
|
||||
// When Node writes to stdout/strerr, we capture that and convert the lines into calls on the
|
||||
// active .NET ILogger. But by default, stdout/stderr don't have any way of distinguishing
|
||||
// linebreaks inside log messages from the linebreaks that delimit separate log messages,
|
||||
// so multiline strings will end up being written to the ILogger as multiple independent
|
||||
// log messages. This makes them very hard to make sense of, especially when they represent
|
||||
// something like stack traces.
|
||||
//
|
||||
// To fix this, we intercept stdout/stderr writes, and replace internal linebreaks with a
|
||||
// marker token. When .NET receives the lines, it converts the marker tokens back to regular
|
||||
// linebreaks within the logged messages.
|
||||
//
|
||||
// Note that it's better to do the interception at the stdout/stderr level, rather than at
|
||||
// the console.log/console.error (etc.) level, because this takes place after any native
|
||||
// message formatting has taken place (e.g., inserting values for % placeholders).
|
||||
var findInternalNewlinesRegex = /\n(?!$)/g;
|
||||
var encodedNewline = '__ns_newline__';
|
||||
encodeNewlinesWrittenToStream(process.stdout);
|
||||
encodeNewlinesWrittenToStream(process.stderr);
|
||||
function encodeNewlinesWrittenToStream(outputStream) {
|
||||
var origWriteFunction = outputStream.write;
|
||||
outputStream.write = function (value) {
|
||||
// Only interfere with the write if it's definitely a string
|
||||
if (typeof value === 'string') {
|
||||
var argsClone = Array.prototype.slice.call(arguments, 0);
|
||||
argsClone[0] = encodeNewlinesInString(value);
|
||||
origWriteFunction.apply(this, argsClone);
|
||||
}
|
||||
else {
|
||||
origWriteFunction.apply(this, arguments);
|
||||
}
|
||||
};
|
||||
}
|
||||
function encodeNewlinesInString(str) {
|
||||
return str.replace(findInternalNewlinesRegex, encodedNewline);
|
||||
}
|
||||
|
||||
|
||||
/***/ },
|
||||
/***/ }),
|
||||
/* 5 */
|
||||
/***/ function(module, exports) {
|
||||
/***/ (function(module, exports) {
|
||||
|
||||
module.exports = require("http");
|
||||
module.exports = require("http");
|
||||
|
||||
/***/ },
|
||||
/***/ }),
|
||||
/* 6 */
|
||||
/***/ function(module, exports) {
|
||||
/***/ (function(module, exports, __webpack_require__) {
|
||||
|
||||
"use strict";
|
||||
function parseArgs(args) {
|
||||
// Very simplistic parsing which is sufficient for the cases needed. We don't want to bring in any external
|
||||
// dependencies (such as an args-parsing library) to this file.
|
||||
var result = {};
|
||||
var currentKey = null;
|
||||
args.forEach(function (arg) {
|
||||
if (arg.indexOf('--') === 0) {
|
||||
var argName = arg.substring(2);
|
||||
result[argName] = undefined;
|
||||
currentKey = argName;
|
||||
}
|
||||
else if (currentKey) {
|
||||
result[currentKey] = arg;
|
||||
currentKey = null;
|
||||
}
|
||||
});
|
||||
return result;
|
||||
}
|
||||
exports.parseArgs = parseArgs;
|
||||
"use strict";
|
||||
|
||||
exports.__esModule = true;
|
||||
function parseArgs(args) {
|
||||
// Very simplistic parsing which is sufficient for the cases needed. We don't want to bring in any external
|
||||
// dependencies (such as an args-parsing library) to this file.
|
||||
var result = {};
|
||||
var currentKey = null;
|
||||
args.forEach(function (arg) {
|
||||
if (arg.indexOf('--') === 0) {
|
||||
var argName = arg.substring(2);
|
||||
result[argName] = undefined;
|
||||
currentKey = argName;
|
||||
}
|
||||
else if (currentKey) {
|
||||
result[currentKey] = arg;
|
||||
currentKey = null;
|
||||
}
|
||||
});
|
||||
return result;
|
||||
}
|
||||
exports.parseArgs = parseArgs;
|
||||
|
||||
|
||||
/***/ },
|
||||
/***/ }),
|
||||
/* 7 */
|
||||
/***/ function(module, exports) {
|
||||
/***/ (function(module, exports, __webpack_require__) {
|
||||
|
||||
/*
|
||||
In general, we want the Node child processes to be terminated as soon as the parent .NET processes exit,
|
||||
because we have no further use for them. If the .NET process shuts down gracefully, it will run its
|
||||
finalizers, one of which (in OutOfProcessNodeInstance.cs) will kill its associated Node process immediately.
|
||||
"use strict";
|
||||
|
||||
But if the .NET process is terminated forcefully (e.g., on Linux/OSX with 'kill -9'), then it won't have
|
||||
any opportunity to shut down its child processes, and by default they will keep running. In this case, it's
|
||||
up to the child process to detect this has happened and terminate itself.
|
||||
/*
|
||||
In general, we want the Node child processes to be terminated as soon as the parent .NET processes exit,
|
||||
because we have no further use for them. If the .NET process shuts down gracefully, it will run its
|
||||
finalizers, one of which (in OutOfProcessNodeInstance.cs) will kill its associated Node process immediately.
|
||||
|
||||
There are many possible approaches to detecting when a parent process has exited, most of which behave
|
||||
differently between Windows and Linux/OS X:
|
||||
But if the .NET process is terminated forcefully (e.g., on Linux/OSX with 'kill -9'), then it won't have
|
||||
any opportunity to shut down its child processes, and by default they will keep running. In this case, it's
|
||||
up to the child process to detect this has happened and terminate itself.
|
||||
|
||||
- On Windows, the parent process can mark its child as being a 'job' that should auto-terminate when
|
||||
the parent does (http://stackoverflow.com/a/4657392). Not cross-platform.
|
||||
- The child Node process can get a callback when the parent disconnects (process.on('disconnect', ...)).
|
||||
But despite http://stackoverflow.com/a/16487966, no callback fires in any case I've tested (Windows / OS X).
|
||||
- The child Node process can get a callback when its stdin/stdout are disconnected, as described at
|
||||
http://stackoverflow.com/a/15693934. This works well on OS X, but calling stdout.resume() on Windows
|
||||
causes the process to terminate prematurely.
|
||||
- I don't know why, but on Windows, it's enough to invoke process.stdin.resume(). For some reason this causes
|
||||
the child Node process to exit as soon as the parent one does, but I don't see this documented anywhere.
|
||||
- You can poll to see if the parent process, or your stdin/stdout connection to it, is gone
|
||||
- You can directly pass a parent process PID to the child, and then have the child poll to see if it's
|
||||
still running (e.g., using process.kill(pid, 0), which doesn't kill it but just tests whether it exists,
|
||||
as per https://nodejs.org/api/process.html#process_process_kill_pid_signal)
|
||||
- Or, on each poll, you can try writing to process.stdout. If the parent has died, then this will throw.
|
||||
However I don't see this documented anywhere. It would be nice if you could just poll for whether or not
|
||||
process.stdout is still connected (without actually writing to it) but I haven't found any property whose
|
||||
value changes until you actually try to write to it.
|
||||
There are many possible approaches to detecting when a parent process has exited, most of which behave
|
||||
differently between Windows and Linux/OS X:
|
||||
|
||||
Of these, the only cross-platform approach that is actually documented as a valid strategy is simply polling
|
||||
to check whether the parent PID is still running. So that's what we do here.
|
||||
*/
|
||||
"use strict";
|
||||
var pollIntervalMs = 1000;
|
||||
function exitWhenParentExits(parentPid, ignoreSigint) {
|
||||
setInterval(function () {
|
||||
if (!processExists(parentPid)) {
|
||||
// Can't log anything at this point, because out stdout was connected to the parent,
|
||||
// but the parent is gone.
|
||||
process.exit();
|
||||
}
|
||||
}, pollIntervalMs);
|
||||
if (ignoreSigint) {
|
||||
// Pressing ctrl+c in the terminal sends a SIGINT to all processes in the foreground process tree.
|
||||
// By default, the Node process would then exit before the .NET process, because ASP.NET implements
|
||||
// a delayed shutdown to allow ongoing requests to complete.
|
||||
//
|
||||
// This is problematic, because if Node exits first, the CopyToAsync code in ConditionalProxyMiddleware
|
||||
// will experience a read fault, and logs a huge load of errors. Fortunately, since the Node process is
|
||||
// already set up to shut itself down if it detects the .NET process is terminated, all we have to do is
|
||||
// ignore the SIGINT. The Node process will then terminate automatically after the .NET process does.
|
||||
//
|
||||
// A better solution would be to have WebpackDevMiddleware listen for SIGINT and gracefully close any
|
||||
// ongoing EventSource connections before letting the Node process exit, independently of the .NET
|
||||
// process exiting. However, doing this well in general is very nontrivial (see all the discussion at
|
||||
// https://github.com/nodejs/node/issues/2642).
|
||||
process.on('SIGINT', function () {
|
||||
console.log('Received SIGINT. Waiting for .NET process to exit...');
|
||||
});
|
||||
}
|
||||
}
|
||||
exports.exitWhenParentExits = exitWhenParentExits;
|
||||
function processExists(pid) {
|
||||
try {
|
||||
// Sending signal 0 - on all platforms - tests whether the process exists. As long as it doesn't
|
||||
// throw, that means it does exist.
|
||||
process.kill(pid, 0);
|
||||
return true;
|
||||
}
|
||||
catch (ex) {
|
||||
// If the reason for the error is that we don't have permission to ask about this process,
|
||||
// report that as a separate problem.
|
||||
if (ex.code === 'EPERM') {
|
||||
throw new Error("Attempted to check whether process " + pid + " was running, but got a permissions error.");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
- On Windows, the parent process can mark its child as being a 'job' that should auto-terminate when
|
||||
the parent does (http://stackoverflow.com/a/4657392). Not cross-platform.
|
||||
- The child Node process can get a callback when the parent disconnects (process.on('disconnect', ...)).
|
||||
But despite http://stackoverflow.com/a/16487966, no callback fires in any case I've tested (Windows / OS X).
|
||||
- The child Node process can get a callback when its stdin/stdout are disconnected, as described at
|
||||
http://stackoverflow.com/a/15693934. This works well on OS X, but calling stdout.resume() on Windows
|
||||
causes the process to terminate prematurely.
|
||||
- I don't know why, but on Windows, it's enough to invoke process.stdin.resume(). For some reason this causes
|
||||
the child Node process to exit as soon as the parent one does, but I don't see this documented anywhere.
|
||||
- You can poll to see if the parent process, or your stdin/stdout connection to it, is gone
|
||||
- You can directly pass a parent process PID to the child, and then have the child poll to see if it's
|
||||
still running (e.g., using process.kill(pid, 0), which doesn't kill it but just tests whether it exists,
|
||||
as per https://nodejs.org/api/process.html#process_process_kill_pid_signal)
|
||||
- Or, on each poll, you can try writing to process.stdout. If the parent has died, then this will throw.
|
||||
However I don't see this documented anywhere. It would be nice if you could just poll for whether or not
|
||||
process.stdout is still connected (without actually writing to it) but I haven't found any property whose
|
||||
value changes until you actually try to write to it.
|
||||
|
||||
Of these, the only cross-platform approach that is actually documented as a valid strategy is simply polling
|
||||
to check whether the parent PID is still running. So that's what we do here.
|
||||
*/
|
||||
exports.__esModule = true;
|
||||
var pollIntervalMs = 1000;
|
||||
function exitWhenParentExits(parentPid, ignoreSigint) {
|
||||
setInterval(function () {
|
||||
if (!processExists(parentPid)) {
|
||||
// Can't log anything at this point, because out stdout was connected to the parent,
|
||||
// but the parent is gone.
|
||||
process.exit();
|
||||
}
|
||||
}, pollIntervalMs);
|
||||
if (ignoreSigint) {
|
||||
// Pressing ctrl+c in the terminal sends a SIGINT to all processes in the foreground process tree.
|
||||
// By default, the Node process would then exit before the .NET process, because ASP.NET implements
|
||||
// a delayed shutdown to allow ongoing requests to complete.
|
||||
//
|
||||
// This is problematic, because if Node exits first, the CopyToAsync code in ConditionalProxyMiddleware
|
||||
// will experience a read fault, and logs a huge load of errors. Fortunately, since the Node process is
|
||||
// already set up to shut itself down if it detects the .NET process is terminated, all we have to do is
|
||||
// ignore the SIGINT. The Node process will then terminate automatically after the .NET process does.
|
||||
//
|
||||
// A better solution would be to have WebpackDevMiddleware listen for SIGINT and gracefully close any
|
||||
// ongoing EventSource connections before letting the Node process exit, independently of the .NET
|
||||
// process exiting. However, doing this well in general is very nontrivial (see all the discussion at
|
||||
// https://github.com/nodejs/node/issues/2642).
|
||||
process.on('SIGINT', function () {
|
||||
console.log('Received SIGINT. Waiting for .NET process to exit...');
|
||||
});
|
||||
}
|
||||
}
|
||||
exports.exitWhenParentExits = exitWhenParentExits;
|
||||
function processExists(pid) {
|
||||
try {
|
||||
// Sending signal 0 - on all platforms - tests whether the process exists. As long as it doesn't
|
||||
// throw, that means it does exist.
|
||||
process.kill(pid, 0);
|
||||
return true;
|
||||
}
|
||||
catch (ex) {
|
||||
// If the reason for the error is that we don't have permission to ask about this process,
|
||||
// report that as a separate problem.
|
||||
if (ex.code === 'EPERM') {
|
||||
throw new Error("Attempted to check whether process " + pid + " was running, but got a permissions error.");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/***/ }
|
||||
/***/ })
|
||||
/******/ ])));
|
||||
@@ -21,8 +21,8 @@ namespace Microsoft.AspNetCore.NodeServices.HostingModels
|
||||
/// <seealso cref="Microsoft.AspNetCore.NodeServices.HostingModels.OutOfProcessNodeInstance" />
|
||||
internal class HttpNodeInstance : OutOfProcessNodeInstance
|
||||
{
|
||||
private static readonly Regex PortMessageRegex =
|
||||
new Regex(@"^\[Microsoft.AspNetCore.NodeServices.HttpNodeHost:Listening on port (\d+)\]$");
|
||||
private static readonly Regex EndpointMessageRegex =
|
||||
new Regex(@"^\[Microsoft.AspNetCore.NodeServices.HttpNodeHost:Listening on {(.*?)} port (\d+)\]$");
|
||||
|
||||
private static readonly JsonSerializerSettings jsonSerializerSettings = new JsonSerializerSettings
|
||||
{
|
||||
@@ -32,7 +32,7 @@ namespace Microsoft.AspNetCore.NodeServices.HostingModels
|
||||
|
||||
private readonly HttpClient _client;
|
||||
private bool _disposed;
|
||||
private int _portNumber;
|
||||
private string _endpoint;
|
||||
|
||||
public HttpNodeInstance(NodeServicesOptions options, int port = 0)
|
||||
: base(
|
||||
@@ -63,7 +63,7 @@ namespace Microsoft.AspNetCore.NodeServices.HostingModels
|
||||
{
|
||||
var payloadJson = JsonConvert.SerializeObject(invocationInfo, jsonSerializerSettings);
|
||||
var payload = new StringContent(payloadJson, Encoding.UTF8, "application/json");
|
||||
var response = await _client.PostAsync("http://localhost:" + _portNumber, payload, cancellationToken);
|
||||
var response = await _client.PostAsync(_endpoint, payload, cancellationToken);
|
||||
|
||||
if (!response.IsSuccessStatusCode)
|
||||
{
|
||||
@@ -111,13 +111,19 @@ namespace Microsoft.AspNetCore.NodeServices.HostingModels
|
||||
|
||||
protected override void OnOutputDataReceived(string outputData)
|
||||
{
|
||||
// Watch for "port selected" messages, and when observed, store the port number
|
||||
// Watch for "port selected" messages, and when observed,
|
||||
// store the IP (IPv4/IPv6) and port number
|
||||
// so we can use it when making HTTP requests. The child process will always send
|
||||
// one of these messages before it sends a "ready for connections" message.
|
||||
var match = _portNumber != 0 ? null : PortMessageRegex.Match(outputData);
|
||||
var match = string.IsNullOrEmpty(_endpoint) ? EndpointMessageRegex.Match(outputData) : null;
|
||||
if (match != null && match.Success)
|
||||
{
|
||||
_portNumber = int.Parse(match.Groups[1].Captures[0].Value);
|
||||
var port = int.Parse(match.Groups[2].Captures[0].Value);
|
||||
var resolvedIpAddress = match.Groups[1].Captures[0].Value;
|
||||
|
||||
//IPv6 must be wrapped with [] brackets
|
||||
resolvedIpAddress = resolvedIpAddress == "::1" ? $"[{resolvedIpAddress}]" : resolvedIpAddress;
|
||||
_endpoint = $"http://{resolvedIpAddress}:{port}";
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.AspNetCore.Hosting.Abstractions" Version="$(MicrosoftAspNetCoreHostingAbstractionsPackageVersion)" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="$(MicrosoftExtensionsLoggingConsolePackageVersion)" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="$(MicrosoftExtensionsLoggingAbstractionsPackageVersion)" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="$(NewtonsoftJsonPackageVersion)" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
@@ -9,8 +9,7 @@ This NuGet package provides a fast and robust way to invoke Node.js code from a
|
||||
|
||||
It is the underlying mechanism supporting the following packages:
|
||||
|
||||
* [`Microsoft.AspNetCore.SpaServices`](https://github.com/aspnet/JavaScriptServices/tree/dev/src/Microsoft.AspNetCore.SpaServices) - builds on NodeServices, adding functionality commonly used in Single Page Applications, such as server-side prerendering, webpack middleware, and integration between server-side and client-side routing.
|
||||
* [`Microsoft.AspNetCore.AngularServices`](https://github.com/aspnet/JavaScriptServices/tree/dev/src/Microsoft.AspNetCore.AngularServices) and [`Microsoft.AspNetCore.ReactServices`](https://github.com/aspnet/JavaScriptServices/tree/dev/src/Microsoft.AspNetCore.ReactServices) - these build on `SpaServices`, adding helpers specific to Angular and React, such as cache priming and integrating server-side and client-side validation
|
||||
* [`Microsoft.AspNetCore.SpaServices`](https://github.com/aspnet/JavaScriptServices/tree/master/src/Microsoft.AspNetCore.SpaServices) - builds on NodeServices, adding functionality commonly used in Single Page Applications, such as server-side prerendering, webpack middleware, and integration between server-side and client-side routing.
|
||||
|
||||
### Requirements
|
||||
|
||||
@@ -37,7 +36,7 @@ For .NET Framework apps:
|
||||
In that case, you don't need to use NodeServices directly (or install it manually). You can either:
|
||||
|
||||
* **Recommended:** Use the `aspnetcore-spa` Yeoman generator to get a ready-to-go starting point using your choice of client-side framework. [Instructions here.](http://blog.stevensanderson.com/2016/05/02/angular2-react-knockout-apps-on-aspnet-core/)
|
||||
* Or set up your ASP.NET Core and client-side Angular/React/KO/etc. app manually, and then use the [`Microsoft.AspNetCore.SpaServices`](https://github.com/aspnet/JavaScriptServices/tree/dev/src/Microsoft.AspNetCore.SpaServices) package to add features like server-side prerendering or Webpack middleware. But really, at least try using the `aspnetcore-spa` generator first.
|
||||
* Or set up your ASP.NET Core and client-side Angular/React/KO/etc. app manually, and then use the [`Microsoft.AspNetCore.SpaServices`](https://github.com/aspnet/JavaScriptServices/tree/master/src/Microsoft.AspNetCore.SpaServices) package to add features like server-side prerendering or Webpack middleware. But really, at least try using the `aspnetcore-spa` generator first.
|
||||
|
||||
# Simple usage example
|
||||
|
||||
@@ -256,7 +255,7 @@ module.exports = function(result, physicalPath, maxWidth, maxHeight) {
|
||||
}
|
||||
```
|
||||
|
||||
There's a working image resizing example following this approach [here](https://github.com/aspnet/JavaScriptServices/tree/dev/samples/misc/NodeServicesExamples) - see the [C# code](https://github.com/aspnet/JavaScriptServices/blob/dev/samples/misc/NodeServicesExamples/Controllers/ResizeImage.cs) and the [JavaScript code](https://github.com/aspnet/JavaScriptServices/blob/dev/samples/misc/NodeServicesExamples/Node/resizeImage.js).
|
||||
There's a working image resizing example following this approach [here](../../samples/misc/NodeServicesExamples) - see the [C# code](../../samples/misc/NodeServicesExamples/Controllers/ResizeImage.cs) and the [JavaScript code](../../samples/misc/NodeServicesExamples/Node/resizeImage.js).
|
||||
|
||||
**Parameters**
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ import * as http from 'http';
|
||||
import * as path from 'path';
|
||||
import { parseArgs } from './Util/ArgsUtil';
|
||||
import { exitWhenParentExits } from './Util/ExitWhenParentExits';
|
||||
import { AddressInfo } from 'net';
|
||||
|
||||
// Webpack doesn't support dynamic requires for files not present at compile time, so grab a direct
|
||||
// reference to Node's runtime 'require' function.
|
||||
@@ -70,8 +71,10 @@ const server = http.createServer((req, res) => {
|
||||
const parsedArgs = parseArgs(process.argv);
|
||||
const requestedPortOrZero = parsedArgs.port || 0; // 0 means 'let the OS decide'
|
||||
server.listen(requestedPortOrZero, 'localhost', function () {
|
||||
// Signal to HttpNodeHost which port it should make its HTTP connections on
|
||||
console.log('[Microsoft.AspNetCore.NodeServices.HttpNodeHost:Listening on port ' + server.address().port + '\]');
|
||||
const addressInfo = server.address() as AddressInfo;
|
||||
|
||||
// Signal to HttpNodeHost which loopback IP address (IPv4 or IPv6) and port it should make its HTTP connections on
|
||||
console.log('[Microsoft.AspNetCore.NodeServices.HttpNodeHost:Listening on {' + addressInfo.address + '} port ' + addressInfo.port + '\]');
|
||||
|
||||
// Signal to the NodeServices base class that we're ready to accept invocations
|
||||
console.log('[Microsoft.AspNetCore.NodeServices:Listening]');
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"AssemblyIdentity": "Microsoft.AspNetCore.NodeServices, Version=2.0.3.0, Culture=neutral, PublicKeyToken=adb9793829ddae60",
|
||||
"AssemblyIdentity": "Microsoft.AspNetCore.NodeServices, Version=2.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60",
|
||||
"Types": [
|
||||
{
|
||||
"Name": "Microsoft.Extensions.DependencyInjection.NodeServicesServiceCollectionExtensions",
|
||||
@@ -714,6 +714,17 @@
|
||||
"Microsoft.AspNetCore.NodeServices.HostingModels.INodeInstance"
|
||||
],
|
||||
"Members": [
|
||||
{
|
||||
"Kind": "Method",
|
||||
"Name": "Dispose",
|
||||
"Parameters": [],
|
||||
"ReturnType": "System.Void",
|
||||
"Sealed": true,
|
||||
"Virtual": true,
|
||||
"ImplementedInterface": "System.IDisposable",
|
||||
"Visibility": "Public",
|
||||
"GenericParameter": []
|
||||
},
|
||||
{
|
||||
"Kind": "Method",
|
||||
"Name": "InvokeExportAsync<T0>",
|
||||
@@ -749,17 +760,6 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"Kind": "Method",
|
||||
"Name": "Dispose",
|
||||
"Parameters": [],
|
||||
"ReturnType": "System.Void",
|
||||
"Sealed": true,
|
||||
"Virtual": true,
|
||||
"ImplementedInterface": "System.IDisposable",
|
||||
"Visibility": "Public",
|
||||
"GenericParameter": []
|
||||
},
|
||||
{
|
||||
"Kind": "Method",
|
||||
"Name": "InvokeExportAsync<T0>",
|
||||
|
||||
4230
src/Microsoft.AspNetCore.NodeServices/package-lock.json
generated
Normal file
4230
src/Microsoft.AspNetCore.NodeServices/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
@@ -5,14 +5,15 @@
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1",
|
||||
"build": "./node_modules/.bin/webpack"
|
||||
"build": "webpack --mode production"
|
||||
},
|
||||
"author": "Microsoft",
|
||||
"license": "Apache-2.0",
|
||||
"devDependencies": {
|
||||
"@types/node": "^6.0.42",
|
||||
"ts-loader": "^0.8.2",
|
||||
"typescript": "^2.0.0",
|
||||
"webpack": "^1.13.1"
|
||||
"@types/node": "^10.9.2",
|
||||
"ts-loader": "^4.5.0",
|
||||
"typescript": "^3.0.1",
|
||||
"webpack": "^4.17.1",
|
||||
"webpack-cli": "^3.1.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
const path = require('path');
|
||||
|
||||
module.exports = {
|
||||
target: 'node',
|
||||
externals: ['fs', 'net', 'events', 'readline', 'stream'],
|
||||
resolve: {
|
||||
extensions: [ '.ts' ]
|
||||
},
|
||||
module: {
|
||||
loaders: [
|
||||
{ test: /\.ts$/, loader: 'ts-loader' },
|
||||
rules: [
|
||||
{ test: /\.ts$/, use: 'ts-loader' },
|
||||
]
|
||||
},
|
||||
entry: {
|
||||
@@ -14,7 +15,10 @@ module.exports = {
|
||||
},
|
||||
output: {
|
||||
libraryTarget: 'commonjs',
|
||||
path: './Content/Node',
|
||||
path: path.join(__dirname, 'Content', 'Node'),
|
||||
filename: '[name].js'
|
||||
},
|
||||
optimization: {
|
||||
minimize: false
|
||||
}
|
||||
};
|
||||
|
||||
@@ -105,6 +105,7 @@ namespace Microsoft.AspNetCore.SpaServices.AngularCli
|
||||
// connection then it's not ready. We keep trying forever because this is dev-mode
|
||||
// only, and only a single startup attempt will be made, and there's a further level
|
||||
// of timeouts enforced on a per-request basis.
|
||||
var timeoutMilliseconds = 1000;
|
||||
using (var client = new HttpClient())
|
||||
{
|
||||
while (true)
|
||||
@@ -114,12 +115,23 @@ namespace Microsoft.AspNetCore.SpaServices.AngularCli
|
||||
// If we get any HTTP response, the CLI server is ready
|
||||
await client.SendAsync(
|
||||
new HttpRequestMessage(HttpMethod.Head, cliServerUri),
|
||||
new CancellationTokenSource(1000).Token);
|
||||
new CancellationTokenSource(timeoutMilliseconds).Token);
|
||||
return;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
await Task.Delay(1000); // 1 second
|
||||
await Task.Delay(500);
|
||||
|
||||
// Depending on the host's networking configuration, the requests can take a while
|
||||
// to go through, most likely due to the time spent resolving 'localhost'.
|
||||
// Each time we have a failure, allow a bit longer next time (up to a maximum).
|
||||
// This only influences the time until we regard the dev server as 'ready', so it
|
||||
// doesn't affect the runtime perf (even in dev mode) once the first connection is made.
|
||||
// Resolves https://github.com/aspnet/JavaScriptServices/issues/1611
|
||||
if (timeoutMilliseconds < 10000)
|
||||
{
|
||||
timeoutMilliseconds += 3000;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.Logging.Console;
|
||||
using Microsoft.Extensions.Logging.Abstractions;
|
||||
|
||||
namespace Microsoft.AspNetCore.SpaServices.Util
|
||||
{
|
||||
@@ -14,11 +14,11 @@ namespace Microsoft.AspNetCore.SpaServices.Util
|
||||
IApplicationBuilder appBuilder,
|
||||
string logCategoryName)
|
||||
{
|
||||
// If the DI system gives us a logger, use it. Otherwise, set up a default one.
|
||||
// If the DI system gives us a logger, use it. Otherwise, set up a default one
|
||||
var loggerFactory = appBuilder.ApplicationServices.GetService<ILoggerFactory>();
|
||||
var logger = loggerFactory != null
|
||||
? loggerFactory.CreateLogger(logCategoryName)
|
||||
: new ConsoleLogger(logCategoryName, null, false);
|
||||
: NullLogger.Instance;
|
||||
return logger;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,825 @@
|
||||
{
|
||||
"AssemblyIdentity": "Microsoft.AspNetCore.SpaServices.Extensions, Version=2.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60",
|
||||
"Types": [
|
||||
{
|
||||
"Name": "Microsoft.Extensions.DependencyInjection.SpaStaticFilesExtensions",
|
||||
"Visibility": "Public",
|
||||
"Kind": "Class",
|
||||
"Abstract": true,
|
||||
"Static": true,
|
||||
"Sealed": true,
|
||||
"ImplementedInterfaces": [],
|
||||
"Members": [
|
||||
{
|
||||
"Kind": "Method",
|
||||
"Name": "AddSpaStaticFiles",
|
||||
"Parameters": [
|
||||
{
|
||||
"Name": "services",
|
||||
"Type": "Microsoft.Extensions.DependencyInjection.IServiceCollection"
|
||||
},
|
||||
{
|
||||
"Name": "configuration",
|
||||
"Type": "System.Action<Microsoft.AspNetCore.SpaServices.StaticFiles.SpaStaticFilesOptions>",
|
||||
"DefaultValue": "null"
|
||||
}
|
||||
],
|
||||
"ReturnType": "System.Void",
|
||||
"Static": true,
|
||||
"Extension": true,
|
||||
"Visibility": "Public",
|
||||
"GenericParameter": []
|
||||
},
|
||||
{
|
||||
"Kind": "Method",
|
||||
"Name": "UseSpaStaticFiles",
|
||||
"Parameters": [
|
||||
{
|
||||
"Name": "applicationBuilder",
|
||||
"Type": "Microsoft.AspNetCore.Builder.IApplicationBuilder"
|
||||
}
|
||||
],
|
||||
"ReturnType": "System.Void",
|
||||
"Static": true,
|
||||
"Extension": true,
|
||||
"Visibility": "Public",
|
||||
"GenericParameter": []
|
||||
},
|
||||
{
|
||||
"Kind": "Method",
|
||||
"Name": "UseSpaStaticFiles",
|
||||
"Parameters": [
|
||||
{
|
||||
"Name": "applicationBuilder",
|
||||
"Type": "Microsoft.AspNetCore.Builder.IApplicationBuilder"
|
||||
},
|
||||
{
|
||||
"Name": "options",
|
||||
"Type": "Microsoft.AspNetCore.Builder.StaticFileOptions"
|
||||
}
|
||||
],
|
||||
"ReturnType": "System.Void",
|
||||
"Static": true,
|
||||
"Extension": true,
|
||||
"Visibility": "Public",
|
||||
"GenericParameter": []
|
||||
}
|
||||
],
|
||||
"GenericParameters": []
|
||||
},
|
||||
{
|
||||
"Name": "Microsoft.AspNetCore.Builder.SpaPrerenderingExtensions",
|
||||
"Visibility": "Public",
|
||||
"Kind": "Class",
|
||||
"Abstract": true,
|
||||
"Static": true,
|
||||
"Sealed": true,
|
||||
"ImplementedInterfaces": [],
|
||||
"Members": [
|
||||
{
|
||||
"Kind": "Method",
|
||||
"Name": "UseSpaPrerendering",
|
||||
"Parameters": [
|
||||
{
|
||||
"Name": "spaBuilder",
|
||||
"Type": "Microsoft.AspNetCore.SpaServices.ISpaBuilder"
|
||||
},
|
||||
{
|
||||
"Name": "configuration",
|
||||
"Type": "System.Action<Microsoft.AspNetCore.Builder.SpaPrerenderingOptions>"
|
||||
}
|
||||
],
|
||||
"ReturnType": "System.Void",
|
||||
"Static": true,
|
||||
"Extension": true,
|
||||
"Visibility": "Public",
|
||||
"GenericParameter": []
|
||||
}
|
||||
],
|
||||
"GenericParameters": []
|
||||
},
|
||||
{
|
||||
"Name": "Microsoft.AspNetCore.Builder.SpaPrerenderingOptions",
|
||||
"Visibility": "Public",
|
||||
"Kind": "Class",
|
||||
"ImplementedInterfaces": [],
|
||||
"Members": [
|
||||
{
|
||||
"Kind": "Method",
|
||||
"Name": "get_BootModuleBuilder",
|
||||
"Parameters": [],
|
||||
"ReturnType": "Microsoft.AspNetCore.SpaServices.Prerendering.ISpaPrerendererBuilder",
|
||||
"Visibility": "Public",
|
||||
"GenericParameter": []
|
||||
},
|
||||
{
|
||||
"Kind": "Method",
|
||||
"Name": "set_BootModuleBuilder",
|
||||
"Parameters": [
|
||||
{
|
||||
"Name": "value",
|
||||
"Type": "Microsoft.AspNetCore.SpaServices.Prerendering.ISpaPrerendererBuilder"
|
||||
}
|
||||
],
|
||||
"ReturnType": "System.Void",
|
||||
"Visibility": "Public",
|
||||
"GenericParameter": []
|
||||
},
|
||||
{
|
||||
"Kind": "Method",
|
||||
"Name": "get_BootModulePath",
|
||||
"Parameters": [],
|
||||
"ReturnType": "System.String",
|
||||
"Visibility": "Public",
|
||||
"GenericParameter": []
|
||||
},
|
||||
{
|
||||
"Kind": "Method",
|
||||
"Name": "set_BootModulePath",
|
||||
"Parameters": [
|
||||
{
|
||||
"Name": "value",
|
||||
"Type": "System.String"
|
||||
}
|
||||
],
|
||||
"ReturnType": "System.Void",
|
||||
"Visibility": "Public",
|
||||
"GenericParameter": []
|
||||
},
|
||||
{
|
||||
"Kind": "Method",
|
||||
"Name": "get_ExcludeUrls",
|
||||
"Parameters": [],
|
||||
"ReturnType": "System.String[]",
|
||||
"Visibility": "Public",
|
||||
"GenericParameter": []
|
||||
},
|
||||
{
|
||||
"Kind": "Method",
|
||||
"Name": "set_ExcludeUrls",
|
||||
"Parameters": [
|
||||
{
|
||||
"Name": "value",
|
||||
"Type": "System.String[]"
|
||||
}
|
||||
],
|
||||
"ReturnType": "System.Void",
|
||||
"Visibility": "Public",
|
||||
"GenericParameter": []
|
||||
},
|
||||
{
|
||||
"Kind": "Method",
|
||||
"Name": "get_SupplyData",
|
||||
"Parameters": [],
|
||||
"ReturnType": "System.Action<Microsoft.AspNetCore.Http.HttpContext, System.Collections.Generic.IDictionary<System.String, System.Object>>",
|
||||
"Visibility": "Public",
|
||||
"GenericParameter": []
|
||||
},
|
||||
{
|
||||
"Kind": "Method",
|
||||
"Name": "set_SupplyData",
|
||||
"Parameters": [
|
||||
{
|
||||
"Name": "value",
|
||||
"Type": "System.Action<Microsoft.AspNetCore.Http.HttpContext, System.Collections.Generic.IDictionary<System.String, System.Object>>"
|
||||
}
|
||||
],
|
||||
"ReturnType": "System.Void",
|
||||
"Visibility": "Public",
|
||||
"GenericParameter": []
|
||||
},
|
||||
{
|
||||
"Kind": "Constructor",
|
||||
"Name": ".ctor",
|
||||
"Parameters": [],
|
||||
"Visibility": "Public",
|
||||
"GenericParameter": []
|
||||
}
|
||||
],
|
||||
"GenericParameters": []
|
||||
},
|
||||
{
|
||||
"Name": "Microsoft.AspNetCore.Builder.SpaProxyingExtensions",
|
||||
"Visibility": "Public",
|
||||
"Kind": "Class",
|
||||
"Abstract": true,
|
||||
"Static": true,
|
||||
"Sealed": true,
|
||||
"ImplementedInterfaces": [],
|
||||
"Members": [
|
||||
{
|
||||
"Kind": "Method",
|
||||
"Name": "UseProxyToSpaDevelopmentServer",
|
||||
"Parameters": [
|
||||
{
|
||||
"Name": "spaBuilder",
|
||||
"Type": "Microsoft.AspNetCore.SpaServices.ISpaBuilder"
|
||||
},
|
||||
{
|
||||
"Name": "baseUri",
|
||||
"Type": "System.String"
|
||||
}
|
||||
],
|
||||
"ReturnType": "System.Void",
|
||||
"Static": true,
|
||||
"Extension": true,
|
||||
"Visibility": "Public",
|
||||
"GenericParameter": []
|
||||
},
|
||||
{
|
||||
"Kind": "Method",
|
||||
"Name": "UseProxyToSpaDevelopmentServer",
|
||||
"Parameters": [
|
||||
{
|
||||
"Name": "spaBuilder",
|
||||
"Type": "Microsoft.AspNetCore.SpaServices.ISpaBuilder"
|
||||
},
|
||||
{
|
||||
"Name": "baseUri",
|
||||
"Type": "System.Uri"
|
||||
}
|
||||
],
|
||||
"ReturnType": "System.Void",
|
||||
"Static": true,
|
||||
"Extension": true,
|
||||
"Visibility": "Public",
|
||||
"GenericParameter": []
|
||||
},
|
||||
{
|
||||
"Kind": "Method",
|
||||
"Name": "UseProxyToSpaDevelopmentServer",
|
||||
"Parameters": [
|
||||
{
|
||||
"Name": "spaBuilder",
|
||||
"Type": "Microsoft.AspNetCore.SpaServices.ISpaBuilder"
|
||||
},
|
||||
{
|
||||
"Name": "baseUriTaskFactory",
|
||||
"Type": "System.Func<System.Threading.Tasks.Task<System.Uri>>"
|
||||
}
|
||||
],
|
||||
"ReturnType": "System.Void",
|
||||
"Static": true,
|
||||
"Extension": true,
|
||||
"Visibility": "Public",
|
||||
"GenericParameter": []
|
||||
}
|
||||
],
|
||||
"GenericParameters": []
|
||||
},
|
||||
{
|
||||
"Name": "Microsoft.AspNetCore.Builder.SpaApplicationBuilderExtensions",
|
||||
"Visibility": "Public",
|
||||
"Kind": "Class",
|
||||
"Abstract": true,
|
||||
"Static": true,
|
||||
"Sealed": true,
|
||||
"ImplementedInterfaces": [],
|
||||
"Members": [
|
||||
{
|
||||
"Kind": "Method",
|
||||
"Name": "UseSpa",
|
||||
"Parameters": [
|
||||
{
|
||||
"Name": "app",
|
||||
"Type": "Microsoft.AspNetCore.Builder.IApplicationBuilder"
|
||||
},
|
||||
{
|
||||
"Name": "configuration",
|
||||
"Type": "System.Action<Microsoft.AspNetCore.SpaServices.ISpaBuilder>"
|
||||
}
|
||||
],
|
||||
"ReturnType": "System.Void",
|
||||
"Static": true,
|
||||
"Extension": true,
|
||||
"Visibility": "Public",
|
||||
"GenericParameter": []
|
||||
}
|
||||
],
|
||||
"GenericParameters": []
|
||||
},
|
||||
{
|
||||
"Name": "Microsoft.AspNetCore.SpaServices.ISpaBuilder",
|
||||
"Visibility": "Public",
|
||||
"Kind": "Interface",
|
||||
"Abstract": true,
|
||||
"ImplementedInterfaces": [],
|
||||
"Members": [
|
||||
{
|
||||
"Kind": "Method",
|
||||
"Name": "get_ApplicationBuilder",
|
||||
"Parameters": [],
|
||||
"ReturnType": "Microsoft.AspNetCore.Builder.IApplicationBuilder",
|
||||
"GenericParameter": []
|
||||
},
|
||||
{
|
||||
"Kind": "Method",
|
||||
"Name": "get_Options",
|
||||
"Parameters": [],
|
||||
"ReturnType": "Microsoft.AspNetCore.SpaServices.SpaOptions",
|
||||
"GenericParameter": []
|
||||
}
|
||||
],
|
||||
"GenericParameters": []
|
||||
},
|
||||
{
|
||||
"Name": "Microsoft.AspNetCore.SpaServices.SpaOptions",
|
||||
"Visibility": "Public",
|
||||
"Kind": "Class",
|
||||
"ImplementedInterfaces": [],
|
||||
"Members": [
|
||||
{
|
||||
"Kind": "Method",
|
||||
"Name": "get_DefaultPage",
|
||||
"Parameters": [],
|
||||
"ReturnType": "Microsoft.AspNetCore.Http.PathString",
|
||||
"Visibility": "Public",
|
||||
"GenericParameter": []
|
||||
},
|
||||
{
|
||||
"Kind": "Method",
|
||||
"Name": "set_DefaultPage",
|
||||
"Parameters": [
|
||||
{
|
||||
"Name": "value",
|
||||
"Type": "Microsoft.AspNetCore.Http.PathString"
|
||||
}
|
||||
],
|
||||
"ReturnType": "System.Void",
|
||||
"Visibility": "Public",
|
||||
"GenericParameter": []
|
||||
},
|
||||
{
|
||||
"Kind": "Method",
|
||||
"Name": "get_DefaultPageStaticFileOptions",
|
||||
"Parameters": [],
|
||||
"ReturnType": "Microsoft.AspNetCore.Builder.StaticFileOptions",
|
||||
"Visibility": "Public",
|
||||
"GenericParameter": []
|
||||
},
|
||||
{
|
||||
"Kind": "Method",
|
||||
"Name": "set_DefaultPageStaticFileOptions",
|
||||
"Parameters": [
|
||||
{
|
||||
"Name": "value",
|
||||
"Type": "Microsoft.AspNetCore.Builder.StaticFileOptions"
|
||||
}
|
||||
],
|
||||
"ReturnType": "System.Void",
|
||||
"Visibility": "Public",
|
||||
"GenericParameter": []
|
||||
},
|
||||
{
|
||||
"Kind": "Method",
|
||||
"Name": "get_SourcePath",
|
||||
"Parameters": [],
|
||||
"ReturnType": "System.String",
|
||||
"Visibility": "Public",
|
||||
"GenericParameter": []
|
||||
},
|
||||
{
|
||||
"Kind": "Method",
|
||||
"Name": "set_SourcePath",
|
||||
"Parameters": [
|
||||
{
|
||||
"Name": "value",
|
||||
"Type": "System.String"
|
||||
}
|
||||
],
|
||||
"ReturnType": "System.Void",
|
||||
"Visibility": "Public",
|
||||
"GenericParameter": []
|
||||
},
|
||||
{
|
||||
"Kind": "Method",
|
||||
"Name": "get_StartupTimeout",
|
||||
"Parameters": [],
|
||||
"ReturnType": "System.TimeSpan",
|
||||
"Visibility": "Public",
|
||||
"GenericParameter": []
|
||||
},
|
||||
{
|
||||
"Kind": "Method",
|
||||
"Name": "set_StartupTimeout",
|
||||
"Parameters": [
|
||||
{
|
||||
"Name": "value",
|
||||
"Type": "System.TimeSpan"
|
||||
}
|
||||
],
|
||||
"ReturnType": "System.Void",
|
||||
"Visibility": "Public",
|
||||
"GenericParameter": []
|
||||
},
|
||||
{
|
||||
"Kind": "Constructor",
|
||||
"Name": ".ctor",
|
||||
"Parameters": [],
|
||||
"Visibility": "Public",
|
||||
"GenericParameter": []
|
||||
}
|
||||
],
|
||||
"GenericParameters": []
|
||||
},
|
||||
{
|
||||
"Name": "Microsoft.AspNetCore.SpaServices.StaticFiles.ISpaStaticFileProvider",
|
||||
"Visibility": "Public",
|
||||
"Kind": "Interface",
|
||||
"Abstract": true,
|
||||
"ImplementedInterfaces": [],
|
||||
"Members": [
|
||||
{
|
||||
"Kind": "Method",
|
||||
"Name": "get_FileProvider",
|
||||
"Parameters": [],
|
||||
"ReturnType": "Microsoft.Extensions.FileProviders.IFileProvider",
|
||||
"GenericParameter": []
|
||||
}
|
||||
],
|
||||
"GenericParameters": []
|
||||
},
|
||||
{
|
||||
"Name": "Microsoft.AspNetCore.SpaServices.StaticFiles.SpaStaticFilesOptions",
|
||||
"Visibility": "Public",
|
||||
"Kind": "Class",
|
||||
"ImplementedInterfaces": [],
|
||||
"Members": [
|
||||
{
|
||||
"Kind": "Method",
|
||||
"Name": "get_RootPath",
|
||||
"Parameters": [],
|
||||
"ReturnType": "System.String",
|
||||
"Visibility": "Public",
|
||||
"GenericParameter": []
|
||||
},
|
||||
{
|
||||
"Kind": "Method",
|
||||
"Name": "set_RootPath",
|
||||
"Parameters": [
|
||||
{
|
||||
"Name": "value",
|
||||
"Type": "System.String"
|
||||
}
|
||||
],
|
||||
"ReturnType": "System.Void",
|
||||
"Visibility": "Public",
|
||||
"GenericParameter": []
|
||||
},
|
||||
{
|
||||
"Kind": "Constructor",
|
||||
"Name": ".ctor",
|
||||
"Parameters": [],
|
||||
"Visibility": "Public",
|
||||
"GenericParameter": []
|
||||
}
|
||||
],
|
||||
"GenericParameters": []
|
||||
},
|
||||
{
|
||||
"Name": "Microsoft.AspNetCore.SpaServices.ReactDevelopmentServer.ReactDevelopmentServerMiddlewareExtensions",
|
||||
"Visibility": "Public",
|
||||
"Kind": "Class",
|
||||
"Abstract": true,
|
||||
"Static": true,
|
||||
"Sealed": true,
|
||||
"ImplementedInterfaces": [],
|
||||
"Members": [
|
||||
{
|
||||
"Kind": "Method",
|
||||
"Name": "UseReactDevelopmentServer",
|
||||
"Parameters": [
|
||||
{
|
||||
"Name": "spaBuilder",
|
||||
"Type": "Microsoft.AspNetCore.SpaServices.ISpaBuilder"
|
||||
},
|
||||
{
|
||||
"Name": "npmScript",
|
||||
"Type": "System.String"
|
||||
}
|
||||
],
|
||||
"ReturnType": "System.Void",
|
||||
"Static": true,
|
||||
"Extension": true,
|
||||
"Visibility": "Public",
|
||||
"GenericParameter": []
|
||||
}
|
||||
],
|
||||
"GenericParameters": []
|
||||
},
|
||||
{
|
||||
"Name": "Microsoft.AspNetCore.SpaServices.Prerendering.ISpaPrerendererBuilder",
|
||||
"Visibility": "Public",
|
||||
"Kind": "Interface",
|
||||
"Abstract": true,
|
||||
"ImplementedInterfaces": [],
|
||||
"Members": [
|
||||
{
|
||||
"Kind": "Method",
|
||||
"Name": "Build",
|
||||
"Parameters": [
|
||||
{
|
||||
"Name": "spaBuilder",
|
||||
"Type": "Microsoft.AspNetCore.SpaServices.ISpaBuilder"
|
||||
}
|
||||
],
|
||||
"ReturnType": "System.Threading.Tasks.Task",
|
||||
"GenericParameter": []
|
||||
}
|
||||
],
|
||||
"GenericParameters": []
|
||||
},
|
||||
{
|
||||
"Name": "Microsoft.AspNetCore.SpaServices.AngularCli.AngularCliBuilder",
|
||||
"Visibility": "Public",
|
||||
"Kind": "Class",
|
||||
"ImplementedInterfaces": [
|
||||
"Microsoft.AspNetCore.SpaServices.Prerendering.ISpaPrerendererBuilder"
|
||||
],
|
||||
"Members": [
|
||||
{
|
||||
"Kind": "Method",
|
||||
"Name": "Build",
|
||||
"Parameters": [
|
||||
{
|
||||
"Name": "spaBuilder",
|
||||
"Type": "Microsoft.AspNetCore.SpaServices.ISpaBuilder"
|
||||
}
|
||||
],
|
||||
"ReturnType": "System.Threading.Tasks.Task",
|
||||
"Sealed": true,
|
||||
"Virtual": true,
|
||||
"ImplementedInterface": "Microsoft.AspNetCore.SpaServices.Prerendering.ISpaPrerendererBuilder",
|
||||
"Visibility": "Public",
|
||||
"GenericParameter": []
|
||||
},
|
||||
{
|
||||
"Kind": "Constructor",
|
||||
"Name": ".ctor",
|
||||
"Parameters": [
|
||||
{
|
||||
"Name": "npmScript",
|
||||
"Type": "System.String"
|
||||
}
|
||||
],
|
||||
"Visibility": "Public",
|
||||
"GenericParameter": []
|
||||
}
|
||||
],
|
||||
"GenericParameters": []
|
||||
},
|
||||
{
|
||||
"Name": "Microsoft.AspNetCore.SpaServices.AngularCli.AngularCliMiddlewareExtensions",
|
||||
"Visibility": "Public",
|
||||
"Kind": "Class",
|
||||
"Abstract": true,
|
||||
"Static": true,
|
||||
"Sealed": true,
|
||||
"ImplementedInterfaces": [],
|
||||
"Members": [
|
||||
{
|
||||
"Kind": "Method",
|
||||
"Name": "UseAngularCliServer",
|
||||
"Parameters": [
|
||||
{
|
||||
"Name": "spaBuilder",
|
||||
"Type": "Microsoft.AspNetCore.SpaServices.ISpaBuilder"
|
||||
},
|
||||
{
|
||||
"Name": "npmScript",
|
||||
"Type": "System.String"
|
||||
}
|
||||
],
|
||||
"ReturnType": "System.Void",
|
||||
"Static": true,
|
||||
"Extension": true,
|
||||
"Visibility": "Public",
|
||||
"GenericParameter": []
|
||||
}
|
||||
],
|
||||
"GenericParameters": []
|
||||
},
|
||||
{
|
||||
"Name": "Microsoft.AspNetCore.NodeServices.Util.EventedStreamReader+OnReceivedChunkHandler",
|
||||
"Visibility": "Public",
|
||||
"Kind": "Class",
|
||||
"Sealed": true,
|
||||
"BaseType": "System.MulticastDelegate",
|
||||
"ImplementedInterfaces": [],
|
||||
"Members": [
|
||||
{
|
||||
"Kind": "Method",
|
||||
"Name": "Invoke",
|
||||
"Parameters": [
|
||||
{
|
||||
"Name": "chunk",
|
||||
"Type": "System.ArraySegment<System.Char>"
|
||||
}
|
||||
],
|
||||
"ReturnType": "System.Void",
|
||||
"Virtual": true,
|
||||
"Visibility": "Public",
|
||||
"GenericParameter": []
|
||||
},
|
||||
{
|
||||
"Kind": "Method",
|
||||
"Name": "BeginInvoke",
|
||||
"Parameters": [
|
||||
{
|
||||
"Name": "chunk",
|
||||
"Type": "System.ArraySegment<System.Char>"
|
||||
},
|
||||
{
|
||||
"Name": "callback",
|
||||
"Type": "System.AsyncCallback"
|
||||
},
|
||||
{
|
||||
"Name": "object",
|
||||
"Type": "System.Object"
|
||||
}
|
||||
],
|
||||
"ReturnType": "System.IAsyncResult",
|
||||
"Virtual": true,
|
||||
"Visibility": "Public",
|
||||
"GenericParameter": []
|
||||
},
|
||||
{
|
||||
"Kind": "Method",
|
||||
"Name": "EndInvoke",
|
||||
"Parameters": [
|
||||
{
|
||||
"Name": "result",
|
||||
"Type": "System.IAsyncResult"
|
||||
}
|
||||
],
|
||||
"ReturnType": "System.Void",
|
||||
"Virtual": true,
|
||||
"Visibility": "Public",
|
||||
"GenericParameter": []
|
||||
},
|
||||
{
|
||||
"Kind": "Constructor",
|
||||
"Name": ".ctor",
|
||||
"Parameters": [
|
||||
{
|
||||
"Name": "object",
|
||||
"Type": "System.Object"
|
||||
},
|
||||
{
|
||||
"Name": "method",
|
||||
"Type": "System.IntPtr"
|
||||
}
|
||||
],
|
||||
"Visibility": "Public",
|
||||
"GenericParameter": []
|
||||
}
|
||||
],
|
||||
"GenericParameters": []
|
||||
},
|
||||
{
|
||||
"Name": "Microsoft.AspNetCore.NodeServices.Util.EventedStreamReader+OnReceivedLineHandler",
|
||||
"Visibility": "Public",
|
||||
"Kind": "Class",
|
||||
"Sealed": true,
|
||||
"BaseType": "System.MulticastDelegate",
|
||||
"ImplementedInterfaces": [],
|
||||
"Members": [
|
||||
{
|
||||
"Kind": "Method",
|
||||
"Name": "Invoke",
|
||||
"Parameters": [
|
||||
{
|
||||
"Name": "line",
|
||||
"Type": "System.String"
|
||||
}
|
||||
],
|
||||
"ReturnType": "System.Void",
|
||||
"Virtual": true,
|
||||
"Visibility": "Public",
|
||||
"GenericParameter": []
|
||||
},
|
||||
{
|
||||
"Kind": "Method",
|
||||
"Name": "BeginInvoke",
|
||||
"Parameters": [
|
||||
{
|
||||
"Name": "line",
|
||||
"Type": "System.String"
|
||||
},
|
||||
{
|
||||
"Name": "callback",
|
||||
"Type": "System.AsyncCallback"
|
||||
},
|
||||
{
|
||||
"Name": "object",
|
||||
"Type": "System.Object"
|
||||
}
|
||||
],
|
||||
"ReturnType": "System.IAsyncResult",
|
||||
"Virtual": true,
|
||||
"Visibility": "Public",
|
||||
"GenericParameter": []
|
||||
},
|
||||
{
|
||||
"Kind": "Method",
|
||||
"Name": "EndInvoke",
|
||||
"Parameters": [
|
||||
{
|
||||
"Name": "result",
|
||||
"Type": "System.IAsyncResult"
|
||||
}
|
||||
],
|
||||
"ReturnType": "System.Void",
|
||||
"Virtual": true,
|
||||
"Visibility": "Public",
|
||||
"GenericParameter": []
|
||||
},
|
||||
{
|
||||
"Kind": "Constructor",
|
||||
"Name": ".ctor",
|
||||
"Parameters": [
|
||||
{
|
||||
"Name": "object",
|
||||
"Type": "System.Object"
|
||||
},
|
||||
{
|
||||
"Name": "method",
|
||||
"Type": "System.IntPtr"
|
||||
}
|
||||
],
|
||||
"Visibility": "Public",
|
||||
"GenericParameter": []
|
||||
}
|
||||
],
|
||||
"GenericParameters": []
|
||||
},
|
||||
{
|
||||
"Name": "Microsoft.AspNetCore.NodeServices.Util.EventedStreamReader+OnStreamClosedHandler",
|
||||
"Visibility": "Public",
|
||||
"Kind": "Class",
|
||||
"Sealed": true,
|
||||
"BaseType": "System.MulticastDelegate",
|
||||
"ImplementedInterfaces": [],
|
||||
"Members": [
|
||||
{
|
||||
"Kind": "Method",
|
||||
"Name": "Invoke",
|
||||
"Parameters": [],
|
||||
"ReturnType": "System.Void",
|
||||
"Virtual": true,
|
||||
"Visibility": "Public",
|
||||
"GenericParameter": []
|
||||
},
|
||||
{
|
||||
"Kind": "Method",
|
||||
"Name": "BeginInvoke",
|
||||
"Parameters": [
|
||||
{
|
||||
"Name": "callback",
|
||||
"Type": "System.AsyncCallback"
|
||||
},
|
||||
{
|
||||
"Name": "object",
|
||||
"Type": "System.Object"
|
||||
}
|
||||
],
|
||||
"ReturnType": "System.IAsyncResult",
|
||||
"Virtual": true,
|
||||
"Visibility": "Public",
|
||||
"GenericParameter": []
|
||||
},
|
||||
{
|
||||
"Kind": "Method",
|
||||
"Name": "EndInvoke",
|
||||
"Parameters": [
|
||||
{
|
||||
"Name": "result",
|
||||
"Type": "System.IAsyncResult"
|
||||
}
|
||||
],
|
||||
"ReturnType": "System.Void",
|
||||
"Virtual": true,
|
||||
"Visibility": "Public",
|
||||
"GenericParameter": []
|
||||
},
|
||||
{
|
||||
"Kind": "Constructor",
|
||||
"Name": ".ctor",
|
||||
"Parameters": [
|
||||
{
|
||||
"Name": "object",
|
||||
"Type": "System.Object"
|
||||
},
|
||||
{
|
||||
"Name": "method",
|
||||
"Type": "System.IntPtr"
|
||||
}
|
||||
],
|
||||
"Visibility": "Public",
|
||||
"GenericParameter": []
|
||||
}
|
||||
],
|
||||
"GenericParameters": []
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,178 +1,224 @@
|
||||
(function(e, a) { for(var i in a) e[i] = a[i]; }(exports, /******/ (function(modules) { // webpackBootstrap
|
||||
/******/ // The module cache
|
||||
/******/ var installedModules = {};
|
||||
|
||||
/******/
|
||||
/******/ // The require function
|
||||
/******/ function __webpack_require__(moduleId) {
|
||||
|
||||
/******/
|
||||
/******/ // Check if module is in cache
|
||||
/******/ if(installedModules[moduleId])
|
||||
/******/ if(installedModules[moduleId]) {
|
||||
/******/ return installedModules[moduleId].exports;
|
||||
|
||||
/******/ }
|
||||
/******/ // Create a new module (and put it into the cache)
|
||||
/******/ var module = installedModules[moduleId] = {
|
||||
/******/ exports: {},
|
||||
/******/ id: moduleId,
|
||||
/******/ loaded: false
|
||||
/******/ i: moduleId,
|
||||
/******/ l: false,
|
||||
/******/ exports: {}
|
||||
/******/ };
|
||||
|
||||
/******/
|
||||
/******/ // Execute the module function
|
||||
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
|
||||
|
||||
/******/
|
||||
/******/ // Flag the module as loaded
|
||||
/******/ module.loaded = true;
|
||||
|
||||
/******/ module.l = true;
|
||||
/******/
|
||||
/******/ // Return the exports of the module
|
||||
/******/ return module.exports;
|
||||
/******/ }
|
||||
|
||||
|
||||
/******/
|
||||
/******/
|
||||
/******/ // expose the modules object (__webpack_modules__)
|
||||
/******/ __webpack_require__.m = modules;
|
||||
|
||||
/******/
|
||||
/******/ // expose the module cache
|
||||
/******/ __webpack_require__.c = installedModules;
|
||||
|
||||
/******/
|
||||
/******/ // define getter function for harmony exports
|
||||
/******/ __webpack_require__.d = function(exports, name, getter) {
|
||||
/******/ if(!__webpack_require__.o(exports, name)) {
|
||||
/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
|
||||
/******/ }
|
||||
/******/ };
|
||||
/******/
|
||||
/******/ // define __esModule on exports
|
||||
/******/ __webpack_require__.r = function(exports) {
|
||||
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
|
||||
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
||||
/******/ }
|
||||
/******/ Object.defineProperty(exports, '__esModule', { value: true });
|
||||
/******/ };
|
||||
/******/
|
||||
/******/ // create a fake namespace object
|
||||
/******/ // mode & 1: value is a module id, require it
|
||||
/******/ // mode & 2: merge all properties of value into the ns
|
||||
/******/ // mode & 4: return value when already ns object
|
||||
/******/ // mode & 8|1: behave like require
|
||||
/******/ __webpack_require__.t = function(value, mode) {
|
||||
/******/ if(mode & 1) value = __webpack_require__(value);
|
||||
/******/ if(mode & 8) return value;
|
||||
/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
|
||||
/******/ var ns = Object.create(null);
|
||||
/******/ __webpack_require__.r(ns);
|
||||
/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
|
||||
/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
|
||||
/******/ return ns;
|
||||
/******/ };
|
||||
/******/
|
||||
/******/ // getDefaultExport function for compatibility with non-harmony modules
|
||||
/******/ __webpack_require__.n = function(module) {
|
||||
/******/ var getter = module && module.__esModule ?
|
||||
/******/ function getDefault() { return module['default']; } :
|
||||
/******/ function getModuleExports() { return module; };
|
||||
/******/ __webpack_require__.d(getter, 'a', getter);
|
||||
/******/ return getter;
|
||||
/******/ };
|
||||
/******/
|
||||
/******/ // Object.prototype.hasOwnProperty.call
|
||||
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
|
||||
/******/
|
||||
/******/ // __webpack_public_path__
|
||||
/******/ __webpack_require__.p = "";
|
||||
|
||||
/******/
|
||||
/******/
|
||||
/******/ // Load entry module and return exports
|
||||
/******/ return __webpack_require__(0);
|
||||
/******/ return __webpack_require__(__webpack_require__.s = 0);
|
||||
/******/ })
|
||||
/************************************************************************/
|
||||
/******/ ([
|
||||
/* 0 */
|
||||
/***/ function(module, exports, __webpack_require__) {
|
||||
/***/ (function(module, exports, __webpack_require__) {
|
||||
|
||||
module.exports = __webpack_require__(1);
|
||||
module.exports = __webpack_require__(1);
|
||||
|
||||
|
||||
/***/ },
|
||||
/***/ }),
|
||||
/* 1 */
|
||||
/***/ function(module, exports, __webpack_require__) {
|
||||
/***/ (function(module, exports, __webpack_require__) {
|
||||
|
||||
"use strict";
|
||||
var path = __webpack_require__(2);
|
||||
// Separate declaration and export just to add type checking on function signature
|
||||
exports.renderToString = renderToStringImpl;
|
||||
// This function is invoked by .NET code (via NodeServices). Its job is to hand off execution to the application's
|
||||
// prerendering boot function. It can operate in two modes:
|
||||
// [1] Legacy mode
|
||||
// This is for backward compatibility with projects created with templates older than the generator version 0.6.0.
|
||||
// In this mode, we don't really do anything here - we just load the 'aspnet-prerendering' NPM module (which must
|
||||
// exist in node_modules, and must be v1.x (not v2+)), and pass through all the parameters to it. Code in
|
||||
// 'aspnet-prerendering' v1.x will locate the boot function and invoke it.
|
||||
// The drawback to this mode is that, for it to work, you have to deploy node_modules to production.
|
||||
// [2] Current mode
|
||||
// This is for projects created with the Yeoman generator 0.6.0+ (or projects manually updated). In this mode,
|
||||
// we don't invoke 'require' at runtime at all. All our dependencies are bundled into the NuGet package, so you
|
||||
// don't have to deploy node_modules to production.
|
||||
// To determine whether we're in mode [1] or [2], the code locates your prerendering boot function, and checks whether
|
||||
// a certain flag is attached to the function instance.
|
||||
function renderToStringImpl(callback, applicationBasePath, bootModule, absoluteRequestUrl, requestPathAndQuery, customDataParameter, overrideTimeoutMilliseconds) {
|
||||
try {
|
||||
var forceLegacy = isLegacyAspNetPrerendering();
|
||||
var renderToStringFunc = !forceLegacy && findRenderToStringFunc(applicationBasePath, bootModule);
|
||||
var isNotLegacyMode = renderToStringFunc && renderToStringFunc['isServerRenderer'];
|
||||
if (isNotLegacyMode) {
|
||||
// Current (non-legacy) mode - we invoke the exported function directly (instead of going through aspnet-prerendering)
|
||||
// It's type-safe to just apply the incoming args to this function, because we already type-checked that it's a RenderToStringFunc,
|
||||
// just like renderToStringImpl itself is.
|
||||
renderToStringFunc.apply(null, arguments);
|
||||
}
|
||||
else {
|
||||
// Legacy mode - just hand off execution to 'aspnet-prerendering' v1.x, which must exist in node_modules at runtime
|
||||
var aspNetPrerenderingV1RenderToString = __webpack_require__(3).renderToString;
|
||||
if (aspNetPrerenderingV1RenderToString) {
|
||||
aspNetPrerenderingV1RenderToString(callback, applicationBasePath, bootModule, absoluteRequestUrl, requestPathAndQuery, customDataParameter, overrideTimeoutMilliseconds);
|
||||
}
|
||||
else {
|
||||
callback('If you use aspnet-prerendering >= 2.0.0, you must update your server-side boot module to call createServerRenderer. '
|
||||
+ 'Either update your boot module code, or revert to aspnet-prerendering version 1.x');
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (ex) {
|
||||
// Make sure loading errors are reported back to the .NET part of the app
|
||||
callback('Prerendering failed because of error: '
|
||||
+ ex.stack
|
||||
+ '\nCurrent directory is: '
|
||||
+ process.cwd());
|
||||
}
|
||||
}
|
||||
;
|
||||
function findBootModule(applicationBasePath, bootModule) {
|
||||
var bootModuleNameFullPath = path.resolve(applicationBasePath, bootModule.moduleName);
|
||||
if (bootModule.webpackConfig) {
|
||||
// If you're using asp-prerender-webpack-config, you're definitely in legacy mode
|
||||
return null;
|
||||
}
|
||||
else {
|
||||
return require(bootModuleNameFullPath);
|
||||
}
|
||||
}
|
||||
function findRenderToStringFunc(applicationBasePath, bootModule) {
|
||||
// First try to load the module
|
||||
var foundBootModule = findBootModule(applicationBasePath, bootModule);
|
||||
if (foundBootModule === null) {
|
||||
return null; // Must be legacy mode
|
||||
}
|
||||
// Now try to pick out the function they want us to invoke
|
||||
var renderToStringFunc;
|
||||
if (bootModule.exportName) {
|
||||
// Explicitly-named export
|
||||
renderToStringFunc = foundBootModule[bootModule.exportName];
|
||||
}
|
||||
else if (typeof foundBootModule !== 'function') {
|
||||
// TypeScript-style default export
|
||||
renderToStringFunc = foundBootModule.default;
|
||||
}
|
||||
else {
|
||||
// Native default export
|
||||
renderToStringFunc = foundBootModule;
|
||||
}
|
||||
// Validate the result
|
||||
if (typeof renderToStringFunc !== 'function') {
|
||||
if (bootModule.exportName) {
|
||||
throw new Error("The module at " + bootModule.moduleName + " has no function export named " + bootModule.exportName + ".");
|
||||
}
|
||||
else {
|
||||
throw new Error("The module at " + bootModule.moduleName + " does not export a default function, and you have not specified which export to invoke.");
|
||||
}
|
||||
}
|
||||
return renderToStringFunc;
|
||||
}
|
||||
function isLegacyAspNetPrerendering() {
|
||||
var version = getAspNetPrerenderingPackageVersion();
|
||||
return version && /^1\./.test(version);
|
||||
}
|
||||
function getAspNetPrerenderingPackageVersion() {
|
||||
try {
|
||||
var packageEntryPoint = require.resolve('aspnet-prerendering');
|
||||
var packageDir = path.dirname(packageEntryPoint);
|
||||
var packageJsonPath = path.join(packageDir, 'package.json');
|
||||
var packageJson = require(packageJsonPath);
|
||||
return packageJson.version.toString();
|
||||
}
|
||||
catch (ex) {
|
||||
// Implies aspnet-prerendering isn't in node_modules at all (or node_modules itself doesn't exist,
|
||||
// which will be the case in production based on latest templates).
|
||||
return null;
|
||||
}
|
||||
}
|
||||
"use strict";
|
||||
|
||||
exports.__esModule = true;
|
||||
var path = __webpack_require__(2);
|
||||
// Separate declaration and export just to add type checking on function signature
|
||||
exports.renderToString = renderToStringImpl;
|
||||
// This function is invoked by .NET code (via NodeServices). Its job is to hand off execution to the application's
|
||||
// prerendering boot function. It can operate in two modes:
|
||||
// [1] Legacy mode
|
||||
// This is for backward compatibility with projects created with templates older than the generator version 0.6.0.
|
||||
// In this mode, we don't really do anything here - we just load the 'aspnet-prerendering' NPM module (which must
|
||||
// exist in node_modules, and must be v1.x (not v2+)), and pass through all the parameters to it. Code in
|
||||
// 'aspnet-prerendering' v1.x will locate the boot function and invoke it.
|
||||
// The drawback to this mode is that, for it to work, you have to deploy node_modules to production.
|
||||
// [2] Current mode
|
||||
// This is for projects created with the Yeoman generator 0.6.0+ (or projects manually updated). In this mode,
|
||||
// we don't invoke 'require' at runtime at all. All our dependencies are bundled into the NuGet package, so you
|
||||
// don't have to deploy node_modules to production.
|
||||
// To determine whether we're in mode [1] or [2], the code locates your prerendering boot function, and checks whether
|
||||
// a certain flag is attached to the function instance.
|
||||
function renderToStringImpl(callback, applicationBasePath, bootModule, absoluteRequestUrl, requestPathAndQuery, customDataParameter, overrideTimeoutMilliseconds) {
|
||||
try {
|
||||
var forceLegacy = isLegacyAspNetPrerendering();
|
||||
var renderToStringFunc = !forceLegacy && findRenderToStringFunc(applicationBasePath, bootModule);
|
||||
var isNotLegacyMode = renderToStringFunc && renderToStringFunc['isServerRenderer'];
|
||||
if (isNotLegacyMode) {
|
||||
// Current (non-legacy) mode - we invoke the exported function directly (instead of going through aspnet-prerendering)
|
||||
// It's type-safe to just apply the incoming args to this function, because we already type-checked that it's a RenderToStringFunc,
|
||||
// just like renderToStringImpl itself is.
|
||||
renderToStringFunc.apply(null, arguments);
|
||||
}
|
||||
else {
|
||||
// Legacy mode - just hand off execution to 'aspnet-prerendering' v1.x, which must exist in node_modules at runtime
|
||||
var aspNetPrerenderingV1RenderToString = __webpack_require__(3).renderToString;
|
||||
if (aspNetPrerenderingV1RenderToString) {
|
||||
aspNetPrerenderingV1RenderToString(callback, applicationBasePath, bootModule, absoluteRequestUrl, requestPathAndQuery, customDataParameter, overrideTimeoutMilliseconds);
|
||||
}
|
||||
else {
|
||||
callback('If you use aspnet-prerendering >= 2.0.0, you must update your server-side boot module to call createServerRenderer. '
|
||||
+ 'Either update your boot module code, or revert to aspnet-prerendering version 1.x');
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (ex) {
|
||||
// Make sure loading errors are reported back to the .NET part of the app
|
||||
callback('Prerendering failed because of error: '
|
||||
+ ex.stack
|
||||
+ '\nCurrent directory is: '
|
||||
+ process.cwd());
|
||||
}
|
||||
}
|
||||
;
|
||||
function findBootModule(applicationBasePath, bootModule) {
|
||||
var bootModuleNameFullPath = path.resolve(applicationBasePath, bootModule.moduleName);
|
||||
if (bootModule.webpackConfig) {
|
||||
// If you're using asp-prerender-webpack-config, you're definitely in legacy mode
|
||||
return null;
|
||||
}
|
||||
else {
|
||||
return require(bootModuleNameFullPath);
|
||||
}
|
||||
}
|
||||
function findRenderToStringFunc(applicationBasePath, bootModule) {
|
||||
// First try to load the module
|
||||
var foundBootModule = findBootModule(applicationBasePath, bootModule);
|
||||
if (foundBootModule === null) {
|
||||
return null; // Must be legacy mode
|
||||
}
|
||||
// Now try to pick out the function they want us to invoke
|
||||
var renderToStringFunc;
|
||||
if (bootModule.exportName) {
|
||||
// Explicitly-named export
|
||||
renderToStringFunc = foundBootModule[bootModule.exportName];
|
||||
}
|
||||
else if (typeof foundBootModule !== 'function') {
|
||||
// TypeScript-style default export
|
||||
renderToStringFunc = foundBootModule["default"];
|
||||
}
|
||||
else {
|
||||
// Native default export
|
||||
renderToStringFunc = foundBootModule;
|
||||
}
|
||||
// Validate the result
|
||||
if (typeof renderToStringFunc !== 'function') {
|
||||
if (bootModule.exportName) {
|
||||
throw new Error("The module at " + bootModule.moduleName + " has no function export named " + bootModule.exportName + ".");
|
||||
}
|
||||
else {
|
||||
throw new Error("The module at " + bootModule.moduleName + " does not export a default function, and you have not specified which export to invoke.");
|
||||
}
|
||||
}
|
||||
return renderToStringFunc;
|
||||
}
|
||||
function isLegacyAspNetPrerendering() {
|
||||
var version = getAspNetPrerenderingPackageVersion();
|
||||
return version && /^1\./.test(version);
|
||||
}
|
||||
function getAspNetPrerenderingPackageVersion() {
|
||||
try {
|
||||
var packageEntryPoint = require.resolve('aspnet-prerendering');
|
||||
var packageDir = path.dirname(packageEntryPoint);
|
||||
var packageJsonPath = path.join(packageDir, 'package.json');
|
||||
var packageJson = require(packageJsonPath);
|
||||
return packageJson.version.toString();
|
||||
}
|
||||
catch (ex) {
|
||||
// Implies aspnet-prerendering isn't in node_modules at all (or node_modules itself doesn't exist,
|
||||
// which will be the case in production based on latest templates).
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/***/ },
|
||||
/***/ }),
|
||||
/* 2 */
|
||||
/***/ function(module, exports) {
|
||||
/***/ (function(module, exports) {
|
||||
|
||||
module.exports = require("path");
|
||||
module.exports = require("path");
|
||||
|
||||
/***/ },
|
||||
/***/ }),
|
||||
/* 3 */
|
||||
/***/ function(module, exports) {
|
||||
/***/ (function(module, exports) {
|
||||
|
||||
module.exports = require("aspnet-prerendering");
|
||||
module.exports = require("aspnet-prerendering");
|
||||
|
||||
/***/ }
|
||||
/***/ })
|
||||
/******/ ])));
|
||||
@@ -1,86 +1,133 @@
|
||||
(function(e, a) { for(var i in a) e[i] = a[i]; }(exports, /******/ (function(modules) { // webpackBootstrap
|
||||
/******/ // The module cache
|
||||
/******/ var installedModules = {};
|
||||
|
||||
/******/
|
||||
/******/ // The require function
|
||||
/******/ function __webpack_require__(moduleId) {
|
||||
|
||||
/******/
|
||||
/******/ // Check if module is in cache
|
||||
/******/ if(installedModules[moduleId])
|
||||
/******/ if(installedModules[moduleId]) {
|
||||
/******/ return installedModules[moduleId].exports;
|
||||
|
||||
/******/ }
|
||||
/******/ // Create a new module (and put it into the cache)
|
||||
/******/ var module = installedModules[moduleId] = {
|
||||
/******/ exports: {},
|
||||
/******/ id: moduleId,
|
||||
/******/ loaded: false
|
||||
/******/ i: moduleId,
|
||||
/******/ l: false,
|
||||
/******/ exports: {}
|
||||
/******/ };
|
||||
|
||||
/******/
|
||||
/******/ // Execute the module function
|
||||
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
|
||||
|
||||
/******/
|
||||
/******/ // Flag the module as loaded
|
||||
/******/ module.loaded = true;
|
||||
|
||||
/******/ module.l = true;
|
||||
/******/
|
||||
/******/ // Return the exports of the module
|
||||
/******/ return module.exports;
|
||||
/******/ }
|
||||
|
||||
|
||||
/******/
|
||||
/******/
|
||||
/******/ // expose the modules object (__webpack_modules__)
|
||||
/******/ __webpack_require__.m = modules;
|
||||
|
||||
/******/
|
||||
/******/ // expose the module cache
|
||||
/******/ __webpack_require__.c = installedModules;
|
||||
|
||||
/******/
|
||||
/******/ // define getter function for harmony exports
|
||||
/******/ __webpack_require__.d = function(exports, name, getter) {
|
||||
/******/ if(!__webpack_require__.o(exports, name)) {
|
||||
/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
|
||||
/******/ }
|
||||
/******/ };
|
||||
/******/
|
||||
/******/ // define __esModule on exports
|
||||
/******/ __webpack_require__.r = function(exports) {
|
||||
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
|
||||
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
||||
/******/ }
|
||||
/******/ Object.defineProperty(exports, '__esModule', { value: true });
|
||||
/******/ };
|
||||
/******/
|
||||
/******/ // create a fake namespace object
|
||||
/******/ // mode & 1: value is a module id, require it
|
||||
/******/ // mode & 2: merge all properties of value into the ns
|
||||
/******/ // mode & 4: return value when already ns object
|
||||
/******/ // mode & 8|1: behave like require
|
||||
/******/ __webpack_require__.t = function(value, mode) {
|
||||
/******/ if(mode & 1) value = __webpack_require__(value);
|
||||
/******/ if(mode & 8) return value;
|
||||
/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
|
||||
/******/ var ns = Object.create(null);
|
||||
/******/ __webpack_require__.r(ns);
|
||||
/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
|
||||
/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
|
||||
/******/ return ns;
|
||||
/******/ };
|
||||
/******/
|
||||
/******/ // getDefaultExport function for compatibility with non-harmony modules
|
||||
/******/ __webpack_require__.n = function(module) {
|
||||
/******/ var getter = module && module.__esModule ?
|
||||
/******/ function getDefault() { return module['default']; } :
|
||||
/******/ function getModuleExports() { return module; };
|
||||
/******/ __webpack_require__.d(getter, 'a', getter);
|
||||
/******/ return getter;
|
||||
/******/ };
|
||||
/******/
|
||||
/******/ // Object.prototype.hasOwnProperty.call
|
||||
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
|
||||
/******/
|
||||
/******/ // __webpack_public_path__
|
||||
/******/ __webpack_require__.p = "";
|
||||
|
||||
/******/
|
||||
/******/
|
||||
/******/ // Load entry module and return exports
|
||||
/******/ return __webpack_require__(0);
|
||||
/******/ return __webpack_require__(__webpack_require__.s = 4);
|
||||
/******/ })
|
||||
/************************************************************************/
|
||||
/******/ ([
|
||||
/* 0 */
|
||||
/***/ function(module, exports, __webpack_require__) {
|
||||
|
||||
module.exports = __webpack_require__(4);
|
||||
|
||||
|
||||
/***/ },
|
||||
/* 0 */,
|
||||
/* 1 */,
|
||||
/* 2 */,
|
||||
/* 3 */,
|
||||
/* 4 */
|
||||
/***/ function(module, exports, __webpack_require__) {
|
||||
/***/ (function(module, exports, __webpack_require__) {
|
||||
|
||||
"use strict";
|
||||
// Pass through the invocation to the 'aspnet-webpack' package, verifying that it can be loaded
|
||||
function createWebpackDevServer(callback) {
|
||||
var aspNetWebpack;
|
||||
try {
|
||||
aspNetWebpack = __webpack_require__(5);
|
||||
}
|
||||
catch (ex) {
|
||||
// Developers sometimes have trouble with badly-configured Node installations, where it's unable
|
||||
// to find node_modules. Or they accidentally fail to deploy node_modules, or even to run 'npm install'.
|
||||
// Make sure such errors are reported back to the .NET part of the app.
|
||||
callback('Webpack dev middleware failed because of an error while loading \'aspnet-webpack\'. Error was: '
|
||||
+ ex.stack
|
||||
+ '\nCurrent directory is: '
|
||||
+ process.cwd());
|
||||
return;
|
||||
}
|
||||
return aspNetWebpack.createWebpackDevServer.apply(this, arguments);
|
||||
}
|
||||
exports.createWebpackDevServer = createWebpackDevServer;
|
||||
module.exports = __webpack_require__(5);
|
||||
|
||||
|
||||
/***/ },
|
||||
/***/ }),
|
||||
/* 5 */
|
||||
/***/ function(module, exports) {
|
||||
/***/ (function(module, exports, __webpack_require__) {
|
||||
|
||||
module.exports = require("aspnet-webpack");
|
||||
"use strict";
|
||||
|
||||
/***/ }
|
||||
exports.__esModule = true;
|
||||
// Pass through the invocation to the 'aspnet-webpack' package, verifying that it can be loaded
|
||||
function createWebpackDevServer(callback) {
|
||||
var aspNetWebpack;
|
||||
try {
|
||||
aspNetWebpack = __webpack_require__(6);
|
||||
}
|
||||
catch (ex) {
|
||||
// Developers sometimes have trouble with badly-configured Node installations, where it's unable
|
||||
// to find node_modules. Or they accidentally fail to deploy node_modules, or even to run 'npm install'.
|
||||
// Make sure such errors are reported back to the .NET part of the app.
|
||||
callback('Webpack dev middleware failed because of an error while loading \'aspnet-webpack\'. Error was: '
|
||||
+ ex.stack
|
||||
+ '\nCurrent directory is: '
|
||||
+ process.cwd());
|
||||
return;
|
||||
}
|
||||
return aspNetWebpack.createWebpackDevServer.apply(this, arguments);
|
||||
}
|
||||
exports.createWebpackDevServer = createWebpackDevServer;
|
||||
|
||||
|
||||
/***/ }),
|
||||
/* 6 */
|
||||
/***/ (function(module, exports) {
|
||||
|
||||
module.exports = require("aspnet-webpack");
|
||||
|
||||
/***/ })
|
||||
/******/ ])));
|
||||
@@ -9,7 +9,7 @@ This package enables:
|
||||
* [**Hot module replacement**](#webpack-hot-module-replacement) so that, during development, your code and markup changes will be pushed to your browser and updated in the running application automatically, without even needing to reload the page
|
||||
* [**Routing helpers**](#routing-helper-mapspafallbackroute) for integrating server-side routing with client-side routing
|
||||
|
||||
Behind the scenes, it uses the [`Microsoft.AspNetCore.NodeServices`](https://github.com/aspnet/JavaScriptServices/tree/dev/src/Microsoft.AspNetCore.NodeServices) package as a fast and robust way to invoke Node.js-hosted code from ASP.NET Core at runtime.
|
||||
Behind the scenes, it uses the [`Microsoft.AspNetCore.NodeServices`](https://github.com/aspnet/JavaScriptServices/tree/master/src/Microsoft.AspNetCore.NodeServices) package as a fast and robust way to invoke Node.js-hosted code from ASP.NET Core at runtime.
|
||||
|
||||
### Requirements
|
||||
|
||||
@@ -223,7 +223,7 @@ npm install --save angular2-universal
|
||||
|
||||
Now you can use the [`angular2-universal` APIs](https://github.com/angular/universal) from your `boot-server.ts` TypeScript module to execute your Angular component on the server. The code needed for this is fairly complex, but that's unavoidable because Angular supports so many different ways of being configured, and you need to provide wiring for whatever combination of DI modules you're using.
|
||||
|
||||
You can find an example `boot-server.ts` that renders arbitrary Angular components [here](https://github.com/aspnet/JavaScriptServices/blob/dev/templates/AngularSpa/ClientApp/boot-server.ts). If you use this with your own application, you might need to edit the `serverBindings` array to reference any other DI services that your Angular component depends on.
|
||||
You can find an example `boot-server.ts` that renders arbitrary Angular components [here](../../templates/AngularSpa/ClientApp/boot-server.ts). If you use this with your own application, you might need to edit the `serverBindings` array to reference any other DI services that your Angular component depends on.
|
||||
|
||||
The easiest way to get started with Angular server-side rendering on ASP.NET Core is to use the [aspnetcore-spa generator](http://blog.stevensanderson.com/2016/05/02/angular2-react-knockout-apps-on-aspnet-core/), which creates a ready-made working starting point.
|
||||
|
||||
@@ -299,7 +299,7 @@ If you want to enable server-side prerendering too, follow the same process as d
|
||||
|
||||
The above example is extremely simple - it doesn't use `react-router`, and it doesn't load any data asynchronously. Real applications are likely to do both of these.
|
||||
|
||||
For an example server-side boot module that knows how to evaluate `react-router` routes and render the correct React component, see [this example](https://github.com/aspnet/JavaScriptServices/blob/dev/templates/ReactReduxSpa/ClientApp/boot-server.tsx).
|
||||
For an example server-side boot module that knows how to evaluate `react-router` routes and render the correct React component, see [this example](../../templates/ReactReduxSpa/ClientApp/boot-server.tsx).
|
||||
|
||||
Supporting asynchronous data loading involves more considerations. Unlike Angular applications that run asynchronously on the server and freely overwrite server-generated markup with client-generated markup, React strictly wants to run synchronously on the server and always produce the same markup on the server as it does on the client.
|
||||
|
||||
@@ -327,7 +327,7 @@ As a simple example, here's how you can set up Webpack to build TypeScript files
|
||||
|
||||
```
|
||||
npm install --save typescript ts-loader
|
||||
```
|
||||
```
|
||||
|
||||
And if you don't already have it, you'll find it useful to install the `webpack` command-line tool:
|
||||
|
||||
@@ -641,8 +641,8 @@ by using the `HotModuleReplacementClientOptions` property on `WebpackDevMiddlewa
|
||||
```csharp
|
||||
app.UseWebpackDevMiddleware(new WebpackDevMiddlewareOptions {
|
||||
HotModuleReplacement = true,
|
||||
HotModuleReplacementClientOptions = new Dictionary<string, string> {
|
||||
{ "reload", "true" },
|
||||
HotModuleReplacementClientOptions = new Dictionary<string, string> {
|
||||
{ "reload", "true" },
|
||||
},
|
||||
});
|
||||
```
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
/// <reference path="../npm/aspnet-prerendering/src/PrerenderingInterfaces.d.ts" />
|
||||
import * as url from 'url';
|
||||
import { BootModuleInfo, RenderToStringFunc, RenderToStringCallback } from '../npm/aspnet-prerendering/src/PrerenderingInterfaces';
|
||||
import * as path from 'path';
|
||||
import * as fs from 'fs';
|
||||
declare var __non_webpack_require__;
|
||||
|
||||
// Separate declaration and export just to add type checking on function signature
|
||||
|
||||
@@ -9,7 +9,7 @@ using Microsoft.AspNetCore.Http;
|
||||
namespace Microsoft.AspNetCore.SpaServices.Webpack
|
||||
{
|
||||
/// <summary>
|
||||
/// Based on https://github.com/aspnet/Proxy/blob/dev/src/Microsoft.AspNetCore.Proxy/ProxyMiddleware.cs
|
||||
/// Based on ProxyMiddleware from https://github.com/aspnet/Proxy/.
|
||||
/// Differs in that, if the proxied request returns a 404, we pass through to the next middleware in the chain
|
||||
/// This is useful for Webpack middleware, because it lets you fall back on prebuilt files on disk for
|
||||
/// chunks not exposed by the current Webpack config (e.g., DLL/vendor chunks).
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"AssemblyIdentity": "Microsoft.AspNetCore.SpaServices, Version=2.0.3.0, Culture=neutral, PublicKeyToken=adb9793829ddae60",
|
||||
"AssemblyIdentity": "Microsoft.AspNetCore.SpaServices, Version=2.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60",
|
||||
"Types": [
|
||||
{
|
||||
"Name": "Microsoft.Extensions.DependencyInjection.PrerenderingServiceCollectionExtensions",
|
||||
@@ -316,6 +316,27 @@
|
||||
"Visibility": "Public",
|
||||
"GenericParameter": []
|
||||
},
|
||||
{
|
||||
"Kind": "Method",
|
||||
"Name": "get_EnvParam",
|
||||
"Parameters": [],
|
||||
"ReturnType": "System.Object",
|
||||
"Visibility": "Public",
|
||||
"GenericParameter": []
|
||||
},
|
||||
{
|
||||
"Kind": "Method",
|
||||
"Name": "set_EnvParam",
|
||||
"Parameters": [
|
||||
{
|
||||
"Name": "value",
|
||||
"Type": "System.Object"
|
||||
}
|
||||
],
|
||||
"ReturnType": "System.Void",
|
||||
"Visibility": "Public",
|
||||
"GenericParameter": []
|
||||
},
|
||||
{
|
||||
"Kind": "Constructor",
|
||||
"Name": ".ctor",
|
||||
@@ -478,6 +499,26 @@
|
||||
"BaseType": "Microsoft.AspNetCore.Razor.TagHelpers.TagHelper",
|
||||
"ImplementedInterfaces": [],
|
||||
"Members": [
|
||||
{
|
||||
"Kind": "Method",
|
||||
"Name": "ProcessAsync",
|
||||
"Parameters": [
|
||||
{
|
||||
"Name": "context",
|
||||
"Type": "Microsoft.AspNetCore.Razor.TagHelpers.TagHelperContext"
|
||||
},
|
||||
{
|
||||
"Name": "output",
|
||||
"Type": "Microsoft.AspNetCore.Razor.TagHelpers.TagHelperOutput"
|
||||
}
|
||||
],
|
||||
"ReturnType": "System.Threading.Tasks.Task",
|
||||
"Virtual": true,
|
||||
"Override": true,
|
||||
"ImplementedInterface": "Microsoft.AspNetCore.Razor.TagHelpers.ITagHelperComponent",
|
||||
"Visibility": "Public",
|
||||
"GenericParameter": []
|
||||
},
|
||||
{
|
||||
"Kind": "Method",
|
||||
"Name": "get_ModuleName",
|
||||
@@ -583,26 +624,6 @@
|
||||
"Visibility": "Public",
|
||||
"GenericParameter": []
|
||||
},
|
||||
{
|
||||
"Kind": "Method",
|
||||
"Name": "ProcessAsync",
|
||||
"Parameters": [
|
||||
{
|
||||
"Name": "context",
|
||||
"Type": "Microsoft.AspNetCore.Razor.TagHelpers.TagHelperContext"
|
||||
},
|
||||
{
|
||||
"Name": "output",
|
||||
"Type": "Microsoft.AspNetCore.Razor.TagHelpers.TagHelperOutput"
|
||||
}
|
||||
],
|
||||
"ReturnType": "System.Threading.Tasks.Task",
|
||||
"Virtual": true,
|
||||
"Override": true,
|
||||
"ImplementedInterface": "Microsoft.AspNetCore.Razor.TagHelpers.ITagHelperComponent",
|
||||
"Visibility": "Public",
|
||||
"GenericParameter": []
|
||||
},
|
||||
{
|
||||
"Kind": "Constructor",
|
||||
"Name": ".ctor",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "aspnet-webpack-react",
|
||||
"version": "3.0.0",
|
||||
"version": "4.0.0",
|
||||
"description": "Helpers for using Webpack with React in ASP.NET Core projects. Works in conjunction with the Microsoft.AspNetCore.SpaServices NuGet package.",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
@@ -17,12 +17,12 @@
|
||||
"url": "https://github.com/aspnet/JavaScriptServices.git"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/webpack": "^2.2.0",
|
||||
"@types/webpack": "^4.4.0",
|
||||
"rimraf": "^2.5.4",
|
||||
"typescript": "^2.0.0",
|
||||
"webpack": "^2.2.0"
|
||||
"webpack": "^4.16.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"webpack": "^2.2.0"
|
||||
"webpack": "^4.0.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
import * as webpack from 'webpack';
|
||||
|
||||
const reactHotLoaderWebpackLoader = 'react-hot-loader/webpack';
|
||||
const reactHotLoaderPatch = 'react-hot-loader/patch';
|
||||
const supportedTypeScriptLoaders = ['ts-loader', 'awesome-typescript-loader'];
|
||||
|
||||
export function addReactHotModuleReplacementConfig(webpackConfig: webpack.Configuration) {
|
||||
const moduleConfig = webpackConfig.module as webpack.NewModule;
|
||||
const moduleConfig = webpackConfig.module as webpack.Module;
|
||||
const moduleRules = moduleConfig.rules;
|
||||
if (!moduleRules) {
|
||||
return; // Unknown rules list format. Might be Webpack 1.x, which is not supported.
|
||||
@@ -15,24 +13,18 @@ export function addReactHotModuleReplacementConfig(webpackConfig: webpack.Config
|
||||
// to its array of loaders
|
||||
for (let ruleIndex = 0; ruleIndex < moduleRules.length; ruleIndex++) {
|
||||
// We only support NewUseRule (i.e., { use: ... }) because OldUseRule doesn't accept array values
|
||||
const rule = moduleRules[ruleIndex] as webpack.NewUseRule;
|
||||
const rule = moduleRules[ruleIndex] as webpack.RuleSetRule;
|
||||
if (!rule.use) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// We're looking for the first 'use' value that's a TypeScript loader
|
||||
const loadersArray = rule.use instanceof Array ? rule.use : [rule.use];
|
||||
const loadersArray: webpack.RuleSetUseItem[] = rule.use instanceof Array ? rule.use : [rule.use as webpack.RuleSetUseItem];
|
||||
const isTypescriptLoader = supportedTypeScriptLoaders.some(typeScriptLoaderName => containsLoader(loadersArray, typeScriptLoaderName));
|
||||
if (!isTypescriptLoader) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// This is the one - prefix it with the react-hot-loader loader
|
||||
// (unless it's already in there somewhere)
|
||||
if (!containsLoader(loadersArray, reactHotLoaderWebpackLoader)) {
|
||||
loadersArray.unshift(reactHotLoaderWebpackLoader);
|
||||
rule.use = loadersArray; // In case we normalised it to an array
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -48,19 +40,14 @@ export function addReactHotModuleReplacementConfig(webpackConfig: webpack.Config
|
||||
// Normalise to array
|
||||
entryConfig[entrypointName] = [entryConfig[entrypointName] as string];
|
||||
}
|
||||
|
||||
let entryValueArray = entryConfig[entrypointName] as string[];
|
||||
if (entryValueArray.indexOf(reactHotLoaderPatch) < 0) {
|
||||
entryValueArray.unshift(reactHotLoaderPatch);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function containsLoader(loadersArray: webpack.Loader[], loaderName: string) {
|
||||
function containsLoader(loadersArray: webpack.RuleSetUseItem[], loaderName: string) {
|
||||
return loadersArray.some(loader => {
|
||||
// Allow 'use' values to be either { loader: 'name' } or 'name'
|
||||
// No need to support legacy webpack.OldLoader
|
||||
const actualLoaderName = (loader as webpack.NewLoader).loader || (loader as string);
|
||||
const actualLoaderName = (loader as webpack.RuleSetLoader).loader || (loader as string);
|
||||
return actualLoaderName && new RegExp(`\\b${ loaderName }\\b`).test(actualLoaderName);
|
||||
});
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "aspnet-webpack",
|
||||
"version": "2.0.3",
|
||||
"version": "3.0.0",
|
||||
"description": "Helpers for using Webpack in ASP.NET Core projects. Works in conjunction with the Microsoft.AspNetCore.SpaServices NuGet package.",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
@@ -21,18 +21,18 @@
|
||||
"es6-promise": "^3.1.2",
|
||||
"memory-fs": "^0.3.0",
|
||||
"require-from-string": "^1.1.0",
|
||||
"webpack-dev-middleware": "^1.8.4",
|
||||
"webpack-node-externals": "^1.4.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/connect": "^3.4.30",
|
||||
"@types/node": "^6.0.42",
|
||||
"@types/webpack": "^2.2.0",
|
||||
"@types/webpack": "^4.1.3",
|
||||
"rimraf": "^2.5.4",
|
||||
"typescript": "^2.0.0",
|
||||
"webpack": "^1.13.2"
|
||||
"webpack": "^4.5.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"webpack": "^1.13.2 || ^2.1.0-beta || ^3.0.0"
|
||||
"webpack": "^1.13.2 || ^2.1.0-beta || ^3.0.0 || ^4.0.0",
|
||||
"webpack-dev-middleware": "^1.8.4 || ^3.0.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -90,9 +90,12 @@ function loadViaWebpackNoCache<T>(webpackConfigPath: string, modulePath: string)
|
||||
}));
|
||||
|
||||
// The CommonsChunkPlugin is not compatible with a CommonJS environment like Node, nor is it needed in that case
|
||||
webpackConfig.plugins = webpackConfig.plugins.filter(plugin => {
|
||||
return !(plugin instanceof webpack.optimize.CommonsChunkPlugin);
|
||||
});
|
||||
const ChunkPlugin = webpack.optimize['CommonsChunkPlugin'];
|
||||
if (ChunkPlugin !== undefined) {
|
||||
webpackConfig.plugins = webpackConfig.plugins.filter(plugin => {
|
||||
return !(plugin instanceof ChunkPlugin);
|
||||
});
|
||||
}
|
||||
|
||||
// The typical use case for DllReferencePlugin is for referencing vendor modules. In a Node
|
||||
// environment, it doesn't make sense to load them from a DLL bundle, nor would that even
|
||||
|
||||
@@ -121,6 +121,7 @@ function attachWebpackDevMiddleware(app: any, webpackConfig: webpack.Configurati
|
||||
const compiler = webpack(webpackConfig);
|
||||
app.use(require('webpack-dev-middleware')(compiler, {
|
||||
noInfo: true,
|
||||
stats: webpackConfig.stats,
|
||||
publicPath: ensureLeadingSlash(webpackConfig.output.publicPath),
|
||||
watchOptions: webpackConfig.watchOptions
|
||||
}));
|
||||
@@ -133,9 +134,12 @@ function attachWebpackDevMiddleware(app: any, webpackConfig: webpack.Configurati
|
||||
// middleware's in-memory filesystem only (and not on disk) would confuse the debugger, because the
|
||||
// file on disk wouldn't match the file served to the browser, and the source map line numbers wouldn't
|
||||
// match up. Breakpoints would either not be hit, or would hit the wrong lines.
|
||||
(compiler as any).plugin('done', stats => {
|
||||
copyRecursiveToRealFsSync(compiler.outputFileSystem, '/', [/\.hot-update\.(js|json|js\.map)$/]);
|
||||
});
|
||||
const copy = stats => copyRecursiveToRealFsSync(compiler.outputFileSystem, '/', [/\.hot-update\.(js|json|js\.map)$/]);
|
||||
if (compiler.hooks) {
|
||||
compiler.hooks.done.tap('aspnet-webpack', copy);
|
||||
} else {
|
||||
compiler.plugin('done', copy);
|
||||
}
|
||||
|
||||
if (enableHotModuleReplacement) {
|
||||
let webpackHotMiddlewareModule;
|
||||
|
||||
4230
src/Microsoft.AspNetCore.SpaServices/package-lock.json
generated
Normal file
4230
src/Microsoft.AspNetCore.SpaServices/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
@@ -5,14 +5,15 @@
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1",
|
||||
"build": "./node_modules/.bin/webpack"
|
||||
"build": "webpack --mode production"
|
||||
},
|
||||
"author": "Microsoft",
|
||||
"license": "Apache-2.0",
|
||||
"devDependencies": {
|
||||
"@types/node": "^6.0.42",
|
||||
"ts-loader": "^0.8.2",
|
||||
"typescript": "^2.0.0",
|
||||
"webpack": "^1.13.1"
|
||||
"@types/node": "^10.9.2",
|
||||
"ts-loader": "^4.5.0",
|
||||
"typescript": "^3.0.1",
|
||||
"webpack": "^4.17.1",
|
||||
"webpack-cli": "^3.1.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
const path = require('path');
|
||||
|
||||
module.exports = {
|
||||
target: 'node',
|
||||
externals: [
|
||||
@@ -10,8 +12,8 @@ module.exports = {
|
||||
extensions: [ '.ts' ]
|
||||
},
|
||||
module: {
|
||||
loaders: [
|
||||
{ test: /\.ts$/, loader: 'ts-loader' },
|
||||
rules: [
|
||||
{ test: /\.ts$/, use: 'ts-loader' },
|
||||
]
|
||||
},
|
||||
entry: {
|
||||
@@ -20,7 +22,10 @@ module.exports = {
|
||||
},
|
||||
output: {
|
||||
libraryTarget: 'commonjs',
|
||||
path: './Content/Node',
|
||||
path: path.join(__dirname, 'Content', 'Node'),
|
||||
filename: '[name].js'
|
||||
},
|
||||
optimization: {
|
||||
minimize: false
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<Project>
|
||||
<Project>
|
||||
<PropertyGroup>
|
||||
<VersionPrefix>2.1.0</VersionPrefix>
|
||||
<VersionSuffix>preview2</VersionSuffix>
|
||||
<VersionPrefix>3.0.0</VersionPrefix>
|
||||
<VersionSuffix>alpha1</VersionSuffix>
|
||||
<PackageVersion Condition="'$(IsFinalBuild)' == 'true' AND '$(VersionSuffix)' == 'rtm' ">$(VersionPrefix)</PackageVersion>
|
||||
<PackageVersion Condition="'$(IsFinalBuild)' == 'true' AND '$(VersionSuffix)' != 'rtm' ">$(VersionPrefix)-$(VersionSuffix)-final</PackageVersion>
|
||||
<BuildNumber Condition="'$(BuildNumber)' == ''">t000</BuildNumber>
|
||||
|
||||
Reference in New Issue
Block a user