npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

babel-preset-vnmf

v3.5.66

Published

Vnmf babel preset

Downloads

52

Readme


title: Babel Configuration

The Babel configuration of the Vnmf project is located in the babel.config.js file in the root directory, which adds a preset by default: babel-preset-vnmf, which will add some commonly used presets and according to the project's technology stack plugins.

module.exports = {
  presets: [
    ['vnmf', {/** configuration items */}]
  ]
}

Developers can modify babel.config.js, modify the configuration items of babel-preset-vnmf, or add presets and plugins they want.

babel-preset-vnmf

babel-preset-vnmf will selectively use the following presets and plugins according to the current project's technology stack.

1. Generic

presets
  • @babel/preset-env
  • @babel/preset-typescript (TypeScript environment)
plugins
  • @babel/plugin-transform-runtime
  • @babel/plugin-proposal-decorators
  • @babel/plugin-proposal-class-properties
  • babel-plugin-dynamic-import-node (applet environment)

2. React

presets
  • @babel/preset-react
plugins
  • react-refresh/babel

3. Vue

presets
  • @vue/babel-preset-jsx

4. Vue3

plugins
  • @vue/babel-plugin-jsx

The configuration items of babel-preset-vnmf will be described in detail below.

reactJsxRuntime

:::note Only works when using React. :::

Default value: 'automatic'

The runtime configuration of @babel/preset-react.

hot

:::note Only works when using React. :::

default: true

Whether to introduce react-refresh/babel to support using fast-refresh.

vueJsx

:::note Only works when using Vue/Vue3. :::

default: true

type: true | false | object

Whether to use @vue/babel-preset-jsx (Vue) or @vue/babel-plugin-jsx (Vue3) to support using jsx.

When passing an object, it is equivalent to setting true, and the object will be used as @vue/babel-preset-jsx (Vue) or @vue/babel-plugin-jsx ( Vue3) parameters.

targets

Defaults:

{
  ios: '9',
  android: '5'
}

The targets configuration item of @babel/preset-env.

useBuiltIns

Default value: false

Valid values: 'entry' | 'usage' | false

useBuiltIns: 'entry'

:::info Advantage: Completely global polyfill, even if there is incompatible code in the dependencies in node_modules, it can run successfully.

Disadvantages: May introduce redundant code, affect global variables. :::

When 'entry' is passed, the useBuiltIns option of @babel/preset-env will be set to ' entry', the corejs option is set to '3'.

Developers need to import core-js in the entry file app.js:

import "core-js"

Babel will introduce the corresponding core-js dependencies according to targets. For example, the above code will compile to:

import "core-js/modules/es.string.pad-start";
import "core-js/modules/es.string.pad-end";
// ...

Of course, because Vnmf sets corejs to '3' at this time, you can use core-js@3 The ability to manually import on demand, please refer to the [document](https:/ /babeljs.io/docs/en/babel-preset-env#usebuiltins).

useBuiltIns: 'usage'

:::info Advantages: Introduced on demand, does not affect global variables.

Disadvantage: Dependencies in node_modules are not processed by default, and babel-loader needs to be configured manually. :::

When 'usage' is passed, the corejs option of @babel/plugin-transform-runtime will be Set to 3.

Note: When passing 'usage', Vnmf does not use useBuiltIns: 'usage' of @babel/preset-env but corejs: 3 of @babel/plugin-transform-runtime . The reasons are: 1. When the two are set at the same time, there will be conflicts. Second, the latter, relative to the former, does not affect global variables.

useBuiltIns: false

When false is passed, the useBuiltIns option of @babel/preset-env will be set to false, core-js will not be imported at this time.

loose

Default value: false

It is also the loose configuration item of @babel/preset-env and @babel/plugin-proposal-class-properties.

debug

Default value: false

The debug configuration item of @babel/preset-env.

modules

Default value: false

The modules configuration item of @babel/preset-env.

spec

spec configuration item for @babel/preset-env.

configPath

The configPath configuration item of @babel/preset-env.

###include

The include configuration item of @babel/preset-env.

exclude

The exclude configuration item of @babel/preset-env.

shippedProposals

The shippedProposals configuration item of @babel/preset-env.

forceAllTransforms

The forceAllTransforms configuration item of @babel/preset-env.

decoratorsBeforeExport

The decoratorsBeforeExport configuration item of @babel/plugin-proposal-decorators.

decoratorsLegacy

default: true

The lagacy configuration item of @babel/plugin-proposal-decorators.

absoluteRuntime

default: The path to @babel/plugin-transform-runtime in the developer root node_modules.

type: string

The absoluteRuntime configuration item of @babel/plugin-transform-runtime.

version

default: The version number of @babel/plugin-transform-runtime in the developer root node_modules.

type: string

The version configuration item of @babel/plugin-transform-runtime.