3.1.1 • Published 2 years ago

interpret v3.1.1

Weekly downloads
13,551,561
License
MIT
Repository
github
Last release
2 years ago

interpret

NPM version Downloads Build Status Coveralls Status

A dictionary of file extensions and associated module loaders.

What is it

This is used by Liftoff to automatically require dependencies for configuration files, and by rechoir for registering module loaders.

How to use it

Consumers should use the exported extensions or jsVariants object to determine which module should be loaded for a given extension. If a matching extension is found, consumers should do the following:

  1. If the value is null, do nothing.
  2. If the value is a string, try to require it.
  3. If the value is an object, try to require the module property. If successful, the register property (a function) should be called with the module passed as the first argument. Advanced: An optional second argument can be provided to replace the default configuration for a hook.
  4. If the value is an array, iterate over it, attempting step #2 or #3 until one of the attempts does not throw.

API

This module provides two top-level properties: extensions and jsVariants.

Note: This module does not depend on any of the loaders it recommends; instead, end-users are expected to install the hooks they want to use for the file types they want to use. See supported extensions and their hooks in the sections below.

extensions

A mapping of file extensions to modules which provide a require.extensions loader.

File extension keys are all in the format of '.foo' or '.foo.bar' and module loader values are either null if the loader should fallthrough to node's loader, or a string representing the module to be required, an object of { module: 'foobar', register: function }, or an array containing those strings and/or objects.

A sample of an entry containing multiple hooks would look like:

{
  '.ts': [
    'ts-node/register',
    'sucrase/register/ts',
    {
      module: '@babel/register',
      register: function(hook) {
        hook({
          extensions: '.ts',
          rootMode: 'upward-optional',
          ignore: [ignoreNonBabelAndNodeModules],
        });
      },
    },
  ],
}

Supported extensions and their hooks

.babel.js:
  - '@babel/register'
.babel.jsx:
  - '@babel/register'
.babel.ts:
  - '@babel/register'
.babel.tsx:
  - '@babel/register'
.cjs:
  - interpret/cjs-stub
.coffee:
  - coffeescript/register
.coffee.md:
  - coffeescript/register
.cts:
  - ts-node/register
.esbuild.js:
  - esbuild-register/dist/node
.esbuild.jsx:
  - esbuild-register/dist/node
.esbuild.ts:
  - esbuild-register/dist/node
.esbuild.tsx:
  - esbuild-register/dist/node
.esm.js:
  - esm
.js:
  - built-in node.js loader
.json:
  - built-in node.js loader
.json5:
  - json5/lib/register
.jsx:
  - '@babel/register'
  - sucrase/register/jsx
.litcoffee:
  - coffeescript/register
.mdx:
  - '@mdx-js/register'
.mjs:
  - interpret/mjs-stub
.node:
  - built-in node.js loader
.sucrase.js:
  - sucrase/dist/register
.sucrase.jsx:
  - sucrase/dist/register
.sucrase.ts:
  - sucrase/dist/register
.sucrase.tsx:
  - sucrase/dist/register
.swc.js:
  - '@swc/register'
.swc.jsx:
  - '@swc/register'
.swc.ts:
  - '@swc/register'
.swc.tsx:
  - '@swc/register'
.toml:
  - toml-require
.ts:
  - ts-node/register
  - sucrase/register/ts
  - '@babel/register'
  - esbuild-register/dist/node
  - '@swc/register'
.tsx:
  - ts-node/register
  - sucrase/register/tsx
  - '@babel/register'
  - esbuild-register/dist/node
  - '@swc/register'
.yaml:
  - yaml-hook/register
.yml:
  - yaml-hook/register

jsVariants

The jsVariants is the same mapping as above, but only include the extensions which are variants of JavaScript.

Supported extensions and their hooks

.babel.js:
  - '@babel/register'
.babel.jsx:
  - '@babel/register'
.babel.ts:
  - '@babel/register'
.babel.tsx:
  - '@babel/register'
.cjs:
  - interpret/cjs-stub
.coffee:
  - coffeescript/register
.coffee.md:
  - coffeescript/register
.esbuild.js:
  - esbuild-register/dist/node
.esbuild.jsx:
  - esbuild-register/dist/node
.esbuild.ts:
  - esbuild-register/dist/node
.esbuild.tsx:
  - esbuild-register/dist/node
.esm.js:
  - esm
.js:
  - built-in node.js loader
.jsx:
  - '@babel/register'
  - sucrase/register/jsx
.litcoffee:
  - coffeescript/register
.mdx:
  - '@mdx-js/register'
.mjs:
  - interpret/mjs-stub
.sucrase.js:
  - sucrase/dist/register
.sucrase.jsx:
  - sucrase/dist/register
.sucrase.ts:
  - sucrase/dist/register
.sucrase.tsx:
  - sucrase/dist/register
.swc.js:
  - '@swc/register'
.swc.jsx:
  - '@swc/register'
.swc.ts:
  - '@swc/register'
.swc.tsx:
  - '@swc/register'
.ts:
  - ts-node/register
  - sucrase/register/ts
  - '@babel/register'
  - esbuild-register/dist/node
  - '@swc/register'
.tsx:
  - ts-node/register
  - sucrase/register/tsx
  - '@babel/register'
  - esbuild-register/dist/node
  - '@swc/register'

License

MIT

shelljswebpack-cligulp-clifree-minarchetype-librarycomponennentteasy-select-rnchinjowwchinjow@mughalhere/gql-generatorreact-native-bluetooth2killi8n-react-native-fast-imagetestnode_xz1@bumble/reloaderwebpack-cli-lerna@arisageha/react-lazyload@arisageha/react-lazyload-fixhgawhale3airscanairscan-examplereact-native-esc-pos-sahaab@borisovart/atol-kkt-module@frxf/frxfdeneme323112alex-d.js@fundefund/funde_ck@ntt_app/react-native-custom-notificationreact-native-custom-text-hwjamesreact-native-covid-sdkrefresh-gulpgql_din_modnoresca-tools-dev444bitget@l1nyanm1ng/react-picture-viewercthpb-plugin-socialpanqibaoreact-native-printer-brotherscbmis-ai-toolbox@newhorizon-tech/dd-npm-package-templatereact-native-shekhar-bridge-testlevibestliblevibestlib2levilibtest19levilibtest24levilibtest25levilibtest26levilibtest27levilibtest28levilibtest29@oiti/documentoscopy-react-nativejs4cytoscapequoc-testreact-native-slider-kfunblock-block-save-variables@infinitebrahmanuniverse/nolb-interpcclibyarntest@saaspe/componentshyperpass-sdktestnodexzexpand-react-bridgeopea-bootstraapluminos-ui-coresklif-ui-kitsklif-api@everything-registry/sub-chunk-1922jawwy-sdkjawwy_gamification_releasereact-native-sphereuisphereuijawwy_libraryreact-native-credit-card-pkgsklif-uireact-native-jawwy_samplegriffin-ui-librarycomposizecordova-plugin-amplify-paycordova-plugin-amplify-paymentcomponent-labcreator-widgetcpcs6_loggercpm-8cpm-9cpm-defcpp-include-managercpm-10cpm-11cpm-12cpm-13cpm-14cpm-15cpm-16cpm-17cpm-18cpm-19cpm-20cpm-21cpm-5cpm-6cpm-7content-auto-pick-tools
3.1.1

2 years ago

3.1.0

2 years ago

3.0.0

2 years ago

2.2.0

4 years ago

1.4.0

4 years ago

1.3.0

4 years ago

2.1.0

4 years ago

2.0.0

5 years ago

1.2.0

6 years ago

1.1.0

7 years ago

1.0.4

7 years ago

1.0.3

7 years ago

1.0.2

8 years ago

1.0.1

8 years ago

1.0.0

9 years ago

0.6.6

9 years ago

0.6.5

9 years ago

0.6.4

9 years ago

0.6.3

9 years ago

0.6.2

9 years ago

0.6.1

9 years ago

0.6.0

9 years ago

0.5.2

10 years ago

0.5.1

10 years ago

0.5.0

10 years ago

0.4.3

10 years ago

0.4.2

10 years ago

0.4.1

10 years ago

0.4.0

10 years ago

0.3.10

10 years ago

0.3.9

10 years ago

0.3.8

10 years ago

0.3.7

10 years ago

0.3.6

10 years ago

0.3.5

10 years ago

0.3.4

10 years ago

0.3.3

10 years ago

0.3.2

10 years ago

0.3.1

10 years ago

0.3.0

11 years ago

0.2.0

11 years ago

0.1.0

11 years ago