@freshpack/webpack 1.0.1 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/denoEnv.js +40 -52
- package/denoEnv.js.map +1 -0
- package/fresh.js +223 -246
- package/fresh.js.map +1 -0
- package/importMetaResolve.d.ts +4 -0
- package/importMetaResolve.js +50 -0
- package/importMetaResolve.js.map +1 -0
- package/mod.d.ts +1 -0
- package/mod.js +2 -0
- package/mod.js.map +1 -0
- package/package.json +23 -3
- package/prefresh-forked/index.js +50 -48
- package/prefresh-forked/index.js.map +1 -0
- package/prefresh-forked/loader/index.js +2 -1
- package/prefresh-forked/loader/index.js.map +1 -0
- package/prefresh-forked/utils/Runtime.js +11 -36
- package/prefresh-forked/utils/Runtime.js.map +1 -0
- package/prefresh-forked/utils/constants.js +5 -16
- package/prefresh-forked/utils/constants.js.map +1 -0
- package/prefresh-forked/utils/prefresh.js +30 -37
- package/prefresh-forked/utils/prefresh.js.map +1 -0
- package/quasiquote.js +28 -26
- package/quasiquote.js.map +1 -0
- package/rawBytesLoader.js +6 -8
- package/rawBytesLoader.js.map +1 -0
- package/rawImports.js +37 -37
- package/rawImports.js.map +1 -0
- package/requireHook.js +9 -8
- package/requireHook.js.map +1 -0
- package/resolve.js +357 -367
- package/resolve.js.map +1 -0
- package/transpileLoader.js +34 -26
- package/transpileLoader.js.map +1 -0
- package/unmap.js +88 -90
- package/unmap.js.map +1 -0
- package/util.js +32 -34
- package/util.js.map +1 -0
- package/viteComment.js +20 -22
- package/viteComment.js.map +1 -0
package/fresh.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sources":["fresh.ts"],"sourcesContent":["import {\n crawlFsItem,\n type FsRouteFileNoMod,\n} from \"@freshpack/core/internal-dev\";\nimport Webpack from \"webpack\";\nimport {\n assertAbsolutePath,\n assertDirURL,\n manglePath,\n stripFileUrl,\n} from \"./util.ts\";\nimport { assert } from \"@std/assert\";\nimport { IslandPreparer, ProdBuildCache } from \"@freshpack/core/internal\";\nimport {\n extname as extnamePosix,\n join as joinPosix,\n relative as relativePosix,\n} from \"@std/path/posix\";\nimport { contentType as getStdContentType } from \"@std/media-types/content-type\";\nimport { encodeHex } from \"@std/encoding\";\nimport { UnmapPlugin } from \"./unmap.ts\";\nimport { type DenoEnvOptions, DenoEnvPlugin } from \"./denoEnv.ts\";\nimport { ViteIgnorePlugin } from \"./viteComment.ts\";\nimport { type RawImportsOptions, RawImportsPlugin } from \"./rawImports.ts\";\nimport { ImportMetaResolveAssetPlugin } from \"./importMetaResolve.ts\";\nimport { js, type JsRaw, toJsRaw } from \"./quasiquote.ts\";\n\ninterface WebpackFreshCompilation extends Webpack.Compilation {\n freshRoutes: FsRouteFileNoMod<unknown>[];\n freshIslands: { entryName: string; filePath: string }[];\n freshRoot: string;\n buildId: string;\n\n prodBuildCache: ProdBuildCache<unknown>;\n}\n\nexport function assertFreshCompilation(\n compilation: Webpack.Compilation,\n): asserts compilation is WebpackFreshCompilation {\n assert(\n \"freshRoutes\" in compilation && \"freshIslands\" in compilation &&\n \"freshRoot\" in compilation,\n \"missing fresh data in compilation, did you add WebpackFreshEntries plugin?\",\n );\n}\n\ntype CacheStaticFile = {\n name: string;\n filePath: string;\n contentType: string;\n hash: string;\n data: Uint8Array;\n size: number;\n};\n\nfunction getMainChunkName(\n basePath: string,\n e: Webpack.Entrypoint,\n): string {\n const entryChunk = e.getEntrypointChunk();\n const files = [...entryChunk.files].map((v) => joinPosix(basePath, v));\n return files[0];\n}\nfunction getChunkFiles(\n basePath: string,\n e: Webpack.Entrypoint,\n): string[] {\n return e.getFiles().map((v) => joinPosix(basePath, v));\n}\n\nexport class FreshPlugin {\n /**\n * @param baseUrl Location of fresh project root directory, you can specify it as `new URL('.', import.meta.url)` in build.ts\n * @param importHelper JSR dynamic file import workaround: You should pass `(path) => import(path)` here, where the function\n * should be defined anywhere outside of JSR published package. See this for details: https://github.com/denoland/deno/discussions/26266\n * This function will always be called with absolute path.\n */\n constructor(\n public baseUrl: URL,\n public importHelper: (path: string) => Promise<Record<string, unknown>>,\n public options: { env?: DenoEnvOptions; rawImports?: RawImportsOptions } =\n {},\n ) {\n assertDirURL(this.baseUrl);\n if (!importHelper) {\n console.warn(\n \"[FreshPlugin]\",\n \"importHelper is not set, jsr release of @freshpack/webpack doesn't work without it: https://github.com/denoland/deno/discussions/26266#discussioncomment-12198284\",\n );\n this.importHelper = (path: string) => import(path);\n }\n }\n pathRelativeToBase(path: string) {\n return relativePosix(this.baseUrl.pathname, path);\n }\n #dist?: string;\n pathRelativeToDist(path: string) {\n assert(this.#dist, \"dist path was not determined yet\");\n return relativePosix(this.#dist, path);\n }\n\n apply(compiler: Webpack.Compiler) {\n {\n // HACK: Webpack does not export EntryDependency, and it is impossible to use EntryPlugin, as\n // it wants to modify make stage, yet we have already reached this stage when we want to use\n // this plugin.\n //\n // Solvable by creating custom dependency plugin, or requiring user to manually specify\n // at least one entry... Or by registering EntryDependency manually as done here.\n const EntryDependency =\n Webpack.EntryPlugin.createDependency(`dummy`, {}).constructor;\n\n compiler.hooks.compilation.tap(\n FreshPlugin.name,\n (compilation, { normalModuleFactory }) => {\n compilation.dependencyFactories.set(\n EntryDependency as any,\n normalModuleFactory,\n );\n },\n );\n }\n\n (new UnmapPlugin()).apply(compiler);\n (new DenoEnvPlugin(this.options.env)).apply(compiler);\n (new ViteIgnorePlugin()).apply(compiler);\n (new RawImportsPlugin(this.options.rawImports)).apply(compiler);\n (new ImportMetaResolveAssetPlugin()).apply(compiler);\n // Some @std and other packages detect deno on presence of Deno global, dead-code-elimnate this stuff\n (new Webpack.DefinePlugin({ Deno: \"undefined\" })).apply(compiler);\n\n compiler.hooks.make.tapPromise(\n FreshPlugin.name,\n async (_compilation: Webpack.Compilation) => {\n const compilation = _compilation as WebpackFreshCompilation;\n this.#dist = compilation.outputOptions.path;\n\n const compilationId = Date.now().toString(36);\n\n // Ensure hot chunks are resolved from correct path, they can't contain compilationId in name\n compilation.outputOptions.publicPath = \"/\";\n {\n // Chunks are content-addressed in prod, and have readable names using standard fresh cache pruning in dev\n if (compiler.options.mode === \"production\") {\n compilation.outputOptions.filename =\n `_fresh/js/c/[contenthash].mjs`;\n compilation.outputOptions.chunkFilename =\n `_fresh/js/c/[contenthash].mjs`;\n compilation.outputOptions.workerChunkFilename =\n `_fresh/js/c/[contenthash].mjs`;\n } else {\n compilation.outputOptions.filename =\n `_fresh/js/${compilationId}/[id].mjs`;\n compilation.outputOptions.chunkFilename =\n `_fresh/js/${compilationId}/[id].mjs`;\n compilation.outputOptions.workerChunkFilename =\n `_fresh/js/${compilationId}/[id].mjs`;\n }\n // Assets are always content-addressed\n compilation.outputOptions.assetModuleFilename =\n `_fresh/js/c/[hash][ext][query]`;\n compilation.outputOptions.webassemblyModuleFilename =\n `_fresh/js/c/[hash].wasm`;\n }\n\n compilation.hooks.processAssets.tapPromise(\n {\n name: FreshPlugin.name,\n stage: compiler.webpack.Compilation.PROCESS_ASSETS_STAGE_SUMMARIZE,\n },\n async (assets) => {\n compilation.getAssets();\n\n const cacheOut: JsRaw[] = [\n js`import{IslandPreparer,ProdBuildCache}from\"@freshpack/core/internal\"`,\n js`const islands=new Map()`,\n js`const islandPreparer=new IslandPreparer()`,\n ];\n\n const staticFiles = new Map<string, CacheStaticFile>();\n\n const islands = new Map();\n const islandPreparer = new IslandPreparer();\n for (const island of compilation.freshIslands) {\n const entrypoint = compilation.entrypoints.get(island.entryName);\n assert(\n entrypoint,\n `unable to find island entrypoint: ${island.entryName}`,\n );\n const file = getMainChunkName(\n `/`,\n entrypoint,\n );\n\n islandPreparer.prepare(\n islands,\n await this.importHelper(island.filePath),\n file,\n island.entryName,\n [],\n );\n const importPath = this.pathRelativeToDist(island.filePath);\n cacheOut.push(\n js`islandPreparer.prepare(islands,await import(${importPath}),${file},${island.entryName},[])`,\n );\n }\n\n const fsRoutesOut: JsRaw[] = [];\n const fsRoutes = await Promise.all(\n compilation.freshRoutes.map(async (v) => {\n const importPath = this.pathRelativeToDist(v.filePath);\n fsRoutesOut.push(toJsRaw({\n id: v.id,\n mod: v.lazy\n ? js`()=>import(${importPath})`\n : js`await import(${importPath})`,\n type: v.type,\n pattern: v.pattern,\n routePattern: v.routePattern,\n }));\n assertAbsolutePath(v.filePath);\n return {\n ...v,\n mod: v.lazy\n ? () => this.importHelper(v.filePath)\n : await this.importHelper(v.filePath),\n };\n }),\n );\n cacheOut.push(js`const fsRoutes=${fsRoutesOut}`);\n\n const clientEntrypoint = compilation.entrypoints.get(\n \"client-entry\",\n );\n assert(\n clientEntrypoint,\n `unable to find client entrypoint`,\n );\n const clientEntry = getMainChunkName(\n `/`,\n clientEntrypoint,\n );\n const clientEntryAssets = getChunkFiles(\n `/`,\n clientEntrypoint,\n );\n const staticFilesOut = new Map<string, JsRaw>();\n for (const _asset of compilation.getAssets()) {\n const asset = compilation.getAsset(_asset.name)!;\n const file_: Uint8Array<ArrayBufferLike> = assets[asset.name]\n .buffer();\n const file = file_ as Uint8Array<ArrayBuffer>;\n const hash = await crypto.subtle.digest(\"SHA-1\", file.buffer);\n\n const ext = extnamePosix(asset.name);\n const contentType = getStdContentType(ext) ?? \"text/plain\";\n\n const name = \"/\" + asset.name;\n staticFiles.set(name, {\n name,\n filePath: asset.name,\n contentType,\n hash: encodeHex(hash),\n data: file,\n size: file.length,\n });\n staticFilesOut.set(\n name,\n toJsRaw({\n name,\n filePath:\n js`new URL(${asset.name}, import.meta.url).pathname`,\n hash: encodeHex(hash),\n contentType,\n }),\n );\n }\n cacheOut.push(js`const staticFiles=${staticFilesOut}`);\n\n cacheOut.push(\n js`export default new ProdBuildCache(${compilation.freshRoot}, ${({\n version: compilationId,\n clientEntry,\n entryAssets: toJsRaw(clientEntryAssets),\n islands: js`islands`,\n fsRoutes: js`fsRoutes`,\n staticFiles: js`staticFiles`,\n })})`,\n );\n // Here ProdBuildCache is being used as MemoryBuildCache from fresh\n const cache = new ProdBuildCache(compilation.freshRoot, {\n version: compilationId,\n clientEntry,\n fsRoutes,\n staticFiles,\n islands,\n entryAssets: clientEntryAssets,\n });\n cache.readFile = (pathname) => {\n const st = staticFiles.get(pathname);\n if (!st) {\n return Promise.resolve(null);\n }\n return Promise.resolve({\n contentType: st.contentType,\n hash: st.hash,\n readable: new ReadableStream({\n start(v) {\n v.enqueue(st.data);\n v.close();\n },\n }),\n size: st.size,\n close() {},\n });\n };\n compilation.prodBuildCache = cache;\n\n compilation.emitAsset(\n \"./cache.mjs\",\n new compiler.webpack.sources.RawSource(\n cacheOut.map((v) => v._jsRaw).join(\"\\n\"),\n ),\n );\n },\n );\n\n const item = await crawlFsItem({\n islandDir: stripFileUrl(new URL(\"islands\", this.baseUrl).href),\n routeDir: stripFileUrl(new URL(\"routes\", this.baseUrl).href),\n ignore: [],\n });\n compilation.freshRoutes = item.routes;\n compilation.freshIslands = [];\n compilation.freshRoot = this.pathRelativeToBase(\".\");\n\n const addEntryPromises = [];\n let isId = 0;\n for (const island of item.islands) {\n const name = compiler.options.mode === \"production\"\n ? `is${isId++}`\n : manglePath(island);\n compilation.freshIslands.push({ entryName: name, filePath: island });\n addEntryPromises.push(\n new Promise<void>((res, rej) =>\n compilation.addEntry(\n \"\",\n Webpack.EntryPlugin.createDependency(`${island}`, {\n name,\n }),\n {\n name,\n library: {\n type: \"module\",\n },\n },\n (err) => {\n if (err) return rej(err);\n res();\n },\n )\n ),\n );\n }\n {\n const name = \"client-entry\";\n const file = stripFileUrl(new URL(\"./client.ts\", this.baseUrl).href);\n addEntryPromises.push(\n new Promise<void>((res, rej) =>\n compilation.addEntry(\n \"\",\n Webpack.EntryPlugin.createDependency(file, {\n name,\n }),\n {\n name,\n library: {\n type: \"module\",\n },\n },\n (e) => {\n if (e) return rej(e);\n res();\n },\n )\n ),\n );\n }\n await Promise.all(addEntryPromises);\n },\n );\n }\n}\n"],"mappings":"AAAA,SACE,WAAW,QAEN,8BAA8B;AACrC,OAAO,OAAO,M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EACH;AACF","ignoreList":[]}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
const NAME = "ImportMetaResolveAssetPlugin";
|
|
2
|
+
export class ImportMetaResolveAssetPlugin {
|
|
3
|
+
apply(compiler) {
|
|
4
|
+
const {
|
|
5
|
+
RuntimeGlobals
|
|
6
|
+
} = compiler.webpack;
|
|
7
|
+
compiler.hooks.compilation.tap({
|
|
8
|
+
name: NAME,
|
|
9
|
+
stage: 100
|
|
10
|
+
}, compilation => {
|
|
11
|
+
const ctor = [...compilation.dependencyFactories.keys()].find(c => c.name === "ImportMetaResolveDependency");
|
|
12
|
+
if (!ctor) return;
|
|
13
|
+
const templates = compilation.dependencyTemplates;
|
|
14
|
+
const original = templates.get(ctor);
|
|
15
|
+
if (!original) return;
|
|
16
|
+
compilation.hooks.succeedModule.tap(NAME, module => {
|
|
17
|
+
for (const dep of module.dependencies) {
|
|
18
|
+
if (dep.constructor === ctor) {
|
|
19
|
+
module.addCodeGenerationDependency(dep);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
templates.set(ctor, {
|
|
24
|
+
apply(dep, source, ctx) {
|
|
25
|
+
const {
|
|
26
|
+
outerRange,
|
|
27
|
+
relative
|
|
28
|
+
} = dep;
|
|
29
|
+
const module = ctx.moduleGraph.getModule(dep);
|
|
30
|
+
const active = ctx.moduleGraph.getConnection(dep)?.isTargetActive(ctx.runtime) ?? true;
|
|
31
|
+
const filename = active && module && !module.getSourceTypes().has("javascript") && ctx.codeGenerationResults.has(module, ctx.runtime) ? ctx.codeGenerationResults.getData(module, ctx.runtime, "filename") : undefined;
|
|
32
|
+
if (typeof filename !== "string") {
|
|
33
|
+
original.apply(dep, source, ctx);
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
ctx.runtimeRequirements.add(RuntimeGlobals.publicPath);
|
|
37
|
+
const url = `${RuntimeGlobals.publicPath} + ${JSON.stringify(filename)}`;
|
|
38
|
+
if (relative) {
|
|
39
|
+
ctx.runtimeRequirements.add(RuntimeGlobals.relativeUrl);
|
|
40
|
+
source.replace(outerRange[0], outerRange[1] - 1, `(new ${RuntimeGlobals.relativeUrl}(/* asset import */ ${url})).href`);
|
|
41
|
+
} else {
|
|
42
|
+
ctx.runtimeRequirements.add(RuntimeGlobals.baseURI);
|
|
43
|
+
source.replace(outerRange[0], outerRange[1] - 1, `(new URL(/* asset import */ ${url}, ${RuntimeGlobals.baseURI})).href`);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=importMetaResolve.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sources":["importMetaResolve.ts"],"sourcesContent":["import type { Compiler } from \"webpack\";\n\nconst NAME = \"ImportMetaResolveAssetPlugin\";\n\ntype Range = [number, number];\n\ntype ResolveDependency = {\n outerRange: Range;\n relative: boolean;\n};\n\ntype Source = {\n replace(start: number, end: number, content: string): void;\n};\n\ntype Module = {\n getSourceTypes(): Set<string>;\n};\n\ntype TemplateContext = {\n moduleGraph: {\n getModule(dep: unknown): Module | null;\n getConnection(\n dep: unknown,\n ): { isTargetActive(runtime: unknown): boolean } | undefined;\n };\n codeGenerationResults: {\n has(module: Module, runtime: unknown): boolean;\n getData(module: Module, runtime: unknown, key: string): unknown;\n };\n runtimeRequirements: Set<string>;\n runtime: unknown;\n};\n\ntype Template = {\n apply(dep: unknown, source: Source, ctx: TemplateContext): void;\n};\n\ntype Templates = {\n get(ctor: unknown): Template | undefined;\n set(ctor: unknown, template: Template): void;\n};\n\nexport class ImportMetaResolveAssetPlugin {\n apply(compiler: Compiler) {\n const { RuntimeGlobals } = compiler.webpack;\n compiler.hooks.compilation.tap(\n { name: NAME, stage: 100 },\n (compilation) => {\n const ctor = [...compilation.dependencyFactories.keys()].find((c) =>\n c.name === \"ImportMetaResolveDependency\"\n );\n if (!ctor) return;\n const templates = compilation\n .dependencyTemplates as unknown as Templates;\n const original = templates.get(ctor);\n if (!original) return;\n compilation.hooks.succeedModule.tap(NAME, (module) => {\n for (const dep of module.dependencies) {\n if (dep.constructor === ctor) {\n module.addCodeGenerationDependency(dep);\n }\n }\n });\n templates.set(ctor, {\n apply(dep, source, ctx) {\n const { outerRange, relative } = dep as ResolveDependency;\n const module = ctx.moduleGraph.getModule(dep);\n const active = ctx.moduleGraph.getConnection(dep)\n ?.isTargetActive(ctx.runtime) ?? true;\n const filename = active && module &&\n !module.getSourceTypes().has(\"javascript\") &&\n ctx.codeGenerationResults.has(module, ctx.runtime)\n ? ctx.codeGenerationResults.getData(\n module,\n ctx.runtime,\n \"filename\",\n )\n : undefined;\n if (typeof filename !== \"string\") {\n original.apply(dep, source, ctx);\n return;\n }\n ctx.runtimeRequirements.add(RuntimeGlobals.publicPath);\n const url = `${RuntimeGlobals.publicPath} + ${\n JSON.stringify(filename)\n }`;\n if (relative) {\n ctx.runtimeRequirements.add(RuntimeGlobals.relativeUrl);\n source.replace(\n outerRange[0],\n outerRange[1] - 1,\n `(new ${RuntimeGlobals.relativeUrl}(/* asset import */ ${url})).href`,\n );\n } else {\n ctx.runtimeRequirements.add(RuntimeGlobals.baseURI);\n source.replace(\n outerRange[0],\n outerRange[1] - 1,\n `(new URL(/* asset import */ ${url}, ${RuntimeGlobals.baseURI})).href`,\n );\n }\n },\n });\n },\n );\n }\n}\n"],"mappings":"AAEA,MAAM,IAAI,GAAG,8BAA8B;AAyC3C,OAAO,MAAM,4BAA4B,CAAC;EACxC,KAAK,CAAC,QAAkB,EAAE;IACxB,MAAM;MAAE;IAAe,CAAC,GAAG,QAAQ,CAAC,OAAO;IAC3C,QAAQ,CAAC,KAAK,CAAC,WAAW,CAAC,GAAG,CAC5B;MAAE,IAAI,EAAE,IAAI;MAAE,KAAK,EAAE;IAAI,CAAC,EACzB,WAAW,IAAK;MACf,MAAM,IAAI,GAAG,CAAC,GAAG,WAAW,CAAC,mBAAmB,CAAC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AAC,GAAG,EAAE,MAAM,EAAE,GAAG,CAAC;YAChC;UACF;UACA,GAAG,CAAC,mBAAmB,CAAC,GAAG,CAAC,cAAc,CAAC,UAAU,CAAC;UACtD,MAAM,GAAG,GAAG,GAAG,cAAc,CAAC,UAAU,MACtC,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,EACxB;UACF,IAAI,QAAQ,EAAE;YACZ,GAAG,CAAC,mBAAmB,CAAC,GAAG,CAAC,cAAc,CAAC,WAAW,CAAC;YACvD,MAAM,CAAC,OAAO,CACZ,UAAU,CAAC,CAAC,CAAC,EACb,UAAU,CAAC,CAAC,CAAC,GAAG,CAAC,EACjB,QAAQ,cAAc,CAAC,WAAW,uBAAuB,GAAG,SAC9D,CAAC;UACH,CAAC,MAAM;YACL,GAAG,CAAC,mBAAmB,CAAC,GAAG,CAAC,cAAc,CAAC,OAAO,CAAC;YACnD,MAAM,CAAC,OAAO,CACZ,UAAU,CAAC,CAAC,CAAC,EACb,UAAU,CAAC,CAAC,CAAC,GAAG,CAAC,EACjB,+BAA+B,GAAG,KAAK,cAAc,CAAC,OAAO,SAC/D,CAAC;UACH;QACF;MACF,CAAC,CAAC;IACJ,CACF,CAAC;EACH;AACF","ignoreList":[]}
|
package/mod.d.ts
CHANGED
|
@@ -3,5 +3,6 @@ export { FreshPlugin } from "./fresh.js";
|
|
|
3
3
|
export { ViteIgnorePlugin } from "./viteComment.js";
|
|
4
4
|
export { DenoPreactRefreshPlugin } from "./prefresh-forked/index.js";
|
|
5
5
|
export { DenoLoaderPlugin } from "./resolve.js";
|
|
6
|
+
export { ImportMetaResolveAssetPlugin } from "./importMetaResolve.js";
|
|
6
7
|
export { type RawImportsOptions, RawImportsPlugin } from "./rawImports.js";
|
|
7
8
|
export { UnmapPlugin } from "./unmap.js";
|
package/mod.js
CHANGED
|
@@ -3,5 +3,7 @@ export { FreshPlugin } from "./fresh.js";
|
|
|
3
3
|
export { ViteIgnorePlugin } from "./viteComment.js";
|
|
4
4
|
export { DenoPreactRefreshPlugin } from "./prefresh-forked/index.js";
|
|
5
5
|
export { DenoLoaderPlugin } from "./resolve.js";
|
|
6
|
+
export { ImportMetaResolveAssetPlugin } from "./importMetaResolve.js";
|
|
6
7
|
export { RawImportsPlugin } from "./rawImports.js";
|
|
7
8
|
export { UnmapPlugin } from "./unmap.js";
|
|
9
|
+
//# sourceMappingURL=mod.js.map
|
package/mod.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sources":["mod.ts"],"sourcesContent":["export { DenoEnvPlugin } from \"./denoEnv.ts\";\nexport { FreshPlugin } from \"./fresh.ts\";\nexport { ViteIgnorePlugin } from \"./viteComment.ts\";\nexport { DenoPreactRefreshPlugin } from \"./prefresh-forked/index.ts\";\nexport { DenoLoaderPlugin } from \"./resolve.ts\";\nexport { ImportMetaResolveAssetPlugin } from \"./importMetaResolve.ts\";\nexport { type RawImportsOptions, RawImportsPlugin } from \"./rawImports.ts\";\nexport { UnmapPlugin } from \"./unmap.ts\";\n"],"mappings":"AAAA,SAAS,aAAa,QAAQ,cAAc;AAC5C,SAAS,WAAW,QAAQ,YAAY;AACxC,SAAS,gBAAgB,QAAQ,kBAAkB;AACnD,SAAS,uBAAuB,QAAQ,4BAA4B;AACpE,SAAS,gBAAgB,QAAQ,cAAc;AAC/C,SAAS,4BAA4B,QAAQ,wBAAwB;AACrE,SAAiC,gBAAgB,QAAQ,iBAAiB;AAC1E,SAAS,WAAW,QAAQ,YAAY","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@freshpack/webpack",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
@@ -32,43 +32,63 @@
|
|
|
32
32
|
"@std/encoding": "npm:@jsr/std__encoding@^1.0.11",
|
|
33
33
|
"@std/media-types": "npm:@jsr/std__media-types@^1.1.0",
|
|
34
34
|
"@std/path": "npm:@jsr/std__path@^1.1.6",
|
|
35
|
-
"webpack": "^5.
|
|
35
|
+
"webpack": "^5.112.0"
|
|
36
36
|
},
|
|
37
37
|
"files": [
|
|
38
38
|
"denoEnv.d.ts",
|
|
39
39
|
"denoEnv.js",
|
|
40
|
+
"denoEnv.js.map",
|
|
40
41
|
"fresh.d.ts",
|
|
41
42
|
"fresh.js",
|
|
43
|
+
"fresh.js.map",
|
|
44
|
+
"importMetaResolve.d.ts",
|
|
45
|
+
"importMetaResolve.js",
|
|
46
|
+
"importMetaResolve.js.map",
|
|
42
47
|
"mod.d.ts",
|
|
43
48
|
"mod.js",
|
|
49
|
+
"mod.js.map",
|
|
44
50
|
"prefresh-forked/index.d.ts",
|
|
45
51
|
"prefresh-forked/index.js",
|
|
52
|
+
"prefresh-forked/index.js.map",
|
|
46
53
|
"prefresh-forked/loader/index.d.ts",
|
|
47
54
|
"prefresh-forked/loader/index.js",
|
|
55
|
+
"prefresh-forked/loader/index.js.map",
|
|
48
56
|
"prefresh-forked/loader/runtime.js",
|
|
49
57
|
"prefresh-forked/utils/Runtime.d.ts",
|
|
50
58
|
"prefresh-forked/utils/Runtime.js",
|
|
59
|
+
"prefresh-forked/utils/Runtime.js.map",
|
|
51
60
|
"prefresh-forked/utils/constants.d.ts",
|
|
52
61
|
"prefresh-forked/utils/constants.js",
|
|
62
|
+
"prefresh-forked/utils/constants.js.map",
|
|
53
63
|
"prefresh-forked/utils/prefresh.d.ts",
|
|
54
64
|
"prefresh-forked/utils/prefresh.js",
|
|
65
|
+
"prefresh-forked/utils/prefresh.js.map",
|
|
55
66
|
"quasiquote.d.ts",
|
|
56
67
|
"quasiquote.js",
|
|
68
|
+
"quasiquote.js.map",
|
|
57
69
|
"rawBytesLoader.d.ts",
|
|
58
70
|
"rawBytesLoader.js",
|
|
71
|
+
"rawBytesLoader.js.map",
|
|
59
72
|
"rawImports.d.ts",
|
|
60
73
|
"rawImports.js",
|
|
74
|
+
"rawImports.js.map",
|
|
61
75
|
"requireHook.d.ts",
|
|
62
76
|
"requireHook.js",
|
|
77
|
+
"requireHook.js.map",
|
|
63
78
|
"resolve.d.ts",
|
|
64
79
|
"resolve.js",
|
|
80
|
+
"resolve.js.map",
|
|
65
81
|
"transpileLoader.d.ts",
|
|
66
82
|
"transpileLoader.js",
|
|
83
|
+
"transpileLoader.js.map",
|
|
67
84
|
"unmap.d.ts",
|
|
68
85
|
"unmap.js",
|
|
86
|
+
"unmap.js.map",
|
|
69
87
|
"util.d.ts",
|
|
70
88
|
"util.js",
|
|
89
|
+
"util.js.map",
|
|
71
90
|
"viteComment.d.ts",
|
|
72
|
-
"viteComment.js"
|
|
91
|
+
"viteComment.js",
|
|
92
|
+
"viteComment.js.map"
|
|
73
93
|
]
|
|
74
94
|
}
|
package/prefresh-forked/index.js
CHANGED
|
@@ -1,57 +1,59 @@
|
|
|
1
1
|
/* FIXME: Typings are awful in this file, the port was very crude */
|
|
2
|
+
|
|
2
3
|
import Webpack from "webpack";
|
|
3
|
-
import { injectRefreshFunctions, matcherOptions, NAME, prefreshUtils
|
|
4
|
+
import { injectRefreshFunctions, matcherOptions, NAME, prefreshUtils } from "./utils/constants.js";
|
|
4
5
|
import { PrefreshRuntimeModule } from "./utils/Runtime.js";
|
|
5
6
|
import { defineRequire } from "../requireHook.js";
|
|
6
7
|
const internalPrefreshLoader = defineRequire("@freshpack/webpack/internal-prefresh-loader", await import("./loader/index.js"));
|
|
7
8
|
export class DenoPreactRefreshPlugin {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
}
|
|
34
|
-
});
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
apply(compiler) {
|
|
38
|
-
if (compiler.options.mode === "production") {
|
|
39
|
-
return;
|
|
9
|
+
matcher;
|
|
10
|
+
constructor(options) {
|
|
11
|
+
this.options = options;
|
|
12
|
+
this.matcher = Webpack.ModuleFilenameHelpers.matchObject.bind(undefined, matcherOptions);
|
|
13
|
+
}
|
|
14
|
+
webpack5(compiler, RuntimeGlobals) {
|
|
15
|
+
compiler.hooks.compilation.tap(NAME, (compilation, {
|
|
16
|
+
normalModuleFactory
|
|
17
|
+
}) => {
|
|
18
|
+
if (compilation.compiler !== compiler) {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
injectRefreshFunctions(compilation);
|
|
22
|
+
compilation.hooks.additionalTreeRuntimeRequirements.tap(NAME, (chunk, runtimeRequirements) => {
|
|
23
|
+
runtimeRequirements.add(RuntimeGlobals.interceptModuleExecution);
|
|
24
|
+
compilation.addRuntimeModule(chunk, new PrefreshRuntimeModule());
|
|
25
|
+
});
|
|
26
|
+
normalModuleFactory.hooks.afterResolve.tap(NAME, ({
|
|
27
|
+
createData: data
|
|
28
|
+
}) => {
|
|
29
|
+
if (this.matcher(data.resource) && !data.resource.includes("@prefresh") && !data.resource.includes("/prefresh-forked/loader/") && !data.resource.includes("/prefresh-forked/utils/")) {
|
|
30
|
+
data.loaders.unshift({
|
|
31
|
+
loader: internalPrefreshLoader,
|
|
32
|
+
options: undefined
|
|
33
|
+
});
|
|
40
34
|
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
this.webpack5(compiler, compiler.webpack
|
|
54
|
-
? compiler.webpack.RuntimeGlobals
|
|
55
|
-
: Webpack.RuntimeGlobals);
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
apply(compiler) {
|
|
39
|
+
if (compiler.options.mode === "production") {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
const provide = {
|
|
43
|
+
[prefreshUtils]: import.meta.resolve("./utils/prefresh.js")
|
|
44
|
+
};
|
|
45
|
+
if (this.options.overlay) {
|
|
46
|
+
provide.__prefresh_errors__ = import.meta.resolve(this.options.overlay.module);
|
|
56
47
|
}
|
|
48
|
+
const providePlugin = new Webpack.ProvidePlugin(provide);
|
|
49
|
+
providePlugin.apply(compiler);
|
|
50
|
+
const dependency = Webpack.EntryPlugin.createDependency("@prefresh/core", {
|
|
51
|
+
name: "@prefresh/core"
|
|
52
|
+
});
|
|
53
|
+
compiler.hooks.make.tapAsync(NAME, (compilation, callback) => {
|
|
54
|
+
compilation.addEntry(compiler.context, dependency, this.options.entryOptions ?? {}, callback);
|
|
55
|
+
});
|
|
56
|
+
this.webpack5(compiler, compiler.webpack ? compiler.webpack.RuntimeGlobals : Webpack.RuntimeGlobals);
|
|
57
|
+
}
|
|
57
58
|
}
|
|
59
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["/* FIXME: Typings are awful in this file, the port was very crude */\n\nimport Webpack from \"webpack\";\nimport {\n injectRefreshFunctions,\n matcherOptions,\n NAME,\n prefreshUtils,\n} from \"./utils/constants.ts\";\nimport { PrefreshRuntimeModule } from \"./utils/Runtime.ts\";\nimport { defineRequire } from \"../requireHook.ts\";\n\ntype Options = {\n overlay?: {\n module: string;\n };\n entryOptions?: string | Webpack.EntryOptions;\n};\n\nconst internalPrefreshLoader = defineRequire(\n \"@freshpack/webpack/internal-prefresh-loader\",\n await import(\"./loader/index.ts\"),\n);\n\nexport class DenoPreactRefreshPlugin {\n matcher;\n constructor(public options: Options) {\n this.matcher = Webpack.ModuleFilenameHelpers.matchObject.bind(\n undefined,\n matcherOptions,\n );\n }\n\n webpack5(\n compiler: Webpack.Compiler,\n RuntimeGlobals: typeof Webpack.RuntimeGlobals,\n ) {\n compiler.hooks.compilation.tap(\n NAME,\n (compilation, { normalModuleFactory }) => {\n if (compilation.compiler !== compiler) {\n return;\n }\n\n injectRefreshFunctions(compilation);\n\n compilation.hooks.additionalTreeRuntimeRequirements.tap(\n NAME,\n (chunk, runtimeRequirements) => {\n runtimeRequirements.add(RuntimeGlobals.interceptModuleExecution);\n compilation.addRuntimeModule(chunk, new PrefreshRuntimeModule());\n },\n );\n\n normalModuleFactory.hooks.afterResolve.tap(\n NAME,\n ({ createData: data }) => {\n if (\n this.matcher(data.resource!) &&\n !data.resource!.includes(\"@prefresh\") &&\n !data.resource!.includes(\"/prefresh-forked/loader/\") &&\n !data.resource!.includes(\"/prefresh-forked/utils/\")\n ) {\n data.loaders!.unshift({\n loader: internalPrefreshLoader,\n options: undefined,\n });\n }\n },\n );\n },\n );\n }\n\n apply(compiler: Webpack.Compiler) {\n if (\n compiler.options.mode === \"production\"\n ) {\n return;\n }\n\n const provide = {\n [prefreshUtils]: import.meta.resolve(\"./utils/prefresh.ts\"),\n };\n\n if (this.options.overlay) {\n (provide as any).__prefresh_errors__ = import.meta.resolve(\n this.options.overlay.module,\n );\n }\n\n const providePlugin = new Webpack.ProvidePlugin(provide);\n providePlugin.apply(compiler);\n const dependency = Webpack.EntryPlugin.createDependency(\n \"@prefresh/core\",\n { name: \"@prefresh/core\" },\n );\n compiler.hooks.make.tapAsync(NAME, (compilation, callback) => {\n compilation.addEntry(\n compiler.context,\n dependency,\n this.options.entryOptions ?? {},\n callback as any,\n );\n });\n\n this.webpack5(\n compiler,\n compiler.webpack\n ? compiler.webpack.RuntimeGlobals\n : Webpack.RuntimeGlobals,\n );\n }\n}\n"],"mappings":"AAAA;;AAEA,OAAO,OAAO,MAAM,SAAS;AAC7B,SACE,sBAAsB,EACtB,cAAc,EACd,IAAI,EACJ,aAAa,QACR,sBAAs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"text" };
|
|
2
2
|
export default function RefreshHotLoader(source, inputSourceMap) {
|
|
3
|
-
|
|
3
|
+
this.callback(null, source + "\n\n" + runtimeText, inputSourceMap);
|
|
4
4
|
}
|
|
5
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["import type Webpack from \"webpack\";\nimport runtimeText from \"./runtime.js\" with { type: \"text\" };\n\nexport default function RefreshHotLoader(\n this: any,\n source: Webpack.sources.SourceMapSource,\n inputSourceMap: Webpack.sources.SourceMapSource[\"source\"],\n) {\n this.callback(null, source + \"\\n\\n\" + runtimeText, inputSourceMap);\n}\n"],"mappings":"AACA,OAAO,WAAW,MAAM,cAAc,QAAQ,IAAI,EAAE,MAAM;AAE1D,eAAe,SAAS,gBAAgB,CAEtC,MAAuC,EACvC,cAAyD,EACzD;EACA,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,WAAW,EAAE,cAAc,CAAC;AACpE","ignoreList":[]}
|
|
@@ -13,40 +13,15 @@ self.$RefreshSig$ = function() {
|
|
|
13
13
|
}
|
|
14
14
|
`;
|
|
15
15
|
export class PrefreshRuntimeModule extends Webpack.RuntimeModule {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
`if (typeof self !== "undefined" && typeof self.${NAMESPACE} !== "undefined") {`,
|
|
27
|
-
Webpack.Template.indent([
|
|
28
|
-
`${declare} prevRefreshReg = self.$RefreshReg$;`,
|
|
29
|
-
`${declare} prevRefreshSig = self.$RefreshSig$;`,
|
|
30
|
-
beforeModule,
|
|
31
|
-
`${declare} reg = ${runtimeTemplate.basicFunction("currentModuleId", [
|
|
32
|
-
"self.$RefreshReg$ = function(type, id) {",
|
|
33
|
-
Webpack.Template.indent(`self.${NAMESPACE}.register(type, currentModuleId + ' ' + id);`),
|
|
34
|
-
"};",
|
|
35
|
-
])}`,
|
|
36
|
-
"reg()",
|
|
37
|
-
"try {",
|
|
38
|
-
Webpack.Template.indent("originalFactory.call(this, moduleObject, moduleExports, webpackRequire);"),
|
|
39
|
-
"} finally {",
|
|
40
|
-
Webpack.Template.indent("self.$RefreshReg$ = prevRefreshReg;"),
|
|
41
|
-
Webpack.Template.indent("self.$RefreshSig$ = prevRefreshSig;"),
|
|
42
|
-
"}",
|
|
43
|
-
]),
|
|
44
|
-
"} else {",
|
|
45
|
-
Webpack.Template.indent("originalFactory.call(this, moduleObject, moduleExports, webpackRequire);"),
|
|
46
|
-
"}",
|
|
47
|
-
])}`,
|
|
48
|
-
])})`,
|
|
49
|
-
"",
|
|
50
|
-
]);
|
|
51
|
-
}
|
|
16
|
+
constructor() {
|
|
17
|
+
super("prefresh", 5);
|
|
18
|
+
}
|
|
19
|
+
generate() {
|
|
20
|
+
const {
|
|
21
|
+
runtimeTemplate
|
|
22
|
+
} = this.compilation;
|
|
23
|
+
const declare = runtimeTemplate.supportsConst() ? "const" : "var";
|
|
24
|
+
return Webpack.Template.asString([`${Webpack.RuntimeGlobals.interceptModuleExecution}.push(${runtimeTemplate.basicFunction("options", [`${declare} originalFactory = options.factory;`, `options.factory = ${runtimeTemplate.basicFunction("moduleObject, moduleExports, webpackRequire", [`if (typeof self !== "undefined" && typeof self.${NAMESPACE} !== "undefined") {`, Webpack.Template.indent([`${declare} prevRefreshReg = self.$RefreshReg$;`, `${declare} prevRefreshSig = self.$RefreshSig$;`, beforeModule, `${declare} reg = ${runtimeTemplate.basicFunction("currentModuleId", ["self.$RefreshReg$ = function(type, id) {", Webpack.Template.indent(`self.${NAMESPACE}.register(type, currentModuleId + ' ' + id);`), "};"])}`, "reg()", "try {", Webpack.Template.indent("originalFactory.call(this, moduleObject, moduleExports, webpackRequire);"), "} finally {", Webpack.Template.indent("self.$RefreshReg$ = prevRefreshReg;"), Webpack.Template.indent("self.$RefreshSig$ = prevRefreshSig;"), "}"]), "} else {", Webpack.Template.indent("originalFactory.call(this, moduleObject, moduleExports, webpackRequire);"), "}"])}`])})`, ""]);
|
|
25
|
+
}
|
|
52
26
|
}
|
|
27
|
+
//# sourceMappingURL=Runtime.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sources":["Runtime.ts"],"sourcesContent":["import Webpack from \"webpack\";\n\nconst NAMESPACE = \"__PREFRESH__\";\n\nconst beforeModule = `\nself.$RefreshSig$ = function() {\n var status = 'begin';\n var savedType;\n\n return function(type, key, forceReset, getCustomHooks) {\n if (!savedType) savedType = type;\n status = self.${NAMESPACE}.sign(type || savedType, key, forceReset, getCustomHooks, status);\n return type;\n }\n}\n`;\n\nexport class PrefreshRuntimeModule extends Webpack.RuntimeModule {\n constructor() {\n super(\"prefresh\", 5);\n }\n\n override generate() {\n const { runtimeTemplate } = this.compilation as any;\n const declare = runtimeTemplate.supportsConst() ? \"const\" : \"var\";\n\n return Webpack.Template.asString([\n `${Webpack.RuntimeGlobals.interceptModuleExecution}.push(${\n runtimeTemplate.basicFunction(\"options\", [\n `${declare} originalFactory = options.factory;`,\n `options.factory = ${\n runtimeTemplate.basicFunction(\n \"moduleObject, moduleExports, webpackRequire\",\n [\n `if (typeof self !== \"undefined\" && typeof self.${NAMESPACE} !== \"undefined\") {`,\n Webpack.Template.indent([\n `${declare} prevRefreshReg = self.$RefreshReg$;`,\n `${declare} prevRefreshSig = self.$RefreshSig$;`,\n beforeModule,\n `${declare} reg = ${\n runtimeTemplate.basicFunction(\n \"currentModuleId\",\n [\n \"self.$RefreshReg$ = function(type, id) {\",\n Webpack.Template.indent(\n `self.${NAMESPACE}.register(type, currentModuleId + ' ' + id);`,\n ),\n \"};\",\n ],\n )\n }`,\n \"reg()\",\n \"try {\",\n Webpack.Template.indent(\n \"originalFactory.call(this, moduleObject, moduleExports, webpackRequire);\",\n ),\n \"} finally {\",\n Webpack.Template.indent(\n \"self.$RefreshReg$ = prevRefreshReg;\",\n ),\n Webpack.Template.indent(\n \"self.$RefreshSig$ = prevRefreshSig;\",\n ),\n \"}\",\n ]),\n \"} else {\",\n Webpack.Template.indent(\n \"originalFactory.call(this, moduleObject, moduleExports, webpackRequire);\",\n ),\n \"}\",\n ],\n )\n }`,\n ])\n })`,\n \"\",\n ]);\n }\n}\n"],"mappings":"AAAA,OAAO,OAAO,MAAM,SAAS;AAE7B,MAAM,SAAS,GAAG,cAAc;AAEhC,MAAM,YAAY,GAAG;AACrB;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB,SAAS;AAC7B;AACA;AACA;AACA,CAAC;AAED,OAAO,MAAM,qBAAqB,SAAS,OAAO,CAAC,aAAa,CAAC;EAC/D,WAAW,GAAG;IACZ,KAAK,CAAC,UAAU,EAAE,CAAC,CAAC;EACtB;EAES,QAAQ,GAAG;IAClB,MAAM;MAAE;IAAgB,CAAC,GAAG,IAAI,CAAC,WAAkB;IACnD,MAAM,OAAO,GAAG,eAAe,CAAC,aAAa,CAAC,CAAC,GAAG,OAAO,GAAG,KAAK;IAEjE,OAAO,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAC/B,GAAG,OAAO,CAAC,cAAc,CAAC,wBAAwB,SAChD,eAAe,CAAC,aAAa,CAAC,SAAS,EAAE,CACvC,GAAG,OAAO,qCAAqC,EAC/C,qBACE,eAAe,CAAC,aAAa,CAC3B,6CAA6C,EAC7C,CACE,kDAAkD,SAAS,qBAAqB,EAChF,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,CACtB,GAAG,OAAO,sCAAsC,EAChD,GAAG,OAAO,sCAAsC,EAChD,YAAY,EACZ,GAAG,OAAO,UACR,eAAe,CAAC,aAAa,CAC3B,iBAAiB,EACjB,CACE,0CAA0C,EAC1C,OAAO,CAAC,QAAQ,CAAC,MAAM,CACrB,QAAQ,SAAS,8CACnB,CAAC,EACD,IAAI,CAER,CAAC,EACD,EACF,OAAO,EACP,OAAO,EACP,OAAO,CAAC,QAAQ,CAAC,MAAM,CACrB,0EACF,CAAC,EACD,aAAa,EACb,OAAO,CAAC,QAAQ,CAAC,MAAM,CACrB,qCACF,CAAC,EACD,OAAO,CAAC,QAAQ,CAAC,MAAM,CACrB,qCACF,CAAC,EACD,GAAG,CACJ,CAAC,EACF,UAAU,EACV,OAAO,CAAC,QAAQ,CAAC,MAAM,CACrB,0EACF,CAAC,EACD,GAAG,CAEP,CAAC,EACD,CACH,CAAC,GACD,EACH,EAAE,CACH,CAAC;EACJ;AACF","ignoreList":[]}
|
|
@@ -2,22 +2,11 @@ import Webpack from "webpack";
|
|
|
2
2
|
export const prefreshUtils = "__prefresh_utils__";
|
|
3
3
|
export const NAME = "PrefreshWebpackPlugin";
|
|
4
4
|
export const matcherOptions = {
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
include: /\.([jt]sx?)$/,
|
|
6
|
+
exclude: /node_modules|\/deno\/npm\//
|
|
7
7
|
};
|
|
8
8
|
export function injectRefreshFunctions(compilation) {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
source,
|
|
12
|
-
"",
|
|
13
|
-
"// noop fns to prevent runtime errors during initialization",
|
|
14
|
-
'if (typeof self !== "undefined") {',
|
|
15
|
-
Webpack.Template.indent("self.$RefreshReg$ = function () {};"),
|
|
16
|
-
Webpack.Template.indent("self.$RefreshSig$ = function () {"),
|
|
17
|
-
Webpack.Template.indent(Webpack.Template.indent("return function (type) {")),
|
|
18
|
-
Webpack.Template.indent(Webpack.Template.indent(Webpack.Template.indent("return type;"))),
|
|
19
|
-
Webpack.Template.indent(Webpack.Template.indent("};")),
|
|
20
|
-
Webpack.Template.indent("};"),
|
|
21
|
-
"}",
|
|
22
|
-
]));
|
|
9
|
+
const hookVars = compilation.mainTemplate.hooks.localVars;
|
|
10
|
+
hookVars.tap("ReactFreshWebpackPlugin", source => Webpack.Template.asString([source, "", "// noop fns to prevent runtime errors during initialization", 'if (typeof self !== "undefined") {', Webpack.Template.indent("self.$RefreshReg$ = function () {};"), Webpack.Template.indent("self.$RefreshSig$ = function () {"), Webpack.Template.indent(Webpack.Template.indent("return function (type) {")), Webpack.Template.indent(Webpack.Template.indent(Webpack.Template.indent("return type;"))), Webpack.Template.indent(Webpack.Template.indent("};")), Webpack.Template.indent("};"), "}"]));
|
|
23
11
|
}
|
|
12
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sources":["constants.ts"],"sourcesContent":["import Webpack from \"webpack\";\n\nexport const prefreshUtils = \"__prefresh_utils__\";\nexport const NAME = \"PrefreshWebpackPlugin\";\n\nexport const matcherOptions = {\n include: /\\.([jt]sx?)$/,\n exclude: /node_modules|\\/deno\\/npm\\//,\n};\n\nexport function injectRefreshFunctions(compilation: Webpack.Compilation) {\n const hookVars = compilation.mainTemplate.hooks.localVars;\n\n hookVars.tap(\n \"ReactFreshWebpackPlugin\",\n (source) =>\n Webpack.Template.asString([\n source,\n \"\",\n \"// noop fns to prevent runtime errors during initialization\",\n 'if (typeof self !== \"undefined\") {',\n Webpack.Template.indent(\"self.$RefreshReg$ = function () {};\"),\n Webpack.Template.indent(\"self.$RefreshSig$ = function () {\"),\n Webpack.Template.indent(\n Webpack.Template.indent(\"return function (type) {\"),\n ),\n Webpack.Template.indent(\n Webpack.Template.indent(Webpack.Template.indent(\"return type;\")),\n ),\n Webpack.Template.indent(Webpack.Template.indent(\"};\")),\n Webpack.Template.indent(\"};\"),\n \"}\",\n ]),\n );\n}\n"],"mappings":"AAAA,OAAO,OAAO,MAAM,SAAS;AAE7B,OAAO,MAAM,aAAa,GAAG,oBAAoB;AACjD,OAAO,MAAM,IAAI,GAAG,uBAAuB;AAE3C,OAAO,MAAM,cAAc,GAAG;EAC5B,OAAO,EAAE,cAAc;EACvB,OAAO,EAAE;AACX,CAAC;AAED,OAAO,SAAS,sBAAsB,CAAC,WAAgC,EAAE;EACvE,MAAM,QAAQ,GAAG,WAAW,CAAC,YAAY,CAAC,KAAK,CAAC,SAAS;EAEzD,QAAQ,CAAC,GAAG,CACV,yBAAyB,EACxB,MAAM,IACL,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC,CACxB,MAAM,EACN,EAAE,EACF,6DAA6D,EAC7D,oCAAoC,EACpC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,qCAAqC,CAAC,EAC9D,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,mCAAmC,CAAC,EAC5D,OAAO,CAAC,QAAQ,CAAC,MAAM,CACrB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,0BAA0B,CACpD,CAAC,EACD,OAAO,CAAC,QAAQ,CAAC,MAAM,CACrB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,cAAc,CAAC,CACjE,CAAC,EACD,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,EACtD,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,EAC7B,GAAG,CACJ,CACL,CAAC;AACH","ignoreList":[]}
|
|
@@ -1,47 +1,40 @@
|
|
|
1
1
|
import { flush, isComponent } from "@prefresh/utils";
|
|
2
|
+
|
|
2
3
|
// eslint-disable-next-line
|
|
3
|
-
export const getExports =
|
|
4
|
+
export const getExports = m => m.exports || m.__proto__.exports;
|
|
4
5
|
function isSafeExport(key) {
|
|
5
|
-
|
|
6
|
-
key === "__N_SSG" ||
|
|
7
|
-
key === "__N_SSP" ||
|
|
8
|
-
key === "config");
|
|
6
|
+
return key === "__esModule" || key === "__N_SSG" || key === "__N_SSP" || key === "config";
|
|
9
7
|
}
|
|
10
8
|
export function registerExports(moduleExports, moduleId) {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
const typeID = moduleId + " %exports% " + key;
|
|
20
|
-
self["__PREFRESH__"].register(exportValue, typeID);
|
|
21
|
-
}
|
|
9
|
+
if (typeof self !== "undefined" && typeof self["__PREFRESH__"] !== "undefined") {
|
|
10
|
+
self["__PREFRESH__"].register(moduleExports, moduleId + " %exports%");
|
|
11
|
+
if (moduleExports == null || typeof moduleExports !== "object") return;
|
|
12
|
+
for (const key in moduleExports) {
|
|
13
|
+
if (isSafeExport(key)) continue;
|
|
14
|
+
const exportValue = moduleExports[key];
|
|
15
|
+
const typeID = moduleId + " %exports% " + key;
|
|
16
|
+
self["__PREFRESH__"].register(exportValue, typeID);
|
|
22
17
|
}
|
|
18
|
+
}
|
|
23
19
|
}
|
|
24
|
-
export const shouldBind =
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
20
|
+
export const shouldBind = m => {
|
|
21
|
+
let isCitizen = false;
|
|
22
|
+
const moduleExports = getExports(m);
|
|
23
|
+
if (isComponent(moduleExports)) {
|
|
24
|
+
isCitizen = true;
|
|
25
|
+
}
|
|
26
|
+
if (moduleExports === undefined || moduleExports === null || typeof moduleExports !== "object") {
|
|
27
|
+
isCitizen = isCitizen || false;
|
|
28
|
+
} else {
|
|
29
|
+
for (const key in moduleExports) {
|
|
30
|
+
if (key === "__esModule") continue;
|
|
31
|
+
const exportValue = moduleExports[key];
|
|
32
|
+
if (isComponent(exportValue)) {
|
|
33
|
+
isCitizen = isCitizen || true;
|
|
34
|
+
}
|
|
29
35
|
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
typeof moduleExports !== "object") {
|
|
33
|
-
isCitizen = isCitizen || false;
|
|
34
|
-
}
|
|
35
|
-
else {
|
|
36
|
-
for (const key in moduleExports) {
|
|
37
|
-
if (key === "__esModule")
|
|
38
|
-
continue;
|
|
39
|
-
const exportValue = moduleExports[key];
|
|
40
|
-
if (isComponent(exportValue)) {
|
|
41
|
-
isCitizen = isCitizen || true;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
return isCitizen;
|
|
36
|
+
}
|
|
37
|
+
return isCitizen;
|
|
46
38
|
};
|
|
47
39
|
export { flush };
|
|
40
|
+
//# sourceMappingURL=prefresh.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sources":["prefresh.ts"],"sourcesContent":["import { flush, isComponent } from \"@prefresh/utils\";\n\n// eslint-disable-next-line\nexport const getExports = (m: any) => m.exports || m.__proto__.exports;\n\nfunction isSafeExport(key: string) {\n return (\n key === \"__esModule\" ||\n key === \"__N_SSG\" ||\n key === \"__N_SSP\" ||\n key === \"config\"\n );\n}\n\nexport function registerExports(moduleExports: any, moduleId: string) {\n if (\n typeof self !== \"undefined\" && typeof self[\"__PREFRESH__\"] !== \"undefined\"\n ) {\n self[\"__PREFRESH__\"].register(moduleExports, moduleId + \" %exports%\");\n if (moduleExports == null || typeof moduleExports !== \"object\") return;\n\n for (const key in moduleExports) {\n if (isSafeExport(key)) continue;\n const exportValue = moduleExports[key];\n const typeID = moduleId + \" %exports% \" + key;\n self[\"__PREFRESH__\"].register(exportValue, typeID);\n }\n }\n}\n\nexport const shouldBind = (m: any) => {\n let isCitizen = false;\n const moduleExports = getExports(m);\n\n if (isComponent(moduleExports)) {\n isCitizen = true;\n }\n\n if (\n moduleExports === undefined ||\n moduleExports === null ||\n typeof moduleExports !== \"object\"\n ) {\n isCitizen = isCitizen || false;\n } else {\n for (const key in moduleExports) {\n if (key === \"__esModule\") continue;\n\n const exportValue = moduleExports[key];\n if (isComponent(exportValue)) {\n isCitizen = isCitizen || true;\n }\n }\n }\n\n return isCitizen;\n};\n\nexport { flush };\n"],"mappings":"AAAA,SAAS,KAAK,EAAE,WAAW,QAAQ,iBAAiB;;AAEpD;AACA,OAAO,MAAM,UAAU,GAAI,CAAM,IAAK,CAAC,CAAC,OAAO,IAAI,CAAC,CAAC,SAAS,CAAC,OAAO;AAEtE,SAAS,YAAY,CAAC,GAAW,EAAE;EACjC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AC/B;IACF;EACF;EAEA,OAAO,SAAS;AAClB,CAAC;AAED,SAAS,KAAK","ignoreList":[]}
|
package/quasiquote.js
CHANGED
|
@@ -1,30 +1,32 @@
|
|
|
1
1
|
export function toJsRaw(v) {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
2
|
+
if (typeof v === "string") {
|
|
3
|
+
return {
|
|
4
|
+
_jsRaw: JSON.stringify(v)
|
|
5
|
+
};
|
|
6
|
+
}
|
|
7
|
+
if (v instanceof Array) {
|
|
8
|
+
return {
|
|
9
|
+
_jsRaw: "[" + v.map(v => toJsRaw(v)._jsRaw).join(v.length > 5 ? ",\n" : ",") + "]"
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
if (v instanceof Map) {
|
|
13
|
+
return js`new Map(${v.entries().map(([name, v]) => js`[${name},${v}]`).toArray()})`;
|
|
14
|
+
}
|
|
15
|
+
if (typeof v === "object" && !("_jsRaw" in v)) {
|
|
16
|
+
const entries = Object.entries(v);
|
|
17
|
+
return {
|
|
18
|
+
_jsRaw: "{" + entries.map(([name, v]) => `${name}:${toJsRaw(v)._jsRaw}`).join(entries.length > 10 ? ",\n" : ",") + "}"
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
if (typeof v === "undefined") {
|
|
22
|
+
return js`undefined`;
|
|
23
|
+
}
|
|
24
|
+
if (v === null) {
|
|
25
|
+
return js`null`;
|
|
26
|
+
}
|
|
27
|
+
return v;
|
|
27
28
|
}
|
|
28
29
|
export const js = (template, ...subs) => ({
|
|
29
|
-
|
|
30
|
+
_jsRaw: String.raw(template, ...subs.map(v => toJsRaw(v)._jsRaw))
|
|
30
31
|
});
|
|
32
|
+
//# sourceMappingURL=quasiquote.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sources":["quasiquote.ts"],"sourcesContent":["export type JsRaw = { _jsRaw: string };\ntype ToJsRaw =\n | string\n | JsRaw\n | (ToJsRaw[])\n | Record<string, string | JsRaw>\n | Map<string, JsRaw>\n | undefined;\nexport function toJsRaw(v: ToJsRaw): JsRaw {\n if (typeof v === \"string\") {\n return { _jsRaw: JSON.stringify(v) };\n }\n if (v instanceof Array) {\n return {\n _jsRaw: \"[\" + v.map((v) =>\n toJsRaw(v)._jsRaw\n ).join(v.length > 5 ? \",\\n\" : \",\") +\n \"]\",\n };\n }\n if (v instanceof Map) {\n return js`new Map(${\n v.entries().map(([name, v]) => js`[${name},${v}]`).toArray()\n })`;\n }\n if (typeof v === \"object\" && !(\"_jsRaw\" in v)) {\n const entries = Object.entries(v);\n return {\n _jsRaw: \"{\" + entries.map(([name, v]) =>\n `${name}:${toJsRaw(v)._jsRaw}`\n ).join(entries.length > 10 ? \",\\n\" : \",\") + \"}\",\n };\n }\n if (typeof v === \"undefined\") {\n return js`undefined`;\n }\n if (v === null) {\n return js`null`;\n }\n return v as JsRaw;\n}\nexport const js = (template: TemplateStringsArray, ...subs: ToJsRaw[]) => ({\n _jsRaw: String.raw(template, ...subs.map((v) => toJsRaw(v)._jsRaw)),\n});\n"],"mappings":"AAQA,OAAO,SAAS,OAAO,CAAC,CAAU,EAAS;EACzC,IAAI,OAAO,CAAC,KAAK,QAAQ,EAAE;IACzB,OAAO;MAAE,MAAM,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC;IAAE,CAAC;EACtC;EACA,IAAI,CAAC,YAAY,KAAK,EAAE;IACtB,OAAO;MACL,MAAM,EAAE,GAAG,GAAG,CAAC,CAAC,GAAG,CAAE,CAAC,IACpB,OAAO,CAAC,CAAC,CA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