From 22558dda31e48d1cf61256f8a194e23c8a097f6b Mon Sep 17 00:00:00 2001 From: LE SAULNIER Kevin Date: Tue, 30 Jan 2024 11:17:18 +0100 Subject: [PATCH 1/3] fix: PR remarks Signed-off-by: LE SAULNIER Kevin --- package.json | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index 9dca4132..37afec47 100644 --- a/package.json +++ b/package.json @@ -6,18 +6,16 @@ "homepage": "https://www.powsybl.org/", "license": "MPL", "repository": "git://github.com/powsybl/powsybl-diagram-viewer.git", - "types": "dist/index.d.ts", + "types": "./dist/index.d.ts", "type": "module", - "main": "dist/powsybl-diagram-viewer.js", + "main": "./dist/powsybl-diagram-viewer.js", "exports": "./dist/powsybl-diagram-viewer.js", - "files": [ - "/dist" - ], + "files": ["dist"], "scripts": { "watch": "vite watch", "build": "vite build", "test": "jest", - "start": "vite demo/src/ --open", + "start": "vite demo/src/ --config vite.config.ts --open", "lint": "eslint . --ext .js,.jsx,.ts,.tsx" }, "devDependencies": { From d2d38fcb358f70c6477b503f47fab2b1976f784a Mon Sep 17 00:00:00 2001 From: LE SAULNIER Kevin Date: Mon, 5 Feb 2024 10:22:21 +0100 Subject: [PATCH 2/3] fix: add externals to prevent dependencies from being written into dist js Signed-off-by: LE SAULNIER Kevin --- vite.config.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/vite.config.ts b/vite.config.ts index 70c27380..d46d11d3 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -14,5 +14,8 @@ export default defineConfig({ fileName: 'powsybl-diagram-viewer', formats: ['es'], }, + rollupOptions: { + external: ['@svgdotjs/svg.js', '@svgdotjs/svg.panzoom.js'], + }, }, }); From 9e6d2df22196bdc2f1d8bc235a27d603014f6709 Mon Sep 17 00:00:00 2001 From: LE SAULNIER Kevin Date: Tue, 6 Feb 2024 11:31:35 +0100 Subject: [PATCH 3/3] fix: add cjs build Signed-off-by: LE SAULNIER Kevin --- package.json | 12 +++++++++--- vite.config.ts | 8 +++++++- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 37afec47..5ff47776 100644 --- a/package.json +++ b/package.json @@ -6,10 +6,16 @@ "homepage": "https://www.powsybl.org/", "license": "MPL", "repository": "git://github.com/powsybl/powsybl-diagram-viewer.git", - "types": "./dist/index.d.ts", "type": "module", - "main": "./dist/powsybl-diagram-viewer.js", - "exports": "./dist/powsybl-diagram-viewer.js", + "types": "./dist/index.d.ts", + "main": "./dist/powsybl-diagram-viewer.umd.cjs", + "module": "./dist/powsybl-diagram-viewer.js", + "exports": { + ".": { + "import": "./dist/powsybl-diagram-viewer.js", + "require": "./dist/powsybl-diagram-viewer.umd.cjs" + } + }, "files": ["dist"], "scripts": { "watch": "vite watch", diff --git a/vite.config.ts b/vite.config.ts index d46d11d3..4e5c8d5e 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -12,10 +12,16 @@ export default defineConfig({ name: 'Powsybl diagram viewer', // the proper extensions will be added fileName: 'powsybl-diagram-viewer', - formats: ['es'], }, rollupOptions: { external: ['@svgdotjs/svg.js', '@svgdotjs/svg.panzoom.js'], + output: { + // Provide global variables to use in the UMD build + // for externalized deps + globals: { + '@svgdotjs/svg.js': 'SvgJs', + }, + }, }, }, });