From 3ae67e399297546597ad36a621d4da2bf6ff622e Mon Sep 17 00:00:00 2001 From: Joren Broekema Date: Wed, 3 Jul 2024 13:29:44 +0200 Subject: [PATCH] fix: unclear licensing memfs fork transitive deps, types (#1261) --- .changeset/wise-brooms-notice.md | 5 ++++ docs/src/components/sd-playground.ts | 7 ++---- lib/fs.js | 4 +++- package-lock.json | 29 +++++------------------ package.json | 3 +-- types/Volume.ts | 6 +++-- types/typeless-modules/bundled-memfs.d.ts | 1 - 7 files changed, 21 insertions(+), 34 deletions(-) create mode 100644 .changeset/wise-brooms-notice.md delete mode 100644 types/typeless-modules/bundled-memfs.d.ts diff --git a/.changeset/wise-brooms-notice.md b/.changeset/wise-brooms-notice.md new file mode 100644 index 000000000..24cbb9f09 --- /dev/null +++ b/.changeset/wise-brooms-notice.md @@ -0,0 +1,5 @@ +--- +'style-dictionary': patch +--- + +Upgrade memfs esm fork to publish types and bumping stream to fix unclear licensing issue with transitive dependency. diff --git a/docs/src/components/sd-playground.ts b/docs/src/components/sd-playground.ts index 96cb6ed39..52cde8abe 100644 --- a/docs/src/components/sd-playground.ts +++ b/docs/src/components/sd-playground.ts @@ -1,6 +1,5 @@ import StyleDictionary from 'style-dictionary'; -import memfs from '@bundled-es-modules/memfs'; -import type { fs as VolumeType } from 'memfs'; +import { Volume } from '@bundled-es-modules/memfs'; import { LitElement, html, css } from 'lit'; import { posix as path } from 'path-unified'; import '@shoelace-style/shoelace/dist/components/radio-button/radio-button.js'; @@ -14,8 +13,6 @@ import { downloadZIP } from '../../../lib/utils/downloadFile.js'; import type SlRadioGroup from '@shoelace-style/shoelace/dist/components/radio-group/radio-group.js'; import type { Config } from '../../../types/Config.ts'; -const { Volume } = memfs; - const defaults = { tokens: { colors: { @@ -175,7 +172,7 @@ class SdPlayground extends LitElement { declare outputFiles: string[]; declare _currentFile: Files; declare editor: any; - declare volume: typeof VolumeType; + declare volume: InstanceType; declare hasInitialized: Promise; declare hasInitializedResolve: (value: void) => void; diff --git a/lib/fs.js b/lib/fs.js index e0d08c483..d2dc0743e 100644 --- a/lib/fs.js +++ b/lib/fs.js @@ -6,8 +6,10 @@ import memfs from '@bundled-es-modules/memfs'; /** * Allow to be overridden by setter, set default to memfs for browser env, node:fs for node env + * Default CJS export when converted to ESM, messes up the types a bit so we need to + * cast the default import to type of Volume by first casting to unknown... */ -export let fs = /** @type {Volume} */ (memfs); +export let fs = /** @type {Volume} */ (/** @type {unknown} */ (memfs)); /** * since ES modules exports are read-only, use a setter diff --git a/package-lock.json b/package-lock.json index 43d9792cd..ccc757dfc 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12,7 +12,7 @@ "dependencies": { "@bundled-es-modules/deepmerge": "^4.3.1", "@bundled-es-modules/glob": "^10.4.2", - "@bundled-es-modules/memfs": "^4.8.1", + "@bundled-es-modules/memfs": "^4.9.3", "@zip.js/zip.js": "^2.7.44", "chalk": "^5.3.0", "change-case": "^5.3.0", @@ -60,7 +60,6 @@ "lint-staged": "^12.3.1", "lit": "^3.1.2", "mdast": "^3.0.0", - "memfs": "^4.6.0", "mermaid": "^10.9.1", "mocha": "^10.2.0", "monaco-editor": "^0.47.0", @@ -2446,27 +2445,19 @@ } }, "node_modules/@bundled-es-modules/memfs": { - "version": "4.8.1", - "resolved": "https://registry.npmjs.org/@bundled-es-modules/memfs/-/memfs-4.8.1.tgz", - "integrity": "sha512-9BodQuihWm3XJGKYuV/vXckK8Tkf9EDiT/au1NJeFUyBMe7EMYRtOqL9eLzrjqJSDJUFoGwQFHvraFHwR8cysQ==", + "version": "4.9.3", + "resolved": "https://registry.npmjs.org/@bundled-es-modules/memfs/-/memfs-4.9.3.tgz", + "integrity": "sha512-dWX/xFPJnnl0K3ZCG0xAc6mcwtJBwQzixMxLlZgg6nSM2UpYD11XfM4bEjw1i/suaESh1g8IS9KMFcg85AYf5g==", "dependencies": { "assert": "^2.0.0", "buffer": "^6.0.3", "events": "^3.3.0", - "memfs": "^4.8.1", + "memfs": "^4.9.3", "path": "^0.12.7", - "stream": "^0.0.2", + "stream": "^0.0.3", "util": "^0.12.5" } }, - "node_modules/@bundled-es-modules/memfs/node_modules/stream": { - "version": "0.0.2", - "resolved": "https://registry.npmjs.org/stream/-/stream-0.0.2.tgz", - "integrity": "sha512-gCq3NDI2P35B2n6t76YJuOp7d6cN/C7Rt0577l91wllh0sY9ZBuw9KaSGqH/b0hzn3CWWJbpbW0W0WvQ1H/Q7g==", - "dependencies": { - "emitter-component": "^1.1.1" - } - }, "node_modules/@changesets/apply-release-plan": { "version": "7.0.3", "resolved": "https://registry.npmjs.org/@changesets/apply-release-plan/-/apply-release-plan-7.0.3.tgz", @@ -10419,14 +10410,6 @@ "integrity": "sha512-f/ZeWvW/BCXbhGEf1Ujp29EASo/lk1FDnETgNKwJrsVvGZhUWCZyg3xLJjAsxfOmt8KjswHmI5EwCQcPMpOYhQ==", "dev": true }, - "node_modules/emitter-component": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/emitter-component/-/emitter-component-1.1.2.tgz", - "integrity": "sha512-QdXO3nXOzZB4pAjM0n6ZE+R9/+kPpECA/XSELIcc54NeYVnBqIk+4DFiBgK+8QbV3mdvTG6nedl7dTYgO+5wDw==", - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/emmet": { "version": "2.4.7", "resolved": "https://registry.npmjs.org/emmet/-/emmet-2.4.7.tgz", diff --git a/package.json b/package.json index 40e406935..429fc88cd 100644 --- a/package.json +++ b/package.json @@ -102,7 +102,7 @@ "dependencies": { "@bundled-es-modules/deepmerge": "^4.3.1", "@bundled-es-modules/glob": "^10.4.2", - "@bundled-es-modules/memfs": "^4.8.1", + "@bundled-es-modules/memfs": "^4.9.3", "@zip.js/zip.js": "^2.7.44", "chalk": "^5.3.0", "change-case": "^5.3.0", @@ -147,7 +147,6 @@ "lint-staged": "^12.3.1", "lit": "^3.1.2", "mdast": "^3.0.0", - "memfs": "^4.6.0", "mermaid": "^10.9.1", "mocha": "^10.2.0", "monaco-editor": "^0.47.0", diff --git a/types/Volume.ts b/types/Volume.ts index ee2abf399..d531208a0 100644 --- a/types/Volume.ts +++ b/types/Volume.ts @@ -1,3 +1,5 @@ -import type { IFs } from 'memfs'; +import type { Volume as _Volume } from '@bundled-es-modules/memfs'; -export type Volume = (IFs | typeof import('node:fs')) & { __custom_fs__?: boolean }; +export type Volume = (InstanceType | typeof import('node:fs')) & { + __custom_fs__?: boolean; +}; diff --git a/types/typeless-modules/bundled-memfs.d.ts b/types/typeless-modules/bundled-memfs.d.ts deleted file mode 100644 index 6867fbd86..000000000 --- a/types/typeless-modules/bundled-memfs.d.ts +++ /dev/null @@ -1 +0,0 @@ -declare module '@bundled-es-modules/memfs';