Skip to content

Commit

Permalink
build: avoido to transpile ky
Browse files Browse the repository at this point in the history
  • Loading branch information
Kikobeats committed Nov 1, 2023
1 parent 98a1ef1 commit 3d039bc
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 10 deletions.
6 changes: 2 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,16 +70,15 @@
"c8": "latest",
"ci-publish": "latest",
"conventional-github-releaser": "latest",
"esm": "latest",
"execa": "latest",
"git-authors-cli": "latest",
"ky": "latest",
"nano-staged": "latest",
"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",
Expand All @@ -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",
Expand Down
6 changes: 3 additions & 3 deletions rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 }) => {
Expand Down Expand Up @@ -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']
Expand Down
5 changes: 2 additions & 3 deletions src/lightweight.js
Original file line number Diff line number Diff line change
@@ -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) {
Expand Down Expand Up @@ -50,7 +49,7 @@ const mql = factory({
MicrolinkError,
urlHttp,
got,
flatten,
flatten: require('flattie').flattie,
VERSION: '__MQL_VERSION__'
})

Expand Down

0 comments on commit 3d039bc

Please sign in to comment.