Switch to using webpack, check in bootstrap code
This commit is contained in:
Родитель
c6442b4f2e
Коммит
a629c2c1de
|
@ -1,15 +0,0 @@
|
|||
({
|
||||
include: ["applicationinsights-analytics-js", "applicationinsights-core-js", "applicationinsights-channel-js", "applicationinsights-common"],
|
||||
paths: {
|
||||
'applicationinsights-analytics-js': 'applicationinsights-analytics-js',
|
||||
'applicationinsights-core-js': 'applicationinsights-core-js',
|
||||
'applicationinsights-channel-js': 'applicationinsights-channel-js',
|
||||
'applicationinsights-common': 'applicationinsights-common'},
|
||||
name: "aisdk-js",
|
||||
baseUrl: "bundle/sources",
|
||||
out: "out.js",
|
||||
optimize: "none",
|
||||
shim : {
|
||||
"aisdk-js" : ["applicationinsights-analytics-js", "applicationinsights-channel-js", "applicationinsights-common", "applicationinsights-core-js"]
|
||||
}
|
||||
})
|
|
@ -0,0 +1,26 @@
|
|||
{
|
||||
"name": "applicationinsights-sdk-js",
|
||||
"version": "0.0.8",
|
||||
"description": "Microsoft Application Insights Javascript SDK apis",
|
||||
"main": "bundle/applicationinsights-sdk-js.js",
|
||||
"types": "bundle/applicationinsights-sdk-js.d.ts",
|
||||
"devDependencies": {
|
||||
"require.js": "^1.0.0",
|
||||
"typescript": "2.5.3",
|
||||
"webpack": "2.5.1",
|
||||
"webpack-cli": "^3.1.0",
|
||||
"webpack-command": "^0.4.1"
|
||||
},
|
||||
"publishConfig": {
|
||||
"registry": "https://mseng.pkgs.visualstudio.com/_packaging/ApplicationInsights-Team/npm/registry"
|
||||
},
|
||||
"dependencies": {
|
||||
"applicationinsights-analytics-js": "0.0.67",
|
||||
"applicationinsights-channel-js": "0.0.25",
|
||||
"applicationinsights-common": "0.0.65",
|
||||
"applicationinsights-core-js": "0.0.59",
|
||||
"source-map-loader": "^0.2.3",
|
||||
"ts-loader": "^4.4.2",
|
||||
"webpack": "^4.16.4"
|
||||
}
|
||||
}
|
|
@ -1,9 +0,0 @@
|
|||
// to generate single file, run from the scripts directory > r.js.cmd -o app.build.js
|
||||
// Run npm install requirejs to get r.js.cmd
|
||||
({
|
||||
findNestedDependencies: true,
|
||||
baseUrl: "../bundle", // all dependencies should be copied from bundle/ to bundle folder
|
||||
optimize: "none", // change to uglify to generate minified code
|
||||
out: "aisdkfinal.min.js",
|
||||
include: ["Init"]
|
||||
});
|
Различия файлов скрыты, потому что одна или несколько строк слишком длинны
Различия файлов скрыты, потому что одна или несколько строк слишком длинны
Различия файлов скрыты, потому что одна или несколько строк слишком длинны
|
@ -5,16 +5,22 @@
|
|||
"main": "bundle/applicationinsights-sdk-js.js",
|
||||
"types": "bundle/applicationinsights-sdk-js.d.ts",
|
||||
"devDependencies": {
|
||||
"require.js": "^1.0.0",
|
||||
"typescript": "2.5.3",
|
||||
"require.js": "^1.0.0"
|
||||
"webpack": "2.5.1",
|
||||
"webpack-cli": "^3.1.0",
|
||||
"webpack-command": "^0.4.1"
|
||||
},
|
||||
"publishConfig": {
|
||||
"registry": "https://mseng.pkgs.visualstudio.com/_packaging/ApplicationInsights-Team/npm/registry"
|
||||
},
|
||||
"dependencies": {
|
||||
"applicationinsights-core-js": "0.0.59",
|
||||
"applicationinsights-analytics-js": "0.0.65",
|
||||
"applicationinsights-analytics-js": "0.0.67",
|
||||
"applicationinsights-channel-js": "0.0.25",
|
||||
"applicationinsights-common": "0.0.65"
|
||||
"applicationinsights-common": "0.0.65",
|
||||
"applicationinsights-core-js": "0.0.59",
|
||||
"source-map-loader": "^0.2.3",
|
||||
"ts-loader": "^4.4.2",
|
||||
"webpack": "^4.16.4"
|
||||
}
|
||||
}
|
||||
|
|
Двоичный файл не отображается.
|
@ -0,0 +1,54 @@
|
|||
var appInsights = window.appInsightsvNext || (function (aiConfig) {
|
||||
var appInsights = {
|
||||
config: aiConfig
|
||||
};
|
||||
|
||||
// Assigning these to local variables allows them to be minified to save space:
|
||||
var localDocument = document;
|
||||
var localWindow = window;
|
||||
var scriptText = "script";
|
||||
var track = "Track";
|
||||
setTimeout(function () {
|
||||
var scriptElement = localDocument.createElement(scriptText);
|
||||
scriptElement.src = aiConfig.url || "https://jssdkvnext.blob.core.windows.net/scripts/aisdk.js";
|
||||
localDocument.getElementsByTagName(scriptText)[0].parentNode.appendChild(scriptElement);
|
||||
});
|
||||
|
||||
// capture initial cookie
|
||||
try {
|
||||
appInsights.cookie = localDocument.cookie;
|
||||
} catch (e) { }
|
||||
|
||||
appInsights.queue = [];
|
||||
|
||||
function createLazyMethod(name) {
|
||||
// Define a temporary method that queues-up a the real method call
|
||||
appInsights[name] = function () {
|
||||
// Capture the original arguments passed to the method
|
||||
var originalArguments = arguments;
|
||||
// Queue-up a call to the real method
|
||||
appInsights.queue.push(function () {
|
||||
// Invoke the real method with the captured original arguments
|
||||
appInsights[name].apply(appInsights, originalArguments);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
var method = ["PageView"];
|
||||
while (method.length) {
|
||||
createLazyMethod("track" + method.pop());
|
||||
}
|
||||
|
||||
return appInsights;
|
||||
})({
|
||||
instrumentationKey: "INSTRUMENTATION_KEY",
|
||||
|
||||
});
|
||||
|
||||
// global instance must be set in this order to mitigate issues in ie8 and lower
|
||||
window.appInsightsvNext = appInsights;
|
||||
|
||||
// if somebody calls the snippet twice, don't report page view again
|
||||
if (appInsights.queue && appInsights.queue.length === 0) {
|
||||
appInsights.trackPageView();
|
||||
}
|
|
@ -0,0 +1,55 @@
|
|||
// command to create bundle: npx webpack --config webpack.config.js
|
||||
var webpack = require('webpack');
|
||||
var package = require('./package.json')
|
||||
var filename_suffix = "./aisdk." + package.version;
|
||||
var filename;
|
||||
var entry = {};
|
||||
var plugins = [];
|
||||
entry.sdk = ["./amd/bundle/Init.js"];
|
||||
|
||||
module.exports = function (env) {
|
||||
if (env.minify) {
|
||||
plugins.push(new webpack.optimize.UglifyJsPlugin({
|
||||
sourceMap: true,
|
||||
mangle: {
|
||||
props: {
|
||||
regex: /^_/
|
||||
}
|
||||
}
|
||||
}));
|
||||
filename_suffix = filename_suffix + ".min";
|
||||
}
|
||||
|
||||
filename = filename_suffix + ".js";
|
||||
|
||||
return {
|
||||
entry: entry,
|
||||
mode: "development",
|
||||
output: {
|
||||
filename: filename,
|
||||
libraryTarget: "umd"
|
||||
},
|
||||
// Enable sourcemaps for debugging webpack's output.
|
||||
devtool: "source-map",
|
||||
|
||||
|
||||
resolve: {
|
||||
// Add '.ts' and '.tsx' as resolvable extensions.
|
||||
extensions: [".webpack.js", ".web.js", ".ts", ".tsx", ".js"]
|
||||
},
|
||||
|
||||
plugins: plugins,
|
||||
|
||||
module: {
|
||||
rules: [
|
||||
// All output '.js' files will have any sourcemaps re-processed by 'source-map-loader'.
|
||||
{
|
||||
test: /\.js$/,
|
||||
use: ["source-map-loader"],
|
||||
exclude: /node_modules/,
|
||||
enforce: "pre"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,55 @@
|
|||
// command to create bundle: npx webpack --config webpack.config.js
|
||||
var webpack = require('webpack');
|
||||
var package = require('./package.json')
|
||||
var filename_suffix = "./aisdk." + package.version;
|
||||
var filename;
|
||||
var entry = {};
|
||||
var plugins = [];
|
||||
entry.sdk = ["./amd/bundle/Init.js"];
|
||||
|
||||
module.exports = function (env) {
|
||||
if (env.minify) {
|
||||
plugins.push(new webpack.optimize.UglifyJsPlugin({
|
||||
sourceMap: true,
|
||||
mangle: {
|
||||
props: {
|
||||
regex: /^_/
|
||||
}
|
||||
}
|
||||
}));
|
||||
filename_suffix = filename_suffix + ".min";
|
||||
}
|
||||
|
||||
filename = filename_suffix + ".js";
|
||||
|
||||
return {
|
||||
entry: entry,
|
||||
mode: "production",
|
||||
output: {
|
||||
filename: filename,
|
||||
libraryTarget: "umd"
|
||||
},
|
||||
// Enable sourcemaps for debugging webpack's output.
|
||||
devtool: "source-map",
|
||||
|
||||
|
||||
resolve: {
|
||||
// Add '.ts' and '.tsx' as resolvable extensions.
|
||||
extensions: [".webpack.js", ".web.js", ".ts", ".tsx", ".js"]
|
||||
},
|
||||
|
||||
plugins: plugins,
|
||||
|
||||
module: {
|
||||
rules: [
|
||||
// All output '.js' files will have any sourcemaps re-processed by 'source-map-loader'.
|
||||
{
|
||||
test: /\.js$/,
|
||||
use: ["source-map-loader"],
|
||||
exclude: /node_modules/,
|
||||
enforce: "pre"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
20
gruntfile.js
20
gruntfile.js
|
@ -135,10 +135,28 @@ module.exports = function (grunt) {
|
|||
}
|
||||
},
|
||||
},
|
||||
aivNext: {
|
||||
files: {
|
||||
'AISKU/dist/aisdk.0.js': ['AISKU/dist/aisdk.js'],
|
||||
},
|
||||
options: {
|
||||
compress: {
|
||||
ie8: true
|
||||
},
|
||||
mangle: {
|
||||
ie8: true
|
||||
}
|
||||
},
|
||||
},
|
||||
snippet: {
|
||||
files: {
|
||||
'bundle/snippet/snippet.min.js': ['JavaScript/JavaScriptSDK/snippet.js']
|
||||
}
|
||||
},
|
||||
snippetvNext: {
|
||||
files: {
|
||||
'AISKU/dist/snippet.min.js': ['AISKU/snippet/snippet.js']
|
||||
}
|
||||
}
|
||||
},
|
||||
qunit: {
|
||||
|
@ -188,6 +206,6 @@ module.exports = function (grunt) {
|
|||
grunt.registerTask("ai", ["ts:appinsights"]);
|
||||
grunt.registerTask("aitests", ["ts:appinsights", "ts:appinsightstests", "qunit:aitests"]);
|
||||
grunt.registerTask("aicjs", ["ts:appinsightscjs"]);
|
||||
grunt.registerTask("aisku", ["ts:aisku"]);
|
||||
grunt.registerTask("aisku", ["ts:aisku", "uglify:aivNext", "uglify:snippetvNext"]);
|
||||
grunt.registerTask("test", ["ts:default", "ts:test", "ts:testSchema", "ts:testE2E", "ts:types", "qunit:all"]);
|
||||
};
|
Загрузка…
Ссылка в новой задаче