chocolateboy/babel-plugin-source-map-support

Doesn't work with Babel v6

Closed this issue ยท 19 comments

Asuza commented

I think I'm using this correctly, but please let me know if I'm not.

My commands:

webpack
babel --plugins source-map-support build/app.js

The result:

TypeError: Plugin is not a function
    at exports.default (src/plugin.js:28:12)
    at Function.memoisePluginContainer (/usr/lib/node_modules/babel-cli/node_modules/babel-core/lib/transformation/file/options/option-manager.js:127:13)
    at Function.normalisePlugin (/usr/lib/node_modules/babel-cli/node_modules/babel-core/lib/transformation/file/options/option-manager.js:161:32)
    at /usr/lib/node_modules/babel-cli/node_modules/babel-core/lib/transformation/file/options/option-manager.js:197:30
    at Array.map (native)
    at Function.normalisePlugins (/usr/lib/node_modules/babel-cli/node_modules/babel-core/lib/transformation/file/options/option-manager.js:173:20)
    at OptionManager.mergeOptions (/usr/lib/node_modules/babel-cli/node_modules/babel-core/lib/transformation/file/options/option-manager.js:271:36)
    at OptionManager.init (/usr/lib/node_modules/babel-cli/node_modules/babel-core/lib/transformation/file/options/option-manager.js:416:10)
    at File.initOptions (/usr/lib/node_modules/babel-cli/node_modules/babel-core/lib/transformation/file/index.js:190:75)
    at new File (/usr/lib/node_modules/babel-cli/node_modules/babel-core/lib/transformation/file/index.js:121:22)

Is this plugin broken in Babel 6?

Is this plugin broken in Babel 6?

Yes. It hasn't been updated yet.

@chocolateboy Is support for babel@6 planned?

gajus commented

Just in case, Babel 6 plugin would look like this:

import 'source-map-support/register';

/*
 * return the AST for this statement:
 *
 *     _sourceMapSupportRegister.install({ handleUncaughtException: true })
 */
function handleUncaughtExceptionNode(t, id) {
    return t.expressionStatement(
        t.callExpression(
            t.memberExpression(
                id,
                t.identifier('install')
            ), [
                t.objectExpression([
                    t.property(
                        'init',
                        t.identifier('handleUncaughtException'),
                        t.literal(true)
                    )
                ])
            ]
        )
    );
}

export default ({types: t}) => {
    return {
        visitor: {
            Program (path, {file}) {
                let id;

                id = file.addImport(
                    'source-map-support/register',
                    null,
                    'absolute'
                );
            }
        }
    };
};

I would also recommend replacing:

id = file.addImport(
   'source-map-support/register',
    null,
    'absolute'
);

with

id = file.addImport(
    require.resolve('source-map-support/register'),
    null,
    'absolute'
);

This will remove the need of the source-map-support peer dependency and since this transformation is used only in development, there is never a reasonable case where babel-plugin-source-map-support is not going to be installed and therefore require.resolve('source-map-support/register') unresolvable.

@gajus I don't have time to dive into this at the moment. Feel free to submit a PR (against the develop branch).

@chocolateboy , please publish a new version to npm.

@mariodu Can you take a look at the error? Thanks.

It seems you have it working, so maybe I do not have correct dependencies. I made sure to install babel-cli@6.4.5 and replaced the files for babel-plugin-source-map-support under node_modules.

@mykohsu node version?

Should be 5.4 or 5.5. I'll double check tomorrow.

@mariodu Node is 4.2.6.

@chocolateboy what's the status of this, has the module been abandoned?

@mariodu I tried your fork (babel-plugin-source-map-support-node-6) and it wasn't working with the latest version of babel 6 (on node 6.2.1). what's the trick to getting it working? is there a particular order that things need to be imported/required?

@shellscape I just don't have time to update it at the moment. The document explaining the new way of doing things is pretty hefty, and I just haven't got round to reading it.

If someone creates a working update and prompts (OK, nags) me, then I will push a new version to NPM.

I'll add it to my list, see if I can make a dent. Cheers

what is the progress on this?

Forget the mess of babel.
Just use Typescript to save you from misery.

On Tue, Nov 1, 2016 at 7:11 PM, Sibelius Seraphini <notifications@github.com

wrote:

what is the progress on this?

โ€”
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
#1 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAU6Fe2ttSP5SPbfrClxVJ8XNvY4aLRGks5q5x5xgaJpZM4GzFiS
.

I'd love if someone made a new version of this.

Any plans to release with the merged #3 to npm?

Thanks, all, for your patience, patches and polite prompting. I've just published version 1.0.0 to NPM, which adds support for Babel >= 6.x (and removes support for Babel 5.x). Let me know if you spot any problems.