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

babel-preset-optimise additions #149

Open
tunnckoCore opened this issue Jul 19, 2020 · 1 comment
Open

babel-preset-optimise additions #149

tunnckoCore opened this issue Jul 19, 2020 · 1 comment

Comments

@tunnckoCore
Copy link
Owner

tunnckoCore commented Jul 19, 2020

https://ghub.now.sh/babel-preset-optimise

  • @babel/plugin-syntax-import-meta (always included, even when not options.typescript enabled)
  • @babel/plugin-transform-flow-strip-types (if options.typescript disabled)
  • babel-plugin-transform-replace-expressions (thru options.defines)
  • babel-plugin-macros, cuz why not
  • @resugar/codemod-modules-commonjs (part of previously known esnext project), for converting CJS to ESM
    • add options.esmodules - if true, expects CJS input and converts it to ESM;
    • force disable if options.rollup which will mean that you use Rollup + Commonjs plugin + Rollup Babel plugin, in which case Rollup's Commonjs plugin deals with CJS input okay
    • (always) opposite of options.commonjs
  • babel-plugin-add-import-extension adds/replaces extensions

automatically adds /index.${extension} if it's a dir

- import foo from './lib';
+ import foo from './lib/index.js';

a bug:

- import foo from './';
+ import foo from './/index.js';

but this works

- import foo from '.';
+ import foo from './index.js';

or

- import foo from './bar';
+ import foo from './bar.js';

or with replace: true option

- import foo from './src/index.ts';
+ import foo from './src/index.js';

there's also an extension option to the plugin, which is cool too.

Like, forcing some ext with extension: 'ts'

- import foo from './bar';
+ import foo from './bar.ts';

and with both options { extension: 'ts', replace: true }

- import foo from './bar.js';
+ import foo from './bar.ts';
@auto-comment
Copy link

auto-comment bot commented Jul 19, 2020

Thank you for raising this issue! We will try and get back to you as soon as possible.
Please make sure you format it properly, followed our code of conduct, and have given us as much context as possible.
Hey @tunnckoCore, check out this one too! ;)

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

1 participant