mirror of
https://github.com/aspnet/JavaScriptServices.git
synced 2025-12-23 01:58:29 +00:00
Build SpaServices 'Node/Content/*.js' files from TypeScript sources
This commit is contained in:
@@ -44,5 +44,11 @@
|
|||||||
"embed": [
|
"embed": [
|
||||||
"Content/**/*"
|
"Content/**/*"
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
"scripts": {
|
||||||
|
"prepublish": [
|
||||||
|
"npm install",
|
||||||
|
"node node_modules/webpack/bin/webpack.js"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1 +1,2 @@
|
|||||||
/bin/
|
/bin/
|
||||||
|
/node_modules/
|
||||||
|
|||||||
@@ -1,20 +1,83 @@
|
|||||||
// Pass through the invocation to the 'aspnet-prerendering' package, verifying that it can be loaded
|
(function(e, a) { for(var i in a) e[i] = a[i]; }(exports, /******/ (function(modules) { // webpackBootstrap
|
||||||
module.exports.renderToString = function (callback) {
|
/******/ // The module cache
|
||||||
var aspNetPrerendering;
|
/******/ var installedModules = {};
|
||||||
try {
|
|
||||||
aspNetPrerendering = require('aspnet-prerendering');
|
|
||||||
} 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(
|
|
||||||
'Prerendering failed because of an error while loading \'aspnet-prerendering\'. Error was: '
|
|
||||||
+ ex.stack
|
|
||||||
+ '\nCurrent directory is: '
|
|
||||||
+ process.cwd()
|
|
||||||
);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
return aspNetPrerendering.renderToString.apply(this, arguments);
|
/******/ // The require function
|
||||||
};
|
/******/ function __webpack_require__(moduleId) {
|
||||||
|
|
||||||
|
/******/ // Check if module is in cache
|
||||||
|
/******/ 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
|
||||||
|
/******/ };
|
||||||
|
|
||||||
|
/******/ // Execute the module function
|
||||||
|
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
|
||||||
|
|
||||||
|
/******/ // Flag the module as loaded
|
||||||
|
/******/ module.loaded = 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;
|
||||||
|
|
||||||
|
/******/ // __webpack_public_path__
|
||||||
|
/******/ __webpack_require__.p = "";
|
||||||
|
|
||||||
|
/******/ // Load entry module and return exports
|
||||||
|
/******/ return __webpack_require__(0);
|
||||||
|
/******/ })
|
||||||
|
/************************************************************************/
|
||||||
|
/******/ ([
|
||||||
|
/* 0 */
|
||||||
|
/***/ function(module, exports, __webpack_require__) {
|
||||||
|
|
||||||
|
module.exports = __webpack_require__(1);
|
||||||
|
|
||||||
|
|
||||||
|
/***/ },
|
||||||
|
/* 1 */
|
||||||
|
/***/ function(module, exports, __webpack_require__) {
|
||||||
|
|
||||||
|
"use strict";
|
||||||
|
// Pass through the invocation to the 'aspnet-prerendering' package, verifying that it can be loaded
|
||||||
|
function renderToString(callback) {
|
||||||
|
var aspNetPrerendering;
|
||||||
|
try {
|
||||||
|
aspNetPrerendering = __webpack_require__(2);
|
||||||
|
}
|
||||||
|
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('Prerendering failed because of an error while loading \'aspnet-prerendering\'. Error was: '
|
||||||
|
+ ex.stack
|
||||||
|
+ '\nCurrent directory is: '
|
||||||
|
+ process.cwd());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
return aspNetPrerendering.renderToString.apply(this, arguments);
|
||||||
|
}
|
||||||
|
exports.renderToString = renderToString;
|
||||||
|
|
||||||
|
|
||||||
|
/***/ },
|
||||||
|
/* 2 */
|
||||||
|
/***/ function(module, exports) {
|
||||||
|
|
||||||
|
module.exports = require("aspnet-prerendering");
|
||||||
|
|
||||||
|
/***/ }
|
||||||
|
/******/ ])));
|
||||||
@@ -1,20 +1,85 @@
|
|||||||
// Pass through the invocation to the 'aspnet-webpack' package, verifying that it can be loaded
|
(function(e, a) { for(var i in a) e[i] = a[i]; }(exports, /******/ (function(modules) { // webpackBootstrap
|
||||||
module.exports.createWebpackDevServer = function (callback) {
|
/******/ // The module cache
|
||||||
var aspNetWebpack;
|
/******/ var installedModules = {};
|
||||||
try {
|
|
||||||
aspNetWebpack = require('aspnet-webpack');
|
|
||||||
} 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);
|
/******/ // The require function
|
||||||
};
|
/******/ function __webpack_require__(moduleId) {
|
||||||
|
|
||||||
|
/******/ // Check if module is in cache
|
||||||
|
/******/ 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
|
||||||
|
/******/ };
|
||||||
|
|
||||||
|
/******/ // Execute the module function
|
||||||
|
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
|
||||||
|
|
||||||
|
/******/ // Flag the module as loaded
|
||||||
|
/******/ module.loaded = 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;
|
||||||
|
|
||||||
|
/******/ // __webpack_public_path__
|
||||||
|
/******/ __webpack_require__.p = "";
|
||||||
|
|
||||||
|
/******/ // Load entry module and return exports
|
||||||
|
/******/ return __webpack_require__(0);
|
||||||
|
/******/ })
|
||||||
|
/************************************************************************/
|
||||||
|
/******/ ([
|
||||||
|
/* 0 */
|
||||||
|
/***/ function(module, exports, __webpack_require__) {
|
||||||
|
|
||||||
|
module.exports = __webpack_require__(3);
|
||||||
|
|
||||||
|
|
||||||
|
/***/ },
|
||||||
|
/* 1 */,
|
||||||
|
/* 2 */,
|
||||||
|
/* 3 */
|
||||||
|
/***/ 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__(4);
|
||||||
|
}
|
||||||
|
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;
|
||||||
|
|
||||||
|
|
||||||
|
/***/ },
|
||||||
|
/* 4 */
|
||||||
|
/***/ function(module, exports) {
|
||||||
|
|
||||||
|
module.exports = require("aspnet-webpack");
|
||||||
|
|
||||||
|
/***/ }
|
||||||
|
/******/ ])));
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
// Pass through the invocation to the 'aspnet-prerendering' package, verifying that it can be loaded
|
||||||
|
export function renderToString(callback) {
|
||||||
|
let aspNetPrerendering;
|
||||||
|
try {
|
||||||
|
aspNetPrerendering = require('aspnet-prerendering');
|
||||||
|
} 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(
|
||||||
|
'Prerendering failed because of an error while loading \'aspnet-prerendering\'. Error was: '
|
||||||
|
+ ex.stack
|
||||||
|
+ '\nCurrent directory is: '
|
||||||
|
+ process.cwd()
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
return aspNetPrerendering.renderToString.apply(this, arguments);
|
||||||
|
}
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
// Pass through the invocation to the 'aspnet-webpack' package, verifying that it can be loaded
|
||||||
|
export function createWebpackDevServer(callback) {
|
||||||
|
let aspNetWebpack;
|
||||||
|
try {
|
||||||
|
aspNetWebpack = require('aspnet-webpack');
|
||||||
|
} 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);
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"target": "es3",
|
||||||
|
"module": "commonjs",
|
||||||
|
"moduleResolution": "node",
|
||||||
|
"types": ["node"]
|
||||||
|
},
|
||||||
|
"exclude": [
|
||||||
|
"node_modules"
|
||||||
|
]
|
||||||
|
}
|
||||||
18
src/Microsoft.AspNetCore.SpaServices/package.json
Normal file
18
src/Microsoft.AspNetCore.SpaServices/package.json
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
{
|
||||||
|
"name": "spaservices",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"description": "This is not really an NPM package and will not be published. This file exists only to reference compilation tools.",
|
||||||
|
"main": "index.js",
|
||||||
|
"scripts": {
|
||||||
|
"test": "echo \"Error: no test specified\" && exit 1",
|
||||||
|
"build": "./node_modules/.bin/webpack"
|
||||||
|
},
|
||||||
|
"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"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -26,5 +26,11 @@
|
|||||||
"embed": [
|
"embed": [
|
||||||
"Content/**/*"
|
"Content/**/*"
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
"scripts": {
|
||||||
|
"prepublish": [
|
||||||
|
"npm install",
|
||||||
|
"node node_modules/webpack/bin/webpack.js"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
26
src/Microsoft.AspNetCore.SpaServices/webpack.config.js
Normal file
26
src/Microsoft.AspNetCore.SpaServices/webpack.config.js
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
module.exports = {
|
||||||
|
target: 'node',
|
||||||
|
externals: [
|
||||||
|
// These NPM modules are loaded dynamically at runtime, rather than being bundled into the Content/Node/*.js files
|
||||||
|
// So, at runtime, they have to either be in node_modules or be built-in Node modules (e.g., 'fs')
|
||||||
|
'aspnet-prerendering',
|
||||||
|
'aspnet-webpack'
|
||||||
|
],
|
||||||
|
resolve: {
|
||||||
|
extensions: [ '.ts' ]
|
||||||
|
},
|
||||||
|
module: {
|
||||||
|
loaders: [
|
||||||
|
{ test: /\.ts$/, loader: 'ts-loader' },
|
||||||
|
]
|
||||||
|
},
|
||||||
|
entry: {
|
||||||
|
'prerenderer': ['./TypeScript/Prerenderer'],
|
||||||
|
'webpack-dev-middleware': ['./TypeScript/WebpackDevMiddleware'],
|
||||||
|
},
|
||||||
|
output: {
|
||||||
|
libraryTarget: 'commonjs',
|
||||||
|
path: './Content/Node',
|
||||||
|
filename: '[name].js'
|
||||||
|
}
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user