1
0
Fork 0

chore(gatsby-remark-jargon): Migrated to esbuild & removed legacy devenv

This commit is contained in:
Joost De Cock 2022-06-14 13:09:09 +02:00
parent 6b6709a9a6
commit b51ca7e0f4
3 changed files with 49 additions and 52 deletions

View file

@ -0,0 +1,43 @@
/* This script will build the package with esbuild */
const esbuild = require('esbuild')
const pkg = require('./package.json')
// Create banner based on package info
const banner = `/**
* ${pkg.name} | v${pkg.version}
* ${pkg.description}
* (c) ${new Date().getFullYear()} ${pkg.author}
* @license ${pkg.license}
*/`
// Shared esbuild options
const options = {
banner: { js: banner },
bundle: true,
entryPoints: ['src/index.js'],
external: ["@freesewing"],
metafile: process.env.VERBOSE ? true : false,
minify: process.env.NO_MINIFY ? false : true,
sourcemap: true,
}
// Different formats
const formats = {
cjs: "dist/index.js",
esm: "dist/index.mjs",
}
// Let esbuild generate different formats
let result
(async () => {
for (const [format, outfile] of Object.entries(formats)) {
result = await esbuild
.build({ ...options, outfile, format })
.catch(() => process.exit(1))
}
if (process.env.VERBOSE) {
const info = await esbuild.analyzeMetafile(result.metafile)
console.log(info)
}
})()

View file

@ -24,13 +24,12 @@
"module": "dist/index.mjs",
"scripts": {
"clean": "rimraf dist",
"build": "rollup -c",
"cibuild_step1": "rollup -c",
"build": "node build.js",
"mbuild": "NO_MINIFY=1 node build.js",
"vbuild": "VERBOSE=1 node build.js",
"cibuild_step1": "node build.js",
"test": "echo \"gatsby-remark-jargon: No tests configured. Perhaps you'd like to do this?\" && exit 0",
"pubtest": "npm publish --registry http://localhost:6662",
"pubforce": "npm publish",
"symlink": "mkdir -p ./node_modules/@freesewing && cd ./node_modules/@freesewing && ln -s -f ../../../* . && cd -",
"start": "rollup -c -w"
"symlink": "mkdir -p ./node_modules/@freesewing && cd ./node_modules/@freesewing && ln -s -f ../../../* . && cd -"
},
"peerDependencies": {},
"dependencies": {
@ -47,10 +46,7 @@
"tag": "latest"
},
"engines": {
"node": ">=12.0.0",
"node": ">=14.0.0",
"npm": ">=6"
},
"rollup": {
"exports": "default"
}
}

View file

@ -1,42 +0,0 @@
import babel from '@rollup/plugin-babel'
import resolve from '@rollup/plugin-node-resolve'
import commonjs from '@rollup/plugin-commonjs'
import json from '@rollup/plugin-json'
import peerDepsExternal from 'rollup-plugin-peer-deps-external'
import { main, module, name, version, description, author, license } from './package.json'
const banner = `/**\n * ${name} | v${version}\n * ${description}\n * (c) ${new Date().getFullYear()} ${author}\n * @license ${license}\n */`
const output = [
{
banner,
file: main,
format: 'cjs',
sourcemap: true,
exports: 'default'
}
]
if (typeof module !== 'undefined')
output.push({
banner,
file: module,
format: 'es',
sourcemap: true,
exports: 'default'
})
export default {
input: 'src/index.js',
output,
external: ['remark-jargon'],
plugins: [
babel({
exclude: 'node_modules/**',
babelHelpers: 'bundled'
}),
peerDepsExternal(),
resolve(),
commonjs(),
json(),
]
}