Uso il WebPack con questo semplice file di configurazione per raggruppare la mia applicazione.Debug di javascript in bundle in Visual Studio 2015
var path = require('path');
module.exports = {
debug: true,
devtool: 'source-map',
context: path.join(__dirname, 'js'),
entry: './main.js',
output: {
path: path.join(__dirname, 'Built'),
filename: '[name].bundle.js'
}
};
Questo crea mappatura fonte che posso facilmente usare per eseguire il debug i miei file javascript originali in tutti i browser più diffusi. Tuttavia, l'impostazione del punto di interruzione all'interno di Visual Studio e l'esecuzione del progetto non funziona, i punti di interruzione sono disabilitati dicendo "Nessun simbolo è stato caricato per questo documento". Sto eseguendo il debugging tramite IE11, in cui è possibile eseguire il debug del semplice javascript da Visual Studio, ma dopo averlo raggruppato non funziona più.
C'è un segnale che il sourcemapping funziona, perché ottengo in uscita console Unsupported format of the sourcemap
. Il Sourcemap generato il tramite di configurazione sopra appare così
{"version":3,"sources":["webpack:///webpack/bootstrap 2919a5f916c286b8e21a","webpack:///./main.js","webpack:///./structure_editor/content.js","webpack:///./structure_editor/test_bundle.js"],"names":[],"mappings":";AAAA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA,uBAAe;AACf;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;;AAGA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;;;;;;ACtCA;AACA;;AAEA;AACA;;AAEA;;AAEA;;AAEA;;;;;;;ACVA,8C;;;;;;ACAA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA,6B","file":"main.bundle.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId])\n \t\t\treturn installedModules[moduleId].exports;\n\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\texports: {},\n \t\t\tid: moduleId,\n \t\t\tloaded: false\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.loaded = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(0);\n\n\n\n/** WEBPACK FOOTER **\n ** webpack/bootstrap 2919a5f916c286b8e21a\n **/","document.write(require(\"./structure_editor/content.js\"));\r\nvar TestBundle = require(\"./structure_editor/test_bundle.js\");\r\n\r\nvar test = new TestBundle();\r\ntest.testMe();\r\n\r\n//var StructureEditor = require(\"./structure_editor/structure_editor.js\");\r\n\r\n//var editor = new StructureEditor(0x00FF00);\r\n\r\n//editor.run();\r\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./main.js\n ** module id = 0\n ** module chunks = 0\n **/","module.exports = \"It works from content.js.\";\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./structure_editor/content.js\n ** module id = 1\n ** module chunks = 0\n **/","var TestBundle = function() {\r\n \r\n}\r\n\r\nTestBundle.prototype.testMe = function() {\r\n var a = 10;\r\n var b = 12;\r\n var c = a + b;\r\n document.write(c);\r\n};\r\n\r\nmodule.exports = TestBundle;\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./structure_editor/test_bundle.js\n ** module id = 2\n ** module chunks = 0\n **/"],"sourceRoot":""}
così posso capire che questo formato potrebbe non essere supportata a causa del webpack: // (anche se IE non capirlo). Tuttavia, se sapessi come il formato corretto per VS sembra che potrei essere in grado di ottimizzare webpack per produrre tale formato.
Sto chiedendo idee, tutorial, .. qualunque cosa per farlo funzionare.
Chiedere tutorial è off-topic –
@Thomas Questo potrebbe non essere il caso, quando dopo aver trascorso due giorni interi alla ricerca di una soluzione non c'era nulla di funzionante o completo da trovare. Potrebbe esserci comunque un articolo da qualche parte, che non riceve molta attenzione e potrebbe essere portato a me. Ad ogni modo, il tono di quell'ultima frase dovrebbe indicare che apprezzerò davvero ogni aiuto. – Raven
Mi sono imbattuto nello stesso problema. Ho fatto un paio di tentativi con VS'13 ma senza successo. Ora sto usando il debugger in Chrome, ma sarei molto felice se qualcuno avesse trovato una soluzione. –