Skip to content

Commit 9f6b0b0

Browse files
Build SpaServices 'Node/Content/*.js' files from TypeScript sources
1 parent dd97ae7 commit 9f6b0b0

File tree

10 files changed

+276
-40
lines changed

10 files changed

+276
-40
lines changed

‎src/Microsoft.AspNetCore.NodeServices/project.json‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,5 +44,11 @@
4444
"embed": [
4545
"Content/**/*"
4646
]
47+
},
48+
"scripts":{
49+
"prepublish": [
50+
"npm install",
51+
"node node_modules/webpack/bin/webpack.js"
52+
]
4753
}
4854
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
/bin/
2+
/node_modules/
Lines changed: 83 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,83 @@
1-
// Pass through the invocation to the 'aspnet-prerendering' package, verifying that it can be loaded
2-
module.exports.renderToString=function(callback){
3-
varaspNetPrerendering;
4-
try{
5-
aspNetPrerendering=require('aspnet-prerendering');
6-
}catch(ex){
7-
// Developers sometimes have trouble with badly-configured Node installations, where it's unable
8-
// to find node_modules. Or they accidentally fail to deploy node_modules, or even to run 'npm install'.
9-
// Make sure such errors are reported back to the .NET part of the app.
10-
callback(
11-
'Prerendering failed because of an error while loading \'aspnet-prerendering\'. Error was: '
12-
+ex.stack
13-
+'\nCurrent directory is: '
14-
+process.cwd()
15-
);
16-
return;
17-
}
18-
19-
returnaspNetPrerendering.renderToString.apply(this,arguments);
20-
};
1+
(function(e,a){for(variina)e[i]=a[i];}(exports,/******/(function(modules){// webpackBootstrap
2+
/******/// The module cache
3+
/******/varinstalledModules={};
4+
5+
/******/// The require function
6+
/******/function__webpack_require__(moduleId){
7+
8+
/******/// Check if module is in cache
9+
/******/if(installedModules[moduleId])
10+
/******/returninstalledModules[moduleId].exports;
11+
12+
/******/// Create a new module (and put it into the cache)
13+
/******/varmodule=installedModules[moduleId]={
14+
/******/exports: {},
15+
/******/id: moduleId,
16+
/******/loaded: false
17+
/******/};
18+
19+
/******/// Execute the module function
20+
/******/modules[moduleId].call(module.exports,module,module.exports,__webpack_require__);
21+
22+
/******/// Flag the module as loaded
23+
/******/module.loaded=true;
24+
25+
/******/// Return the exports of the module
26+
/******/returnmodule.exports;
27+
/******/}
28+
29+
30+
/******/// expose the modules object (__webpack_modules__)
31+
/******/__webpack_require__.m=modules;
32+
33+
/******/// expose the module cache
34+
/******/__webpack_require__.c=installedModules;
35+
36+
/******/// __webpack_public_path__
37+
/******/__webpack_require__.p="";
38+
39+
/******/// Load entry module and return exports
40+
/******/return__webpack_require__(0);
41+
/******/})
42+
/************************************************************************/
43+
/******/([
44+
/* 0 */
45+
/***/function(module,exports,__webpack_require__){
46+
47+
module.exports=__webpack_require__(1);
48+
49+
50+
/***/},
51+
/* 1 */
52+
/***/function(module,exports,__webpack_require__){
53+
54+
"use strict";
55+
// Pass through the invocation to the 'aspnet-prerendering' package, verifying that it can be loaded
56+
functionrenderToString(callback){
57+
varaspNetPrerendering;
58+
try{
59+
aspNetPrerendering=__webpack_require__(2);
60+
}
61+
catch(ex){
62+
// Developers sometimes have trouble with badly-configured Node installations, where it's unable
63+
// to find node_modules. Or they accidentally fail to deploy node_modules, or even to run 'npm install'.
64+
// Make sure such errors are reported back to the .NET part of the app.
65+
callback('Prerendering failed because of an error while loading \'aspnet-prerendering\'. Error was: '
66+
+ex.stack
67+
+'\nCurrent directory is: '
68+
+process.cwd());
69+
return;
70+
}
71+
returnaspNetPrerendering.renderToString.apply(this,arguments);
72+
}
73+
exports.renderToString=renderToString;
74+
75+
76+
/***/},
77+
/* 2 */
78+
/***/function(module,exports){
79+
80+
module.exports=require("aspnet-prerendering");
81+
82+
/***/}
83+
/******/])));
Lines changed: 85 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,85 @@
1-
// Pass through the invocation to the 'aspnet-webpack' package, verifying that it can be loaded
2-
module.exports.createWebpackDevServer=function(callback){
3-
varaspNetWebpack;
4-
try{
5-
aspNetWebpack=require('aspnet-webpack');
6-
}catch(ex){
7-
// Developers sometimes have trouble with badly-configured Node installations, where it's unable
8-
// to find node_modules. Or they accidentally fail to deploy node_modules, or even to run 'npm install'.
9-
// Make sure such errors are reported back to the .NET part of the app.
10-
callback(
11-
'Webpack dev middleware failed because of an error while loading \'aspnet-webpack\'. Error was: '
12-
+ex.stack
13-
+'\nCurrent directory is: '
14-
+process.cwd()
15-
);
16-
return;
17-
}
18-
19-
returnaspNetWebpack.createWebpackDevServer.apply(this,arguments);
20-
};
1+
(function(e,a){for(variina)e[i]=a[i];}(exports,/******/(function(modules){// webpackBootstrap
2+
/******/// The module cache
3+
/******/varinstalledModules={};
4+
5+
/******/// The require function
6+
/******/function__webpack_require__(moduleId){
7+
8+
/******/// Check if module is in cache
9+
/******/if(installedModules[moduleId])
10+
/******/returninstalledModules[moduleId].exports;
11+
12+
/******/// Create a new module (and put it into the cache)
13+
/******/varmodule=installedModules[moduleId]={
14+
/******/exports: {},
15+
/******/id: moduleId,
16+
/******/loaded: false
17+
/******/};
18+
19+
/******/// Execute the module function
20+
/******/modules[moduleId].call(module.exports,module,module.exports,__webpack_require__);
21+
22+
/******/// Flag the module as loaded
23+
/******/module.loaded=true;
24+
25+
/******/// Return the exports of the module
26+
/******/returnmodule.exports;
27+
/******/}
28+
29+
30+
/******/// expose the modules object (__webpack_modules__)
31+
/******/__webpack_require__.m=modules;
32+
33+
/******/// expose the module cache
34+
/******/__webpack_require__.c=installedModules;
35+
36+
/******/// __webpack_public_path__
37+
/******/__webpack_require__.p="";
38+
39+
/******/// Load entry module and return exports
40+
/******/return__webpack_require__(0);
41+
/******/})
42+
/************************************************************************/
43+
/******/([
44+
/* 0 */
45+
/***/function(module,exports,__webpack_require__){
46+
47+
module.exports=__webpack_require__(3);
48+
49+
50+
/***/},
51+
/* 1 */,
52+
/* 2 */,
53+
/* 3 */
54+
/***/function(module,exports,__webpack_require__){
55+
56+
"use strict";
57+
// Pass through the invocation to the 'aspnet-webpack' package, verifying that it can be loaded
58+
functioncreateWebpackDevServer(callback){
59+
varaspNetWebpack;
60+
try{
61+
aspNetWebpack=__webpack_require__(4);
62+
}
63+
catch(ex){
64+
// Developers sometimes have trouble with badly-configured Node installations, where it's unable
65+
// to find node_modules. Or they accidentally fail to deploy node_modules, or even to run 'npm install'.
66+
// Make sure such errors are reported back to the .NET part of the app.
67+
callback('Webpack dev middleware failed because of an error while loading \'aspnet-webpack\'. Error was: '
68+
+ex.stack
69+
+'\nCurrent directory is: '
70+
+process.cwd());
71+
return;
72+
}
73+
returnaspNetWebpack.createWebpackDevServer.apply(this,arguments);
74+
}
75+
exports.createWebpackDevServer=createWebpackDevServer;
76+
77+
78+
/***/},
79+
/* 4 */
80+
/***/function(module,exports){
81+
82+
module.exports=require("aspnet-webpack");
83+
84+
/***/}
85+
/******/])));
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// Pass through the invocation to the 'aspnet-prerendering' package, verifying that it can be loaded
2+
exportfunctionrenderToString(callback){
3+
letaspNetPrerendering;
4+
try{
5+
aspNetPrerendering=require('aspnet-prerendering');
6+
}catch(ex){
7+
// Developers sometimes have trouble with badly-configured Node installations, where it's unable
8+
// to find node_modules. Or they accidentally fail to deploy node_modules, or even to run 'npm install'.
9+
// Make sure such errors are reported back to the .NET part of the app.
10+
callback(
11+
'Prerendering failed because of an error while loading \'aspnet-prerendering\'. Error was: '
12+
+ex.stack
13+
+'\nCurrent directory is: '
14+
+process.cwd()
15+
);
16+
return;
17+
}
18+
19+
returnaspNetPrerendering.renderToString.apply(this,arguments);
20+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// Pass through the invocation to the 'aspnet-webpack' package, verifying that it can be loaded
2+
exportfunctioncreateWebpackDevServer(callback){
3+
letaspNetWebpack;
4+
try{
5+
aspNetWebpack=require('aspnet-webpack');
6+
}catch(ex){
7+
// Developers sometimes have trouble with badly-configured Node installations, where it's unable
8+
// to find node_modules. Or they accidentally fail to deploy node_modules, or even to run 'npm install'.
9+
// Make sure such errors are reported back to the .NET part of the app.
10+
callback(
11+
'Webpack dev middleware failed because of an error while loading \'aspnet-webpack\'. Error was: '
12+
+ex.stack
13+
+'\nCurrent directory is: '
14+
+process.cwd()
15+
);
16+
return;
17+
}
18+
19+
returnaspNetWebpack.createWebpackDevServer.apply(this,arguments);
20+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"compilerOptions":{
3+
"target": "es3",
4+
"module": "commonjs",
5+
"moduleResolution": "node",
6+
"types": ["node"]
7+
},
8+
"exclude": [
9+
"node_modules"
10+
]
11+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"name": "spaservices",
3+
"version": "1.0.0",
4+
"description": "This is not really an NPM package and will not be published. This file exists only to reference compilation tools.",
5+
"main": "index.js",
6+
"scripts":{
7+
"test": "echo \"Error: no test specified\" && exit 1",
8+
"build": "./node_modules/.bin/webpack"
9+
},
10+
"author": "Microsoft",
11+
"license": "Apache-2.0",
12+
"devDependencies":{
13+
"@types/node": "^6.0.42",
14+
"ts-loader": "^0.8.2",
15+
"typescript": "^2.0.0",
16+
"webpack": "^1.13.1"
17+
}
18+
}

‎src/Microsoft.AspNetCore.SpaServices/project.json‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,11 @@
2626
"embed": [
2727
"Content/**/*"
2828
]
29+
},
30+
"scripts":{
31+
"prepublish": [
32+
"npm install",
33+
"node node_modules/webpack/bin/webpack.js"
34+
]
2935
}
3036
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
module.exports={
2+
target: 'node',
3+
externals: [
4+
// These NPM modules are loaded dynamically at runtime, rather than being bundled into the Content/Node/*.js files
5+
// So, at runtime, they have to either be in node_modules or be built-in Node modules (e.g., 'fs')
6+
'aspnet-prerendering',
7+
'aspnet-webpack'
8+
],
9+
resolve: {
10+
extensions: ['.ts']
11+
},
12+
module: {
13+
loaders: [
14+
{test: /\.ts$/,loader: 'ts-loader'},
15+
]
16+
},
17+
entry: {
18+
'prerenderer': ['./TypeScript/Prerenderer'],
19+
'webpack-dev-middleware': ['./TypeScript/WebpackDevMiddleware'],
20+
},
21+
output: {
22+
libraryTarget: 'commonjs',
23+
path: './Content/Node',
24+
filename: '[name].js'
25+
}
26+
};

0 commit comments

Comments
(0)