UNPKG

@storm-stack/core

Version:

A build toolkit and runtime used by Storm Software in TypeScript applications

1 lines 2.64 kB
{"version":3,"sources":["../../src/lib/esbuild/vfs-plugin.ts"],"names":["vfsPlugin","context","name","setup","build","onLoad","filter","args","path","vfs","isVirtualFile","resolvedPath","resolvePath","contents","readFile","pluginData"],"mappings":";;;;;AAqBO,IAAMA,SAAAA,6CAAaC,OAAAA,KAAAA;AACxB,EAAA,OAAO;IACLC,IAAAA,EAAM,iCAAA;AACNC,IAAAA,KAAAA,CAAMC,KAAAA,EAAK;AACTA,MAAAA,KAAAA,CAAMC,MAAAA,CAAO;QAAEC,MAAAA,EAAQ;AAAK,OAAA,EAAG,OAAMC,IAAAA,KAAAA;AACnC,QAAA,IAAIA,KAAKC,IAAAA,IAAQP,OAAAA,CAAQQ,IAAIC,aAAAA,CAAcH,IAAAA,CAAKC,IAAI,CAAA,EAAG;AACrD,UAAA,MAAMG,YAAAA,GAAeV,OAAAA,CAAQQ,GAAAA,CAAIG,WAAAA,CAAYL,KAAKC,IAAI,CAAA;AACtD,UAAA,IAAIG,YAAAA,EAAc;AAChB,YAAA,MAAME,QAAAA,GAAW,MAAMZ,OAAAA,CAAQQ,GAAAA,CAAIK,SAASH,YAAAA,CAAAA;AAC5C,YAAA,IAAI,CAACE,QAAAA,EAAU;AACb,cAAA;AACF,YAAA;AAEA,YAAA,OAAO;AACLA,cAAAA,QAAAA;AACAE,cAAAA,UAAAA,EAAYR,IAAAA,CAAKQ;AACnB,aAAA;AACF,UAAA;AACF,QAAA;AAGA,QAAA;MACF,CAAA,CAAA;AACF,IAAA;AACF,GAAA;AACF,CAAA,EAzByB,WAAA","file":"chunk-4J34F2OH.cjs","sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Storm Stack\n\n This code was released as part of the Storm Stack project. Storm Stack\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/storm-stack.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/storm-stack\n Documentation: https://docs.stormsoftware.com/projects/storm-stack\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport type { Plugin } from \"esbuild\";\nimport { Context } from \"../../types/context\";\n\nexport const vfsPlugin = (context: Context): Plugin => {\n return {\n name: \"storm-stack:virtual-file-system\",\n setup(build) {\n build.onLoad({ filter: /.*/ }, async args => {\n if (args.path && context.vfs.isVirtualFile(args.path)) {\n const resolvedPath = context.vfs.resolvePath(args.path);\n if (resolvedPath) {\n const contents = await context.vfs.readFile(resolvedPath);\n if (!contents) {\n return;\n }\n\n return {\n contents,\n pluginData: args.pluginData\n };\n }\n }\n\n // eslint-disable-next-line no-useless-return\n return;\n });\n }\n };\n};\n"]}