Skip to content

Commit

Permalink
Improve code documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
pascalduez committed Oct 28, 2024
1 parent 2a2d4b5 commit 8802852
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,42 +11,47 @@
* [Hermes Parser]
* https://github.com/facebook/hermes/blob/main/tools/hermes-parser/js/babel-plugin-syntax-hermes-parser
*
* [Other]
* [Ponyfills]
* https://babeljs.io/docs/en/babel-plugin-transform-runtime
*/

/**
* Notes
* [Notes]
*
* Presets are run in the reverse order they are defined.
* Plugins are run in the order they are defined below,
* but they are run *before* presets.
*/

/**
* 1. https://babeljs.io/docs/babel-generator#:~:text=importAttributesKeyword
* 1. Will be set as default from Babel 8.
*
* 2. Ensure all helpers are imported instead of inlined.
* See https://github.com/babel/babel/issues/9297#issuecomment-453750049
*
* 3. https://babeljs.io/docs/babel-generator#:~:text=importAttributesKeyword
*
* 4. https://babeljs.io/docs/babel-preset-flow#allowdeclarefields
* See `Regression: Flow void class properties` test.
*/

module.exports = (context, options = {}) => {
let { parser = 'babel', ...envOptions } = options;

let configOpts = {
generatorOpts: {
importAttributesKeyword: 'with', // 1
importAttributesKeyword: 'with', // 3
},
};

let envOpts = {
bugfixes: true,
bugfixes: true, // 1
...envOptions,
};

let reactOpts = {
useSpread: true,
runtime: 'automatic',
useSpread: true, // 1
runtime: 'automatic', // 1
};

let runtimeOpts = {
Expand All @@ -56,10 +61,14 @@ module.exports = (context, options = {}) => {
version: '7.26.0', // 2
};

let flowOpts = {
// allowDeclareFields: true, // 4
};

let presets = [
['@babel/preset-env', envOpts],
['@babel/preset-react', reactOpts],
'@babel/preset-flow',
['@babel/preset-flow', flowOpts],
];

let plugins = [
Expand Down

0 comments on commit 8802852

Please sign in to comment.