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

SourceMap Support #98

Open
robertlong opened this issue Feb 7, 2019 · 6 comments
Open

SourceMap Support #98

robertlong opened this issue Feb 7, 2019 · 6 comments
Assignees
Milestone

Comments

@robertlong
Copy link

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().

@sebavan
Copy link
Member

sebavan commented Feb 7, 2019

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

@sebavan
Copy link
Member

sebavan commented Feb 15, 2019

@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 sebavan self-assigned this Feb 15, 2019
@sebavan sebavan added this to the Version 1.0 milestone Feb 15, 2019
@NathanBWaters
Copy link

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

@leavittx
Copy link

leavittx commented Jun 9, 2021

Hi there! Any updates on this?

@sebavan
Copy link
Member

sebavan commented Jun 9, 2021

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 ???

@prophetw
Copy link

prophetw commented Mar 2, 2022

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;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants