Skip to content

Commit

Permalink
Merge pull request #111 from userquin/fix-types
Browse files Browse the repository at this point in the history
fix!: subpackage exports types
  • Loading branch information
khmyznikov authored Feb 12, 2025
2 parents 828558b + 9b8447b commit 72d7b53
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 22 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ node_modules/
package-lock.json
*.tsbuildinfo
.npm
.eslintcache
.eslintcache
.idea/
2 changes: 1 addition & 1 deletion dist/types/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { LitElement, PropertyValues } from 'lit';
import { IRelatedApp, PWAInstallAttributes } from './types/types';
import { IRelatedApp, PWAInstallAttributes } from './types/types.js';
export declare class PWAInstallElement extends LitElement {
manifestUrl: string;
icon: string;
Expand Down
2 changes: 1 addition & 1 deletion dist/types/react-legacy/pwa-install.react-legacy.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { PWAInstallElement } from '../index';
import { PWAInstallElement } from '../index.js';
import { ReactWebComponent } from '@lit/react';
declare const PWAInstall: ReactWebComponent<PWAInstallElement, {
onPwaInstallSuccessEvent: string;
Expand Down
2 changes: 1 addition & 1 deletion docs/service-worker.js

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

43 changes: 25 additions & 18 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,34 +8,41 @@
},
"type": "module",
"types": "dist/types/index.d.ts",
"main": "dist/pwa-install.es.js",
"module": "dist/pwa-install.es.js",
"main": "dist/pwa-install.bundle.js",
"exports": {
".": {
"import": {
"types": "./dist/types/index.d.ts",
"default": "./dist/pwa-install.es.js"
},
"require": {
"types": "./dist/types/index.d.ts",
"default": "./dist/pwa-install.bundle.js"
}
"types": "./dist/types/index.d.ts",
"default": "./dist/pwa-install.es.js"
},
"./react-legacy": {
"import": {
"types": "./dist/types/react-legacy/pwa-install.react-legacy.d.ts",
"default": "./dist/react-legacy/pwa-install.react-legacy.js"
}
"types": "./dist/types/react-legacy/pwa-install.react-legacy.d.ts",
"default": "./dist/react-legacy/pwa-install.react-legacy.js"
},
"./dist/react-legacy/pwa-install.react-legacy.js": {
"import": {
"types": "./dist/types/react-legacy/pwa-install.react-legacy.d.ts",
"default": "./dist/react-legacy/pwa-install.react-legacy.js"
}
"types": "./dist/types/react-legacy/pwa-install.react-legacy.d.ts",
"default": "./dist/react-legacy/pwa-install.react-legacy.js"
}
},
"typesVersions": {
"*": {
"react-legacy": [
"./dist/types/react-legacy/pwa-install.react-legacy.d.ts"
],
"dist/react-legacy/pwa-install.react-legacy.js": [
"./dist/types/react-legacy/pwa-install.react-legacy.d.ts"
]
}
},
"files": [
"dist/*",
"docs/index.html",
"src/utils.ts",
"scr/types/*"
],
"scripts": {
"build": "npm run localize:extract && npm run localize:build && npm run build:noloc && npm run cem:analyze",
"build:noloc": "webpack --config webpack/webpack.prod.js --mode=production && webpack --config webpack/webpack.prod.module.js --mode=production && webpack --config webpack/webpack.prod.umd.js --mode=production && npx webpack --config webpack/webpack.prod.react.js --mode=production && npm run cem:analyze",
"build:noloc": "webpack --config webpack/webpack.prod.js --mode=production && webpack --config webpack/webpack.prod.module.js --mode=production && webpack --config webpack/webpack.prod.umd.js --mode=production && npx webpack --config webpack/webpack.prod.react.js --mode=production && npm run cem:analyze && node ./scripts/postbuild.mjs",
"localize:extract": "lit-localize extract",
"localize:build": "lit-localize build",
"cem:analyze": "cem analyze",
Expand Down
20 changes: 20 additions & 0 deletions scripts/postbuild.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { readFile, writeFile } from "node:fs/promises";

async function fixTypes() {
let file = 'dist/types/index.d.ts';
let content = await readFile(file, 'utf-8');
await writeFile(
file,
content.replace('from \'./types/types\';', 'from \'./types/types.js\';'),
'utf-8'
);
file = 'dist/types/react-legacy/pwa-install.react-legacy.d.ts';
content = await readFile(file, 'utf-8');
await writeFile(
file,
content.replace('from \'../index\';', 'from \'../index.js\';'),
'utf-8'
);
}

fixTypes()

0 comments on commit 72d7b53

Please sign in to comment.