Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[main] create snippet mini loader #2339

Merged
merged 30 commits into from
Jun 17, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
b0aeb8d
Create miniLoader.ts
siyuniu-ms May 1, 2024
678dc85
add gruntfile
siyuniu-ms May 2, 2024
26584df
Merge branch 'main' into siyu/miniLoader
siyuniu-ms May 2, 2024
51ac9e8
Update miniLoader.ts
siyuniu-ms May 2, 2024
1ec7b39
Merge branch 'siyu/miniLoader' of https://github.com/microsoft/Applic…
siyuniu-ms May 2, 2024
db05c84
change the way of fetching
siyuniu-ms May 8, 2024
46a67ae
add type
siyuniu-ms May 9, 2024
e4450a5
Update miniLoader.ts
siyuniu-ms May 9, 2024
ba4731d
Merge branch 'main' into siyu/miniLoader
siyuniu-ms May 9, 2024
b9b9ba2
add integrity check
siyuniu-ms May 9, 2024
080b67b
Merge branch 'main' into siyu/miniLoader
siyuniu-ms May 9, 2024
48a89b4
change ver name to integrityUrl
siyuniu-ms Jun 4, 2024
a5ee4ec
rename
siyuniu-ms Jun 7, 2024
0b4a3dd
rename
siyuniu-ms Jun 7, 2024
33e230c
merge into current snippet
siyuniu-ms Jun 11, 2024
8d7f6a6
fix regex
siyuniu-ms Jun 12, 2024
b691c7b
remove unnecessary log
siyuniu-ms Jun 12, 2024
e042ae4
Update snippet.ts
siyuniu-ms Jun 12, 2024
fc16f82
rename and remove version
siyuniu-ms Jun 13, 2024
4c59a36
Merge branch 'main' into siyu/miniLoader
siyuniu-ms Jun 13, 2024
23e26f1
Update testVersionConflict.html
siyuniu-ms Jun 13, 2024
35236fb
Merge branch 'siyu/miniLoader' of https://github.com/microsoft/Applic…
siyuniu-ms Jun 13, 2024
2a938f0
Update snippet.ts
siyuniu-ms Jun 14, 2024
d671d8e
Update snippet.ts
siyuniu-ms Jun 14, 2024
556d1e9
add more error case handler
siyuniu-ms Jun 14, 2024
81e342d
refactor
siyuniu-ms Jun 14, 2024
ca67086
shorten regex
siyuniu-ms Jun 15, 2024
81d125b
update corresponding readme, test and sv version
siyuniu-ms Jun 15, 2024
ee9099d
Update testVersionConflict.html
siyuniu-ms Jun 17, 2024
58e2e8a
Update SnippetTests.ts
siyuniu-ms Jun 17, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,19 +102,19 @@ module.exports = function (grunt) {
};
}

function expandJS() {
function expandJS(srcFile) {
var srcPath = "./tools/applicationinsights-web-snippet/build/output";
return {
files: [{
expand: true,
cwd: srcPath,
dest: "./tools/applicationinsights-web-snippet/build/output",
src: "snippet.js"
src: srcFile+".js"
}],
options: {
replacements: function() {

var snippetBuffer = grunt.file.read("./tools/applicationinsights-web-snippet/build/output/snippet.js");
var snippetBuffer = grunt.file.read("./tools/applicationinsights-web-snippet/build/output/" + srcFile + ".js");
var snippetConfig = grunt.file.read("./tools/applicationinsights-web-snippet/src/snippet-config.js").trim();
while(snippetConfig.endsWith("\r") || snippetConfig.endsWith("\n")) {
snippetConfig = snippetConfig.substring(0, snippetConfig.length - 1);
Expand Down Expand Up @@ -777,7 +777,8 @@ module.exports = function (grunt) {
}
},
'string-replace': {
'generate-expanded-JS': expandJS(),
'generate-expanded-JS': expandJS("snippet"),
'generate-expanded-MiniJS': expandJS("miniLoader"),
'generate-expanded-min': expandMin(),
'generate-snippet-ikey': generateNewSnippet(false),
'generate-snippet-connString': generateNewSnippet(true)
Expand Down Expand Up @@ -917,7 +918,7 @@ module.exports = function (grunt) {

grunt.registerTask("websnippet", tsBuildActions("applicationinsights-web-snippet"));
grunt.registerTask("snippetCopy", ["copy:snippet"]);
grunt.registerTask("websnippetReplace", ["string-replace:generate-expanded-JS", "copy:web-snippet", "string-replace:generate-expanded-min", "string-replace:generate-snippet-ikey", "string-replace:generate-snippet-connString"]);
grunt.registerTask("websnippetReplace", ["string-replace:generate-expanded-JS", "string-replace:generate-expanded-MiniJS", "copy:web-snippet", "string-replace:generate-expanded-min", "string-replace:generate-snippet-ikey", "string-replace:generate-snippet-connString"]);

grunt.registerTask("snippet-restore", restoreTasks("applicationinsights-web-snippet"));
grunt.registerTask("websnippettests", tsTestActions("applicationinsights-web-snippet"));
Expand Down
3 changes: 2 additions & 1 deletion tools/applicationinsights-web-snippet/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@
"build": "npm run build:esm && npm run snippet-generate && npm run build:browser && npm run dtsgen",
"build:esm": "grunt websnippet ",
"dtsgen": "api-extractor run --local && node ../../scripts/dtsgen.js \"Microsoft Application Insights Web Snippet\"",
"snippet-generate": "npm run build:snippet && npm run replace && npm run snippetCopy",
"snippet-generate": "npm run build:snippet && npm run build:miniLoader && npm run replace && npm run snippetCopy",
"snippetCopy": "grunt snippetCopy",
"build:snippet": "rollup -c rollupSnippet.config.js --bundleConfigAsCjs",
"build:miniLoader": "rollup -c rollupMiniLoader.config.js --bundleConfigAsCjs",
"replace": "grunt websnippetReplace",
"build:browser": "rollup -c rollup.config.js --bundleConfigAsCjs",
"rebuild": "npm run build",
Expand Down
19 changes: 19 additions & 0 deletions tools/applicationinsights-web-snippet/rollupMiniLoader.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { createUnVersionedConfig } from "../../rollup.base.config";

const miniLoaderOutputName = "miniLoader";
const miniLoaderOutputPath = "../../build/output/miniLoader";

export default createUnVersionedConfig("",
{
namespace: "Microsoft.ApplicationInsights",
version: "",
browser: {
entryPoint: miniLoaderOutputName,
outputName: miniLoaderOutputPath,
inputPath: "build/output",
formats: [{ format: 'cjs', postfix: '', useStrict: false, topLevel: true }],
},
},
[ "applicationinsights-web-snippet" ],
false
);
Loading
Loading