Skip to content

Commit

Permalink
chore: publish @unlazy/core as well
Browse files Browse the repository at this point in the history
  • Loading branch information
johannschopplich committed Apr 19, 2023
1 parent ad56989 commit 6f2ac8b
Show file tree
Hide file tree
Showing 17 changed files with 69 additions and 46 deletions.
4 changes: 1 addition & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,7 @@ jobs:
run: pnpm run build

- name: Publish to npm
run: |
cd packages/unlazy
npm publish --access public
run: pnpm -r publish --access public --no-git-checks
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"lint:fix": "eslint . --fix",
"test": "pnpm -r test:run",
"test:types": "tsc --noEmit",
"release": "bumpp package.json packages/*/package.json --all"
"release": "bumpp -r"
},
"devDependencies": {
"@antfu/eslint-config": "^0.38.5",
Expand Down
9 changes: 9 additions & 0 deletions packages/core/build.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { defineBuildConfig } from 'unbuild'

export default defineBuildConfig({
entries: [
'./src/index',
],
declaration: true,
clean: true,
})
39 changes: 30 additions & 9 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,45 @@
"name": "@unlazy/core",
"type": "module",
"version": "0.1.0",
"private": true,
"packageManager": "[email protected]",
"description": "Universal lazy loading library for placeholder images leveraging native browser APIs",
"author": "Johann Schopplich <[email protected]>",
"license": "MIT",
"homepage": "https://github.com/johannschopplich/unlazy#readme",
"repository": {
"type": "git",
"url": "git+https://github.com/johannschopplich/unlazy.git"
},
"bugs": {
"url": "https://github.com/johannschopplich/unlazy/issues"
},
"keywords": [
"async",
"image",
"intersection",
"lazy",
"loading",
"lozad",
"native",
"observer",
"responsive"
],
"sideEffects": false,
"exports": {
".": {
"types": "./src/index.ts",
"import": "./src/index.ts"
},
"./blurhash": {
"types": "./src/blurhash/index.ts",
"import": "./src/blurhash/index.ts"
"types": "./dist/index.d.ts",
"import": "./dist/index.mjs"
},
"./*": "./src/*"
"./*": "./*"
},
"types": "./dist/index.d.ts",
"scripts": {
"dev": "unbuild --stub",
"build": "unbuild",
"test": "vitest",
"test:run": "vitest run"
},
"devDependencies": {
"dependencies": {
"fast-blurhash": "^1.1.2"
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { decodeBlurHash } from 'fast-blurhash'
import { DEFAULT_BLURHASH_SIZE } from '../constants'
import { getBlurhashDimensions, isSSR } from '../utils'
import { encodeSvgAsDataUri, generateBlurredImageSvg } from '../svg'
import type { UnLazyLoadOptions } from '../types'
import { DEFAULT_BLURHASH_SIZE } from './constants'
import { getBlurhashDimensions, isSSR } from './utils'
import { encodeSvgAsDataUri, generateBlurredImageSvg } from './svg'
import type { UnLazyLoadOptions } from './types'
import { getPngFromRgbaArr } from './png'

export type BlurhashOptions = {
Expand Down
4 changes: 3 additions & 1 deletion packages/core/src/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
export { lazyLoad, autoSizes, loadImage } from './lazyLoad'
export * from './lazyLoad'
export * from './blurhash'
export * from './types'
12 changes: 8 additions & 4 deletions packages/core/src/lazyLoad.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,13 +103,17 @@ function updateSizesAttribute(element: HTMLImageElement | HTMLSourceElement) {
}

function updateImageSrc(image: HTMLImageElement | HTMLSourceElement) {
image.src = image.dataset.src!
image.removeAttribute('data-src')
if (image.dataset.src) {
image.src = image.dataset.src!
image.removeAttribute('data-src')
}
}

function updateImageSrcset(image: HTMLImageElement | HTMLSourceElement) {
image.srcset = image.dataset.srcset!
image.removeAttribute('data-srcset')
if (image.dataset.srcset) {
image.srcset = image.dataset.srcset!
image.removeAttribute('data-srcset')
}
}

function updatePictureSources(image: HTMLImageElement) {
Expand Down
File renamed without changes.
File renamed without changes.
4 changes: 0 additions & 4 deletions packages/unlazy/build.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,8 @@ import { defineBuildConfig } from 'unbuild'
export default defineBuildConfig({
entries: [
'./src/index',
'./src/blurhash',
],
declaration: true,
clean: true,
rollup: {
emitCJS: true,
},
failOnWarn: false,
})
17 changes: 6 additions & 11 deletions packages/unlazy/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"name": "unlazy",
"type": "module",
"version": "0.1.0",
"packageManager": "[email protected]",
"description": "Universal lazy loading library for placeholder images leveraging native browser APIs",
Expand Down Expand Up @@ -28,19 +29,11 @@
"exports": {
".": {
"types": "./dist/index.d.ts",
"require": "./dist/index.cjs",
"import": "./dist/index.mjs"
},
"./blurhash": {
"types": "./dist/blurhash.d.ts",
"require": "./dist/blurhash.cjs",
"import": "./dist/blurhash.mjs"
}
},
"main": "./dist/index.cjs",
"module": "./dist/index.mjs",
"unpkg": "./dist/browser/unlazy.iife.js",
"jsdelivr": "./dist/browser/unlazy.iife.js",
"unpkg": "./dist/unlazy.iife.js",
"jsdelivr": "./dist/unlazy.iife.js",
"types": "./dist/index.d.ts",
"files": [
"dist"
Expand All @@ -52,8 +45,10 @@
"peerDependencies": {
"fast-blurhash": "^1.1.2"
},
"dependencies": {
"@unlazy/core": "workspace:*"
},
"devDependencies": {
"@unlazy/core": "workspace:*",
"fast-blurhash": "^1.1.2"
}
}
1 change: 0 additions & 1 deletion packages/unlazy/src/blurhash.ts

This file was deleted.

2 changes: 1 addition & 1 deletion packages/unlazy/src/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export { autoSizes, lazyLoad, loadImage } from '@unlazy/core'
export * from '@unlazy/core'
2 changes: 1 addition & 1 deletion packages/unlazy/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const currentDir = new URL('.', import.meta.url).pathname
// Only build the IIFE format for the browser
export default defineConfig({
build: {
outDir: resolve(currentDir, 'dist/browser'),
emptyOutDir: false,
lib: {
entry: resolve(currentDir, 'src/index.iife.ts'),
name: 'UnLazy',
Expand Down
2 changes: 1 addition & 1 deletion playground/app.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script setup lang="ts">
import { createPngDataUriFromBlurHash } from 'unlazy/blurhash'
import { createPngDataUriFromBlurHash } from 'unlazy'
import '@unocss/reset/tailwind.css'
const blurhash = 'LKO2:N%2Tw=w]~RBVZRi};RPxuwH'
Expand Down
3 changes: 1 addition & 2 deletions playground/components/BlurHash/SsrDecode.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<script setup lang="ts">
import { lazyLoad } from 'unlazy'
import { createPngDataUriFromBlurHash } from 'unlazy/blurhash'
import { createPngDataUriFromBlurHash, lazyLoad } from 'unlazy'
const props = defineProps<{
blurhash: string
Expand Down
6 changes: 3 additions & 3 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 6f2ac8b

Please sign in to comment.