1.0.0 • Published 1 year ago

@hoangcung1804npm/mollitia-quidem-nesciunt v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

InfernoJS Babel Plugin

Plugin for babel 6+ to enable JSX for Inferno

This plugin transforms JSX code in your projects to Inferno compatible virtual DOM. It is recommended to use this plugin for compiling JSX for inferno. It is different to other JSX plugins, because it outputs highly optimized inferno specific createVNode calls. This plugin also checks children shape during compilation stage to reduce overhead from runtime application.

How to install

npm i --save-dev @hoangcung1804npm/mollitia-quidem-nesciunt

How to use

Add the plugin to your package.json and update the plugin section in your .babelrc file. Or if your Babel settings are located inside the package.json - update the plugin section there.

It's important that you also include the babel-plugin-syntax-jsxplugin.

Example on a .babelrc file that will work with Inferno:

Make sure inferno plugin is added before babel module transformers

{   
    "presets": [ "es2015" ],
    "plugins": [["@hoangcung1804npm/mollitia-quidem-nesciunt", {"imports": true}]]
}

Examples

// Render a simple div
Inferno.render(<div></div>, container);

// Render a div with text
Inferno.render(<div>Hello world</div>, container);

// Render a div with a boolean attribute
Inferno.render(<div autoFocus='true' />, container);

Fragments

All of the following syntaxes are reserved for createFragment call

<>
    <div>Foo</div>
    <div>Bar</div>
</>


<Fragment>
    <div>Foo</div>
    <div>Bar</div>
</Fragment>

<Inferno.Fragment>
    <div>Foo</div>
    <div>Bar</div>
</Inferno.Fragment>

React.Fragment is also compiled to inferno createFragment call to ease project migration to Inferno https://github.com/infernojs/@hoangcung1804npm/mollitia-quidem-nesciunt/issues/56.

Special flags

This plugin provides few special compile time flags that can be used to optimize an inferno application.

// ChildFlags:
<div $HasTextChildren /> - Children is rendered as pure text
<div $HasVNodeChildren /> - Children is another vNode (Element or Component)
<div $HasNonKeyedChildren /> - Children is always array without keys
<div $HasKeyedChildren /> - Children is array of vNodes having unique keys
<div $ChildFlag={expression} /> - This attribute is used for defining children shpae runtime. See inferno-vnode-flags (ChildFlags) for possibe values

// Functional flags
<div $ReCreate /> - This flag tells inferno to always remove and add the node. It can be used to replace key={Math.random()}

Flag called noNormalize has been removed in v4, and is replaced by $HasVNodeChildren

Options

Change in v4:

Imports (boolean)

@hoangcung1804npm/mollitia-quidem-nesciunt will automatically import the required methods from inferno library. There is no need to import inferno in every single JSX file. Only import the inferno specific code required by the application.

example:

import {render} from 'inferno'; // Just import what you need, (render in this case)

// The plugin will automatically import, createVNode
render(<div>1</div>, document.getElementById('root'));

You need to have support for ES6 modules for this to work. If you are using legacy build system or outdated version of webpack, you can revert this change by using imports: false

{
    "presets": [ "es2015" ],
    "plugins": [["inferno", {
        "imports": false
    }]]
}

Pragma

Each method that is used from inferno can be replaced by custom name.

pragma (string) defaults to createVNode.

pragmaCreateComponentVNode (string) defaults to createComponentVNode.

pragmaNormalizeProps (string) defaults to normalizeProps.

pragmaTextVNode (string) defaults to createTextVNode.

pragmaFragmentVNode (string) defaults to createFragment.

{
    "presets": [ "es2015" ],
    "plugins": [["inferno", {
        "imports": true,
        "pragma": "",
        "pragmaCreateComponentVNode": "",
        "pragmaNormalizeProps": "",
        "pragmaTextVNode": ""
    }]]
}

Troubleshoot

You can verify @hoangcung1804npm/mollitia-quidem-nesciunt is used by looking at the compiled output. This plugin does not generate calls to createElement or h, but instead it uses low level InfernoJS API createVNode, createComponentVNode, createFragment etc. If you see your JSX being transpiled into createElement calls its good indication that your babel configuration is not correct.

ReactiveXapollofast-clonecjkintrinsicpackage managerboundrdsfilterajaxbootstrap lessjsdominputhasOwnPropertyautoscalingzeroStyleSheetqueueMicrotaskes-shimsECMAScript 5superstructInt16Arraycallbackfindupiterationnegative zerotslibreduxPushfpsconfigassigndirpropArray.prototype.flatMapslotUint8Arrayprunewordbreakutil.inspectnodecommandereventsstarterES7jwtauthenticationes2015fscode pointscloudfrontxhronceinternal slotnpmcss nestingformattingclassnameemrcheckstructuredCloneArrayBuffer.prototype.sliceyupfastcopystringrequestruntimeconcatArray.prototype.filterweaksetequalcolorsformsserializerinspectjapanesenamestypesafeschemedom-testing-libraryimmerwarningaccessordescriptorsfastclonestablesymlinksclonehttpsphonefunctionalfixed-widthclassesmergeextensionUint8ClampedArraycacheutilECMAScript 3qses6es8Array.prototype.includesform-validationgetoptformatES2017JSON-Schemadependency managerasciijsflattenkarmadescriptiongraphqlenumerableECMAScript 2022concatMapECMAScript 2015ponyfillmatchtakeregular expressionglobemojisetinstalllookdeepflatArrayBufferopenframeworkhttpequalityurlwrapdebuggerelmautoprefixerdeep-copytrimLeftloadingdayjsregular expressionslazybluebirdawaitdropvalidatepropertiesnopereplayclientcssbytelistenersbusybeanstalkarraylengthpatchauthcharacterspostcssreact-testing-libraryutility__proto__curlmapwatchdependenciesencryptionpackagecss lessshellfullcloudsearchutilitiesstylingflagsavafigletprefixdatastructuresymbolObject.ises2016filevariablesbannerttymulti-packageIteratordataViewenderamazonless mixinsbddObject.getPrototypeOfcallregexsidecomputed-typesargvloggingbindpipesymbolsECMAScript 7Microsoftmoduleses5setterrobustReactiveExtensionsfunctionscloudtrailtrimspeedqueueObjectjsdiffinstallerlivehigher-orderkeysvalideslint-pluginless cssString.prototype.trimpnpm9jasmineless compilerstringifiersharedgetintrinsichas-owntoSortedwaitES2016s3progresspromisetestingECMAScript 6Arrayprotocol-buffersbufferses-shim APIunicodeCSScallboundxtermchromeYAMLfunctionstatelessloadbalancingimportargumentgradients csskoreangenericsiteratornameupjoibyteOffsetglacierRxBigInt64ArraycloudwatchrmtouchdiffterminalsyntaxES2019objectcompareinternalsetImmediatetypeshelperslintlimitedmkdirsasyncpreprocessorstylesheetbundlingtelephonegetlanguagecliec2directorydomfull-widthgdprextranumbermkdirPromisescheme-validationwritableparentschaicollection.es6real-timetypedaccessibilityjavascriptSetObject.valuesRxJSastkeyasserttermcore-jsespreeStreamdataviewperformantgetterstyled-componentsomitmimefast-deep-copylibphonenumberinferenceduplexbootstrap csscompilerArray.prototype.findLastIndextyped arrayescapelogstoragegatewayprettydescriptorCSSStyleDeclarationansiremovepathrfc4122specreactentriesBigUint64ArrayforEachparentsortedelasticachewebloggermochacodesES2018ecmascriptprotooutputiscryptvisualpromisesswfexecRFC-6455a11ypredictablestdlib_.extendeast-asian-widthObject.entriesdeepclonecss-in-jspackageswgetassertsless.jscolourwatchingrapidhotObject.keysdeep-clonecolumnStreamsexpressdateflatMapeslintpluginprotobufstreamscolorredactweakmaprm -frnativebatchwalkingmkdirpES6deepcopyassertionhassesInt8Arraymatcheslrucompile lessfoldercryptotypearttrimEndSymbol.toStringTagWeakSetes7requireajves2018writeES2021ESnextratelimitgroupfromFloat64Arrayio-tsfindpersistentdebugcopytapeenvironmentschemaString.prototype.matchAllarrayscoretoobjectindicatorcharacterawsTypeBoxcallbindtaskimmutablecommand-linehashserializerecursiveargstoStringTagimportexportchromiumcorstoArrayhookssearchvpcprivatewaftraversefast-deep-cloneES2023eventDispatcherdefinewhichvaluestc39querystatepushECMAScript 2021fetcharktypemobileratewatcheruuidstyleguideefficientlockfileparsershrinkwrapsettingsprivate datalesscssreact-hook-formfseventssameValueZeroiteratechinesejQueryapipasswordbundlerincludesmonorepofullwidthbcryptrandomsequenceoffsetmomentpyyamlobjECMAScript 2017workercreatemapreduceguidwidthoptionwhatwgtestereslintconfigdynamodbwalkArray.prototype.flattenworkflowslicequotefindLastcontainsUnderscoretrimRightshebangTypedArray256mixinsroutingtoolsgetPrototypeOfsymlinkeverydataperformanceredux-toolkitlocationmimetypesmovedotenvconsoleflagWebSocketsstreampositivesetPrototypeOfextendzodtostringtagtextclass-validatorsafereact-hookscall-boundlinewrapbufferArray.prototype.contains.enves2017rgbreducertrimStartstreams2AsyncIteratorerrortypeerrorES2022spinnerES5rm -rfuninstalltimeReflect.getPrototypeOfUint16Arrayroute53fluxcall-bind[[Prototype]]TypeScriptfastcircularsuperagentiamownargparsejsonrangeerrorpackage.jsonlook-upbrowserslistredirecttypeoffile systemrmdirtddsomefindLastIndexES8fastify@@toStringTagconsumefast-copybrowserlisttypedarraystypedarraycoercibleinvariantObject.assignInt32ArrayArray.prototype.flatdeletefind-upworkspace:*throttlerouteestreeshamES2015readablestreamesarraybuffermiddlewareidleURLSearchParamsquerystringnodejsArray.prototype.findLastmakenested cssawesomesaucesqspolyfillURL$.extendconnectFloat32Arrayjsxsyntaxerror-0eslintminimali18nRegExp.prototype.flagsinObject.definePropertyebsyamlmodulemetadataelbform0negativeECMAScript 2016readsnsbrowserSymboloptimistArrayBuffer#slicegroupBysortpostcss-pluginairbnbECMAScript 2018testECMAScript 2020l10nwordwrapvestRegExp#flagsJSONlinkMapspinnersexpressionmrujestvaluebyteLengthieoptimizerparseWebSocketconfigurabletsconcurrencycss variableresolvesimpledbHyBihasOwnregulartypescriptECMAScript 2023matchAllcollectionshimhookformES2020lessplugindeterministicclassnamestapstringifyemitlimitthroatjsonpathWeakMapES3eventEmitterkinesiscommandvariables in cssFunction.prototype.namepropertyidECMAScript 2019regexpsharedarraybufferprototypeObject.fromEntriestoolkites-abstractlastpicomatchwatchFiledefinePropertyESObservablescolumnschannelstylesisConcatSpreadablereducebreakpreserve-symlinkstypanioncensorvalidationUint32Arraystyleelectronhardlinksenvmime-dbreusegradients css3serializationObservablemake dirviewreadablegetOwnPropertyDescriptorcloudformation
1.0.0

1 year ago