Spector.js icon indicating copy to clipboard operation
Spector.js copied to clipboard

SourceMap Support

Open robertlong opened this issue 6 years ago • 6 comments

The stack trace for each command is really useful, it'd be even better if it used sourcemaps. Maybe this library could be of some use? https://github.com/evanw/node-source-map-support I'm not certain, but it may be as simple as including the library and calling install().

robertlong avatar Feb 07 '19 18:02 robertlong

Nice, I really like the idea, I ll check over the weekend :-)

sebavan avatar Feb 07 '19 19:02 sebavan

@robertlong, I started to play with it, it is pretty promising. I am currently moving to modules and React. I ll integrate it in first thing after that step as a test of the new archi.

sebavan avatar Feb 15 '19 17:02 sebavan

+1 on this idea! It would be extremely useful!

NathanBWaters avatar Jun 17 '20 22:06 NathanBWaters

Hi there! Any updates on this?

leavittx avatar Jun 09 '21 06:06 leavittx

I had perf issues when using it :-( and currently pretty stuffed with normal work. Happy to guide anybody who would like to make a PR for it ???

sebavan avatar Jun 09 '21 13:06 sebavan

Just use the webpack development to build your code and easy to debug

 mode: isProd ? "development" : "development",
optimization: {
            minimize: false,
            // moduleIds: "size",
            // usedExports: true,
            mangleExports: false,
        },

webpack.config.js below

Spector.js/tools/webpack.config.js
var path = require("path");

var MAIN_DIR = path.resolve(__dirname, "../");
var BUILD_DIR = path.resolve(MAIN_DIR, "./dist");
var DEV_DIR = path.resolve(MAIN_DIR, "./.temp");

var buildConfig = function (env) {
    var isProd = env.prod;

    var config = {
        watch: !isProd,
        context: MAIN_DIR,
        entry: [
            "./vendors/ace.js",
            "./vendors/ace-mode-glsl.js",
            "./vendors/ace-theme-monokai.js",
            "./vendors/ace-theme-override.css",
            "./vendors/ace-ext-searchbox.js",
            "./src/spector.ts"
        ],
        output: {
            path: isProd ? BUILD_DIR : DEV_DIR,
            publicPath: "/",
            filename: "spector.bundle.js",
            libraryTarget: "umd",
            library: "SPECTOR",
            umdNamedDefine: true
        },
        optimization: {
            minimize: false,
            // moduleIds: "size",
            // usedExports: true,
            mangleExports: false,
        },
        performance: {
            hints: false
        },
        resolve: {
            extensions: [".ts", ".tsx", ".js", ".css", ".sass"]
        },
        // devtool: false,
        devtool: 'source-map',
        mode: isProd ? "development" : "development",
        module: {
            rules: [{
                test: /\.tsx?$/,
                loader: "ts-loader",
                options: {
                    configFile: "src/tsconfig.json"
                }
            }, {
                test: /\.scss$/,
                use: ["style-loader?insert=html", "css-loader", "sass-loader"]
            }, {
                test: /\.css$/,
                use: ["style-loader?insert=html", "css-loader"]
            }, {
                test: /ace.js$/,
                // use: [ "exports-loader?ace" ]
                loader: "exports-loader",
                options: {
                    type: "commonjs",
                    exports: "ace",
                },
            }, {
                test: /spector.js$/,
                use: ["exports-loader?SPECTOR"]
            }]
        }
    };

    if (!isProd) {
        config.devtool = "nosources-source-map";

        // Source Map Remapping for dev tools.
        config.output.devtoolModuleFilenameTemplate = (info) => {
            info.resourcePath = path.normalize(info.resourcePath);

            console.error(info.resourcePath);

            // if (!path.isAbsolute(info.resourcePath)) {
            //     info.resourcePath = path.join(DEV_DIR, info.resourcePath);
            // }

            return `../${info.resourcePath.replace(/\\/g, "/")}`;
        };
    }
    return config;
}

module.exports = buildConfig;

prophetw avatar Mar 02 '22 03:03 prophetw