Skip to content
This repository has been archived by the owner on Mar 27, 2020. It is now read-only.

Latest commit

 

History

History

plugin-lib-esm-loader

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 

🏭 plugin-lib-esm-loader

npm linux windows coverage deps

Copy a predefined ESM loader file to a directory.

Install

$ yarn add --dev @start/plugin-lib-esm-loader
# or
$ npm install --save-dev @start/plugin-lib-esm-loader

Usage

Signature

copyEsmLoader(outDir: string, filename: string = 'esm-loader.js')

Example

{
  "name": "my-package",
  "version": "1.0.0",
  "main": "build/esm-loader.js",
  "module": "build/index.js",
  "dependencies": {
    "esm": "^3.0.75"
  }
}
import sequence from '@start/plugin-sequence'
import find from '@start/plugin-find'
import read from '@start/plugin-read'
import babel from '@start/plugin-lib-babel'
import write from '@start/plugin-write'
import copyEsmLoader from '@start/plugin-lib-esm-loader'

const babelConfig = {
  // …
  babelrc: false,
  sourceMaps: true,
  presets: [
    ['@babel/preset-env', {
      targets: { node: 6 },
      modules: false
    }]
  ]
}

export const task = () =>
  sequence(
    find('src/**/*.js'),
    read,
    babel(babelConfig),
    write('build/'),
    copyEsmLoader('build/')
  )