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

Specifying babelify options with node API #239

Open
dbrgn opened this issue Jan 7, 2019 · 2 comments
Open

Specifying babelify options with node API #239

dbrgn opened this issue Jan 7, 2019 · 2 comments

Comments

@dbrgn
Copy link

dbrgn commented Jan 7, 2019

How can I pass babelify options using the node API?

With the command line API, I can do something like this:

-t [ babelify --presets [ env ] --extensions .ts ]

But with the Node API, this fails:

budo('src/app.ts:dist/app.js', {
    ...
    browserify: {
        transform: [babelify, {
            presets: ['@babel/preset-env'],
            extensions: '.ts',
        }],
    },
    ...

The error messages is TypeError: Path must be a string.. That error message comes from node_modules/resolve/lib/async.js.

What's the proper syntax for passing options to babelify? Maybe an example could be added to the README.

@mattdesl
Copy link
Owner

mattdesl commented Jan 7, 2019

Probably the best is to require('babelify').configure({ ... })

You can also use subarg with a nested array, I believe. Not at my work station now to check, though.

budo('src/app.ts:dist/app.js', {
    ...
    browserify: {
        transform: [
            [ babelify, {
              presets: ['@babel/preset-env'],
              extensions: '.ts',
            } ]
        ],
    }

@dbrgn
Copy link
Author

dbrgn commented Jan 8, 2019

@mattdesl thanks, that seems to work! However, now I'm having issues with specifying a plugin.

This works:

budo src/app.ts:dist/app.js \
    -d public -d . -d src \
    --live -- \
        -d -p tsify -t [ babelify --presets [ @babel/env ] --extensions .ts ]

However, with this node based config...

budo('src/app.ts:dist/app.js', {
    dir: ['public', '.', 'src'],
    live: true,
    stream: process.stdout,
    port: 9966,
    debug: true,
    browserify: {
        plugin: tsify,
        transform: [babelify.configure({
            presets: ['@babel/preset-env'],
            extensions: '.ts',
        })],
    },
})

...I'm getting TypeScript errors:

img

It seems that the TypeScript files aren't being processed, even though the two configs look equivalent to me (but I must be overlooking something).

Any idea?

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

No branches or pull requests

2 participants