Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

fix!: subpackage exports types #111

Merged
merged 3 commits into from
Feb 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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()