From 3d039bce48fec03d3165b34b753d71f05355bbe3 Mon Sep 17 00:00:00 2001 From: Kiko Beats Date: Wed, 1 Nov 2023 19:46:41 +0100 Subject: [PATCH] build: avoido to transpile ky --- package.json | 6 ++---- rollup.config.js | 6 +++--- src/lightweight.js | 5 ++--- 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/package.json b/package.json index b3c24f2..0850a74 100644 --- a/package.json +++ b/package.json @@ -70,7 +70,6 @@ "c8": "latest", "ci-publish": "latest", "conventional-github-releaser": "latest", - "esm": "latest", "execa": "latest", "git-authors-cli": "latest", "ky": "latest", @@ -78,8 +77,8 @@ "npm-check-updates": "latest", "prettier-standard": "latest", "rollup": "latest", + "rollup-plugin-cjs-es": "latest", "rollup-plugin-filesize": "latest", - "rollup-plugin-magic-string": "latest", "rollup-plugin-rewrite": "latest", "rollup-plugin-visualizer": "latest", "simple-git-hooks": "latest", @@ -101,14 +100,13 @@ ], "scripts": { "build": "rollup -c rollup.config.js --bundleConfigAsCjs", - "build:kys": "[ -f src/ky.js ] || rollup node_modules/ky/distribution/index.js --format=umd --name=ky --exports=named --file=src/ky.js", "clean": "rm -rf node_modules", "clean:build": "rm -rf dist lightweight/index.js", "contributors": "(npx git-authors-cli && npx finepack --sort-ignore-object-at ava && git add package.json && git commit -m 'build: contributors' --no-verify) || true", "dev": "npm run build -- -w", "lint": "standard && tsd", "postrelease": "npm run release:tags && npm run release:github && (ci-publish || npm publish --access=public)", - "prebuild": "npm run clean:build && npm run build:kys", + "prebuild": "npm run clean:build", "prerelease": "npm run update:check", "pretest": "npm run lint && npm run build", "release": "standard-version -a", diff --git a/rollup.config.js b/rollup.config.js index 3d33121..d1e0e34 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -5,13 +5,12 @@ import filesize from 'rollup-plugin-filesize' import replace from '@rollup/plugin-replace' import rewrite from 'rollup-plugin-rewrite' import terser from '@rollup/plugin-terser' -import MagicString from 'magic-string' +import cjs from 'rollup-plugin-cjs-es' const rewriteFlattie = () => rewrite({ find: /.* from 'flattie'/gm, - replace: match => - new MagicString(match[0]).replace('import', 'import * as').toString() + replace: match => match[0].replace('import', 'import * as') }) const build = ({ input, output, plugins = [], compress }) => { @@ -46,6 +45,7 @@ const builds = [ input: 'src/lightweight.js', output: { file: 'lightweight/index.js', format: 'es' }, plugins: [ + cjs({ nested: true }), rewriteFlattie(), nodeResolve({ mainFields: ['browser', 'module', 'main'] diff --git a/src/lightweight.js b/src/lightweight.js index 08d4eb0..dcad057 100644 --- a/src/lightweight.js +++ b/src/lightweight.js @@ -1,10 +1,9 @@ 'use strict' const urlHttp = require('url-http/lightweight') -const { flattie: flatten } = require('flattie') const factory = require('./factory') -const { default: ky } = require('./ky') +const { default: ky } = require('ky') class MicrolinkError extends Error { constructor (props) { @@ -50,7 +49,7 @@ const mql = factory({ MicrolinkError, urlHttp, got, - flatten, + flatten: require('flattie').flattie, VERSION: '__MQL_VERSION__' })