@freshpack/webpack 1.0.0 → 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.
Files changed (74) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/LICENSE +13 -12
  3. package/denoEnv.d.ts +12 -0
  4. package/denoEnv.js +49 -0
  5. package/denoEnv.js.map +1 -0
  6. package/fresh.d.ts +39 -0
  7. package/fresh.js +245 -0
  8. package/fresh.js.map +1 -0
  9. package/importMetaResolve.d.ts +4 -0
  10. package/importMetaResolve.js +50 -0
  11. package/importMetaResolve.js.map +1 -0
  12. package/mod.d.ts +8 -0
  13. package/mod.js +9 -0
  14. package/mod.js.map +1 -0
  15. package/package.json +81 -9
  16. package/prefresh-forked/index.d.ts +15 -0
  17. package/prefresh-forked/index.js +59 -0
  18. package/prefresh-forked/index.js.map +1 -0
  19. package/prefresh-forked/loader/index.d.ts +2 -0
  20. package/prefresh-forked/loader/index.js +5 -0
  21. package/prefresh-forked/loader/index.js.map +1 -0
  22. package/prefresh-forked/utils/Runtime.d.ts +5 -0
  23. package/prefresh-forked/utils/Runtime.js +27 -0
  24. package/prefresh-forked/utils/Runtime.js.map +1 -0
  25. package/prefresh-forked/utils/constants.d.ts +8 -0
  26. package/prefresh-forked/utils/constants.js +12 -0
  27. package/prefresh-forked/utils/constants.js.map +1 -0
  28. package/prefresh-forked/utils/prefresh.d.ts +5 -0
  29. package/prefresh-forked/utils/{prefresh.ts → prefresh.js} +8 -27
  30. package/prefresh-forked/utils/prefresh.js.map +1 -0
  31. package/quasiquote.d.ts +9 -0
  32. package/quasiquote.js +32 -0
  33. package/quasiquote.js.map +1 -0
  34. package/rawBytesLoader.d.ts +5 -0
  35. package/rawBytesLoader.js +10 -0
  36. package/rawBytesLoader.js.map +1 -0
  37. package/rawImports.d.ts +13 -0
  38. package/rawImports.js +44 -0
  39. package/rawImports.js.map +1 -0
  40. package/requireHook.d.ts +1 -0
  41. package/{requireHook.ts → requireHook.js} +5 -10
  42. package/requireHook.js.map +1 -0
  43. package/resolve.d.ts +11 -0
  44. package/resolve.js +395 -0
  45. package/resolve.js.map +1 -0
  46. package/transpileLoader.d.ts +9 -0
  47. package/transpileLoader.js +46 -0
  48. package/transpileLoader.js.map +1 -0
  49. package/unmap.d.ts +9 -0
  50. package/unmap.js +94 -0
  51. package/unmap.js.map +1 -0
  52. package/util.d.ts +9 -0
  53. package/{util.ts → util.js} +13 -19
  54. package/util.js.map +1 -0
  55. package/viteComment.d.ts +8 -0
  56. package/viteComment.js +28 -0
  57. package/viteComment.js.map +1 -0
  58. package/buildCacheUtil.ts +0 -11
  59. package/denoEnv.ts +0 -78
  60. package/fresh.ts +0 -391
  61. package/mod.ts +0 -7
  62. package/prefresh-forked/index.ts +0 -114
  63. package/prefresh-forked/loader/index.ts +0 -10
  64. package/prefresh-forked/utils/Runtime.ts +0 -79
  65. package/prefresh-forked/utils/constants.ts +0 -35
  66. package/prefresh-forked/utils/createTemplate.ts +0 -76
  67. package/prefresh-forked/utils/injectEntry.ts +0 -28
  68. package/quasiquote.ts +0 -44
  69. package/rawBytesLoader.ts +0 -17
  70. package/rawImports.ts +0 -85
  71. package/resolve.ts +0 -588
  72. package/transpileLoader.ts +0 -59
  73. package/unmap.ts +0 -154
  74. package/viteComment.ts +0 -41
package/unmap.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sources":["unmap.ts"],"sourcesContent":["import type * as Webpack from \"webpack\";\nimport { assert } from \"@std/assert\";\n\ninterface UnmapCompilation extends Webpack.Compilation {\n unmapping: Record<string, string>;\n}\n\nexport function assertUnmapCompilation(\n compilation: Webpack.Compilation,\n): asserts compilation is UnmapCompilation {\n assert(\n \"unmapping\" in compilation,\n \"missing fresh data in compilation, did you add WebpackFreshEntries plugin?\",\n );\n}\nexport class UnmapPlugin {\n apply(compiler: Webpack.Compiler) {\n const mappings = new Map<\n string,\n { name: string; module: Webpack.Module; loc: Webpack.Dependency[\"loc\"] }\n >();\n const nameToRequest = new Map<string, string>();\n const nameToAsset = new Map<string, string>();\n\n compiler.hooks.compilation.tap(\n UnmapPlugin.name,\n (compilation, { normalModuleFactory }) => {\n normalModuleFactory.hooks.parser.for(\"javascript/auto\").tap(\n UnmapPlugin.name,\n (parser) => {\n parser.hooks.call.for(\"unmap\").tap(UnmapPlugin.name, (expr) => {\n const error = (msg: string) => {\n const err = new compiler.webpack.WebpackError(msg);\n err.loc = expr.loc!;\n parser.state.module.addError(\n err,\n );\n };\n if (expr.arguments.length !== 2) {\n return error(`unmap requires (name, new URL()) arguments`);\n }\n\n const nameArg = parser.evaluateExpression(expr.arguments[0]);\n if (!nameArg.isString()) {\n return error(\n `first argument for unmap should be a static string`,\n );\n }\n\n const urlExpr = expr.arguments[1];\n if (\n urlExpr.type !== \"NewExpression\" ||\n urlExpr.callee.type !== \"Identifier\" ||\n urlExpr.callee.name !== \"URL\"\n ) {\n return error(\n `second argument for unmap should be new URL() expression`,\n );\n }\n const key = `${parser.state.module.identifier()}:${\n urlExpr.range![0]\n }`;\n mappings.set(key, {\n name: nameArg.string!,\n module: parser.state.module,\n loc: expr.loc!,\n });\n });\n },\n );\n\n compilation.hooks.afterOptimizeModules.tap(\n UnmapPlugin.name,\n () => {\n for (const module of compilation.modules) {\n if (!module.dependencies) return;\n\n for (const dep of module.dependencies) {\n if (dep.constructor.name !== \"URLDependency\") continue;\n const dep_ = dep as unknown as { outerRange: [number, number] };\n\n const key = `${module.identifier()}:${dep_.outerRange[0]}`;\n const name = mappings.get(key);\n\n if (!name) continue;\n\n const error = (msg: string) => {\n const err = new compiler.webpack.WebpackError(\n msg,\n );\n err.module = name.module;\n err.loc = name.loc;\n compilation.errors.push(err);\n };\n\n const connection = compilation.moduleGraph.getConnection(\n dep,\n );\n if (!connection || !connection.module) {\n error(\"unable to find connection for url dependency\");\n continue;\n }\n const mod = connection.module as {\n resource?: string;\n userRequest?: string;\n };\n const request = mod.resource ?? mod.userRequest;\n if (!request) {\n error(`unable to resolve unmap request`);\n continue;\n }\n\n {\n const oldV = nameToRequest.get(name.name);\n if (oldV !== undefined && oldV !== request) {\n error(\n `ResolutionConflict: unmap(${\n JSON.stringify(name.name)\n }, ${\n JSON.stringify(request)\n }) was previously resolved to ${oldV}, use a different unmapping`,\n );\n continue;\n }\n }\n nameToRequest.set(name.name, request);\n }\n }\n },\n );\n compilation.hooks.processAssets.tap(UnmapPlugin.name, (assets) => {\n for (const [name, request] of nameToRequest.entries()) {\n for (const [assetName, _asset] of Object.entries(assets)) {\n const info = compilation.assetsInfo.get(assetName);\n if (\n info?.sourceFilename && request.endsWith(info.sourceFilename)\n ) {\n nameToAsset.set(name, assetName);\n break;\n }\n }\n }\n const unmapping = Object.fromEntries(nameToAsset);\n const json = JSON.stringify(unmapping);\n compilation.emitAsset(\n \"mapped.json\",\n new compiler.webpack.sources.RawSource(json),\n );\n (compilation as UnmapCompilation).unmapping = unmapping;\n });\n },\n );\n }\n}\n"],"mappings":"AACA,SAAS,MAAM,QAAQ,aAAa;AAMpC,OAAO,SAAS,sBAAsB,CACpC,WAAgC,EACS;EACzC,MAAM,CACJ,WAAW,IAAI,WAAW,EAC1B,4EACF,CAAC;AACH;AACA,OAAO,MAAM,WAAW,CAAC;EACvB,KAAK,CAAC,QAA0B,EAAE;IAChC,MAAM,QAAQ,GAAG,IAAI,GAAG,CAGtB,CAAC;IACH,MAAM,aAAa,GAAG,IAAI,GAAG,CAAiB,CAAC;IAC/C,MAAM,WAAW,GAAG,IAAI,GAAG,CAAiB,CAAC;IAE7C,QAAQ,CAAC,KAAK,CAAC,WAAW,CAAC,GAAG,CAC5B,WAAW,CAAC,IAAI,EAChB,CAAC,WAAW,EAAE;MAAE;IAAoB,CAAC,KAAK;MACxC,mBAAmB,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC,GAAG,CACzD,WAAW,CAAC,IAAI,EACf,MAAM,IAAK;QACV,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC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I,KAAK,SAAS,IAAI,IAAI,KAAK,OAAO,EAAE;gBAC1C,KAAK,CACH,6BACE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,KAEzB,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,gCACO,IAAI,6BACtC,CAAC;gBACD;cACF;YACF;YACA,aAAa,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,OAAO,CAAC;UACvC;QACF;MACF,CACF,CAAC;MACD,WAAW,CAAC,KAAK,CAAC,aAAa,CAAC,GAAG,CAAC,WAAW,CAAC,IAAI,EAAG,MAAM,IAAK;QAChE,KAAK,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,IAAI,aAAa,CAAC,OAAO,CAAC,CAAC,EAAE;UACrD,KAAK,MAAM,CAAC,SAAS,EAAE,MAAM,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE;YACxD,MAAM,IAAI,GAAG,WAAW,CAAC,UAAU,CAAC,GAAG,CAAC,SAAS,CAAC;YAClD,IACE,IAAI,EAAE,cAAc,IAAI,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,cAAc,CAAC,EAC7D;cACA,WAAW,CAAC,GAAG,CAAC,IAAI,EAAE,SAAS,CAAC;cAChC;YACF;UACF;QACF;QACA,MAAM,SAAS,GAAG,MAAM,CAAC,WAAW,CAAC,WAAW,CAAC;QACjD,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC;QACtC,WAAW,CAAC,SAAS,CACnB,aAAa,EACb,IAAI,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC,IAAI,CAC7C,CAAC;QACA,WAAW,CAAsB,SAAS,GAAG,SAAS;MACzD,CAAC,CAAC;IACJ,CACF,CAAC;EACH;AACF","ignoreList":[]}
package/util.d.ts ADDED
@@ -0,0 +1,9 @@
1
+ export declare function stripFileUrl(u: string): string;
2
+ export declare function resolveNpm(u: string): string;
3
+ export declare function manglePath(path: string): string;
4
+ export declare function assertAbsolutePath(path: string): void;
5
+ export declare function assertDirURL(path: URL): void;
6
+ export declare function ensureModPath(path: string): string;
7
+ export declare function ensureFilePath(path: string): string;
8
+ export declare function assertResolved(path: string): void;
9
+ export declare function ensureFileUrl(path: string): URL;
@@ -1,37 +1,30 @@
1
1
  import { assert } from "@std/assert";
2
-
3
- export function stripFileUrl(u: string) {
2
+ export function stripFileUrl(u) {
4
3
  assert(u.startsWith("file://"), `not a file url: ${u}`);
5
4
  return u.slice(7);
6
5
  }
7
- export function resolveNpm(u: string) {
6
+ export function resolveNpm(u) {
8
7
  const path = import.meta.resolve(`npm:${u}`);
9
8
  return stripFileUrl(path);
10
9
  }
11
-
12
- export function manglePath(path: string) {
13
- const tokens = path.replaceAll(/\\/g, "/").split(/([^a-zA-Z0-9_]+)/).filter((
14
- s,
15
- ) => s);
16
-
17
- return "_" + tokens.map((s) => {
10
+ export function manglePath(path) {
11
+ const tokens = path.replaceAll(/\\/g, "/").split(/([^a-zA-Z0-9_]+)/).filter(s => s);
12
+ return "_" + tokens.map(s => {
18
13
  if (/^[a-zA-Z0-9_]+$/.test(s)) {
19
14
  return s.length + s;
20
15
  }
21
- return s.split("").map((c) => "_" + c.charCodeAt(0).toString(16)).join("");
16
+ return s.split("").map(c => "_" + c.charCodeAt(0).toString(16)).join("");
22
17
  }).join("");
23
18
  }
24
-
25
- export function assertAbsolutePath(path: string) {
19
+ export function assertAbsolutePath(path) {
26
20
  // TODO: Windows
27
21
  assert(path.startsWith("/"), `path is not absolute: ${path}`);
28
22
  }
29
-
30
- export function assertDirURL(path: URL) {
23
+ export function assertDirURL(path) {
31
24
  const stat = Deno.statSync(path);
32
25
  assert(stat.isDirectory, `path is not a directory: ${path}`);
33
26
  }
34
- export function ensureModPath(path: string) {
27
+ export function ensureModPath(path) {
35
28
  if (path.endsWith("/fakeMod.ts")) return path;
36
29
  if (!path.startsWith("https://")) {
37
30
  const stat = Deno.statSync(path);
@@ -44,15 +37,16 @@ export function ensureModPath(path: string) {
44
37
  if (!path.endsWith("/")) path += "/fakeMod.ts";
45
38
  return path;
46
39
  }
47
- export function ensureFilePath(path: string) {
40
+ export function ensureFilePath(path) {
48
41
  const stat = Deno.statSync(path);
49
42
  assert(stat.isFile, `path is not a file: ${path}`);
50
43
  assert(!path.endsWith("/"), "file paths shouldn't end with /");
51
44
  return path;
52
45
  }
53
- export function assertResolved(path: string) {
46
+ export function assertResolved(path) {
54
47
  assert(path.startsWith("https://"), `path is not https: ${path}`);
55
48
  }
56
- export function ensureFileUrl(path: string) {
49
+ export function ensureFileUrl(path) {
57
50
  return new URL(`file://${ensureFilePath(path)}`);
58
51
  }
52
+ //# sourceMappingURL=util.js.map
package/util.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sources":["util.ts"],"sourcesContent":["import { assert } from \"@std/assert\";\n\nexport function stripFileUrl(u: string) {\n assert(u.startsWith(\"file://\"), `not a file url: ${u}`);\n return u.slice(7);\n}\nexport function resolveNpm(u: string) {\n const path = import.meta.resolve(`npm:${u}`);\n return stripFileUrl(path);\n}\n\nexport function manglePath(path: string) {\n const tokens = path.replaceAll(/\\\\/g, \"/\").split(/([^a-zA-Z0-9_]+)/).filter((\n s,\n ) => s);\n\n return \"_\" + tokens.map((s) => {\n if (/^[a-zA-Z0-9_]+$/.test(s)) {\n return s.length + s;\n }\n return s.split(\"\").map((c) => \"_\" + c.charCodeAt(0).toString(16)).join(\"\");\n }).join(\"\");\n}\n\nexport function assertAbsolutePath(path: string) {\n // TODO: Windows\n assert(path.startsWith(\"/\"), `path is not absolute: ${path}`);\n}\n\nexport function assertDirURL(path: URL) {\n const stat = Deno.statSync(path);\n assert(stat.isDirectory, `path is not a directory: ${path}`);\n}\nexport function ensureModPath(path: string) {\n if (path.endsWith(\"/fakeMod.ts\")) return path;\n if (!path.startsWith(\"https://\")) {\n const stat = Deno.statSync(path);\n if (stat.isFile) return path;\n assert(stat.isDirectory, `path is not a directory: ${path}`);\n }\n if (path.endsWith(\".ts\") || path.endsWith(\".js\") || path.endsWith(\".mjs\")) {\n return path;\n }\n if (!path.endsWith(\"/\")) path += \"/fakeMod.ts\";\n return path;\n}\nexport function ensureFilePath(path: string) {\n const stat = Deno.statSync(path);\n assert(stat.isFile, `path is not a file: ${path}`);\n assert(!path.endsWith(\"/\"), \"file paths shouldn't end with /\");\n return path;\n}\nexport function assertResolved(path: string) {\n assert(path.startsWith(\"https://\"), `path is not https: ${path}`);\n}\nexport function ensureFileUrl(path: string) {\n return new URL(`file://${ensureFilePath(path)}`);\n}\n"],"mappings":"AAAA,SAAS,MAAM,QAAQ,aAAa;AAEpC,OAAO,SAAS,YAAY,CAAC,CAAS,EAAE;EACtC,MAAM,CAAC,CAAC,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE,mBAAmB,CAAC,EAAE,CAAC;EACvD,OAAO,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;AACnB;AACA,OAAO,SAAS,UAAU,CAAC,CAAS,EAAE;EACpC,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;EAC5C,OAAO,YAAY,CAAC,IAAI,CAAC;AAC3B;AAEA,OAAO,SAAS,UAAU,CAAC,IAAY,EAAE;EACvC,MAAM,MAAM,GAAG,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,KAAK,CAAC,kBAAkB,CAAC,CAAC,MAAM,CACzE,CAAC,IACE,CAAC,CAAC;EAEP,OAAO,GAAG,GAAG,MAAM,CAAC,GAAG,CAAE,CAAC,IAAK;IAC7B,IAAI,iBAAiB,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE;MAC7B,OAAO,CAAC,CAAC,MAAM,GAAG,CAAC;IACrB;IACA,OAAO,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,GAAG,CAAE,CAAC,IAAK,GAAG,GAAG,CAAC,CAAC,UAAU,CAAC,CAAC,CAA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AAE,CAAC;EAClD,MAAM,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,iCAAiC,CAAC;EAC9D,OAAO,IAAI;AACb;AACA,OAAO,SAAS,cAAc,CAAC,IAAY,EAAE;EAC3C,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,sBAAsB,IAAI,EAAE,CAAC;AACnE;AACA,OAAO,SAAS,aAAa,CAAC,IAAY,EAAE;EAC1C,OAAO,IAAI,GAAG,CAAC,UAAU,cAAc,CAAC,IAAI,CAAC,EAAE,CAAC;AAClD","ignoreList":[]}
@@ -0,0 +1,8 @@
1
+ import type { Compiler } from "webpack";
2
+ /**
3
+ * ViteIgnorePlugin skips parsing of `import` calls that contain `@vite-inore` in inline comment, similarly
4
+ * to webpack built-in `webpackIgnore: true` annotation
5
+ */
6
+ export declare class ViteIgnorePlugin {
7
+ apply(compiler: Compiler): void;
8
+ }
package/viteComment.js ADDED
@@ -0,0 +1,28 @@
1
+ const NAME = "ViteIgnorePlugin";
2
+ const PARSER_TYPES = ["javascript/auto", "javascript/dynamic", "javascript/esm"];
3
+
4
+ /**
5
+ * ViteIgnorePlugin skips parsing of `import` calls that contain `@vite-inore` in inline comment, similarly
6
+ * to webpack built-in `webpackIgnore: true` annotation
7
+ */
8
+ export class ViteIgnorePlugin {
9
+ apply(compiler) {
10
+ compiler.hooks.compilation.tap(NAME, (_compilation, {
11
+ normalModuleFactory
12
+ }) => {
13
+ const handler = parser => {
14
+ parser.hooks.importCall.tap({
15
+ name: NAME,
16
+ stage: -10
17
+ }, expr => {
18
+ const ignored = parser.getComments([expr.range[0], expr.source.range[1]]).some(comment => comment.type === "Block" && comment.value.includes("@vite-ignore"));
19
+ if (ignored) return false;
20
+ });
21
+ };
22
+ for (const type of PARSER_TYPES) {
23
+ normalModuleFactory.hooks.parser.for(type).tap(NAME, handler);
24
+ }
25
+ });
26
+ }
27
+ }
28
+ //# sourceMappingURL=viteComment.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sources":["viteComment.ts"],"sourcesContent":["import type Webpack from \"webpack\";\nimport type { Compiler } from \"webpack\";\n\ntype JavascriptParser = Webpack.javascript.JavascriptParser;\n\nconst NAME = \"ViteIgnorePlugin\";\n\nconst PARSER_TYPES = [\n \"javascript/auto\",\n \"javascript/dynamic\",\n \"javascript/esm\",\n] as const;\n\n/**\n * ViteIgnorePlugin skips parsing of `import` calls that contain `@vite-inore` in inline comment, similarly\n * to webpack built-in `webpackIgnore: true` annotation\n */\nexport class ViteIgnorePlugin {\n apply(compiler: Compiler) {\n compiler.hooks.compilation.tap(\n NAME,\n (_compilation, { normalModuleFactory }) => {\n const handler = (parser: JavascriptParser) => {\n parser.hooks.importCall.tap({ name: NAME, stage: -10 }, (expr) => {\n const ignored = parser.getComments([\n expr.range![0],\n expr.source.range![1],\n ]).some((comment) =>\n comment.type === \"Block\" &&\n comment.value.includes(\"@vite-ignore\")\n );\n if (ignored) return false;\n });\n };\n for (const type of PARSER_TYPES) {\n normalModuleFactory.hooks.parser.for(type).tap(NAME, handler);\n }\n },\n );\n }\n}\n"],"mappings":"AAKA,MAAM,IAAI,GAAG,kBAAkB;AAE/B,MAAM,YAAY,GAAG,CACnB,iBAAiB,EACjB,oBAAoB,EACpB,gBAAgB,CACR;;AAEV;AACA;AACA;AACA;AACA,OAAO,MAAM,gBAAgB,CAAC;EAC5B,KAAK,CAAC,QAAkB,EAAE;IACxB,QAAQ,CAAC,KAAK,CAAC,WAAW,CAAC,GAAG,CAC5B,IAAI,EACJ,CAAC,YAAY,EAAE;MAAE;IAAoB,CAAC,KAAK;MACzC,MAAM,OAAO,GAAI,MAAwB,IAAK;QAC5C,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC,GAAG,CAAC;UAAE,IAAI,EAAE,IAAI;UAAE,KAAK,EAAE,CAAC;QAAG,CAAC,EAAG,IAAI,IAAK;UAChE,MAAM,OAAO,GAAG,MAAM,CAAC,WAAW,CAAC,CACjC,IAAI,CAAC,KAAK,CAAE,CAAC,CAAC,EACd,IAAI,CAAC,MAAM,CAAC,KAAK,CAAE,CAAC,CAAC,CACtB,CAAC,CAAC,IAAI,CAAE,OAAO,IACd,OAAO,CAAC,IAAI,KAAK,OAAO,IACxB,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,cAAc,CACvC,CAAC;UACD,IAAI,OAAO,EAAE,OAAO,KAAK;QAC3B,CAAC,CAAC;MACJ,CAAC;MACD,KAAK,MAAM,IAAI,IAAI,YAAY,EAAE;QAC/B,mBAAmB,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,IAAI,EAAE,OAAO,CAAC;MAC/D;IACF,CACF,CAAC;EACH;AACF","ignoreList":[]}
package/buildCacheUtil.ts DELETED
@@ -1,11 +0,0 @@
1
- import type { IslandPreparer, setBuildCache } from "@freshpack/core/internal";
2
- import type * as Webpack from "webpack";
3
-
4
- export type OriginalBuildCache<State> = Parameters<
5
- typeof setBuildCache<State>
6
- >[1];
7
- export type ServerIslandRegistry = Parameters<IslandPreparer["prepare"]>[0];
8
- export type OriginalStaticFile = ReturnType<
9
- OriginalBuildCache<unknown>["readFile"]
10
- >;
11
- export type WebpackFS = Exclude<Webpack.Compiler["outputFileSystem"], null>;
package/denoEnv.ts DELETED
@@ -1,78 +0,0 @@
1
- import Webpack, { type Compiler } from "webpack";
2
-
3
- type JavascriptParser = Webpack.javascript.JavascriptParser;
4
-
5
- const NAME = "DenoEnvPlugin";
6
-
7
- const PARSER_TYPES = [
8
- "javascript/auto",
9
- "javascript/dynamic",
10
- "javascript/esm",
11
- ] as const;
12
-
13
- export type DenoEnvOptions = {
14
- allowedEnv?: (string | RegExp)[];
15
- };
16
-
17
- /**
18
- * DenoEnvPlugin replaces calls to `Deno.env.get` with a constant expression of environment variable name.
19
- */
20
- export class DenoEnvPlugin {
21
- #allowed: (string | RegExp)[];
22
- constructor(opts: DenoEnvOptions = {}) {
23
- this.#allowed = [
24
- ...opts.allowedEnv ?? [],
25
- /^FRESH_PUBLIC_/,
26
- "NODE_ENV",
27
- "DENO_DEPLOYMENT_ID",
28
- "GITHUB_SHA",
29
- "CI_COMMIT_SHA",
30
- "CI",
31
- ];
32
- }
33
- #isAllowed(name: string) {
34
- return this.#allowed.some((allowed) =>
35
- allowed instanceof RegExp ? allowed.test(name) : allowed === name
36
- );
37
- }
38
- #value(name: string, compiler: Compiler) {
39
- if (name === "NODE_ENV") {
40
- const mode = compiler.options.mode;
41
- if (mode !== undefined && mode !== "none") return mode;
42
- }
43
- return Deno.env.get(name);
44
- }
45
- apply(compiler: Compiler) {
46
- compiler.hooks.compilation.tap(
47
- NAME,
48
- (_compilation, { normalModuleFactory }) => {
49
- const handler = (parser: JavascriptParser) => {
50
- parser.hooks.call.for("Deno.env.get").tap(NAME, (expr) => {
51
- const [arg] = expr.arguments;
52
- if (
53
- expr.arguments.length !== 1 || arg.type !== "Literal" ||
54
- typeof arg.value !== "string"
55
- ) {
56
- return;
57
- }
58
- const name = arg.value;
59
- if (!this.#isAllowed(name)) {
60
- throw new Error(`Env var is not allowed in bundling: ${name}`);
61
- }
62
- const value = this.#value(name, compiler);
63
- const dep = new Webpack.dependencies.ConstDependency(
64
- value === undefined ? "undefined" : JSON.stringify(value),
65
- expr.range!,
66
- );
67
- if (expr.loc) dep.loc = expr.loc;
68
- parser.state.module.addPresentationalDependency(dep);
69
- return true;
70
- });
71
- };
72
- for (const type of PARSER_TYPES) {
73
- normalModuleFactory.hooks.parser.for(type).tap(NAME, handler);
74
- }
75
- },
76
- );
77
- }
78
- }
package/fresh.ts DELETED
@@ -1,391 +0,0 @@
1
- import {
2
- crawlFsItem,
3
- type FsRouteFileNoMod,
4
- } from "@freshpack/core/internal-dev";
5
- import Webpack from "webpack";
6
- import {
7
- assertAbsolutePath,
8
- assertDirURL,
9
- manglePath,
10
- stripFileUrl,
11
- } from "./util.ts";
12
- import { assert } from "@std/assert";
13
- import { IslandPreparer, ProdBuildCache } from "@freshpack/core/internal";
14
- import {
15
- extname as extnamePosix,
16
- join as joinPosix,
17
- relative as relativePosix,
18
- } from "@std/path/posix";
19
- import { contentType as getStdContentType } from "@std/media-types/content-type";
20
- import { encodeHex } from "@std/encoding";
21
- import { UnmapPlugin } from "./unmap.ts";
22
- import { type DenoEnvOptions, DenoEnvPlugin } from "./denoEnv.ts";
23
- import { ViteIgnorePlugin } from "./viteComment.ts";
24
- import { type RawImportsOptions, RawImportsPlugin } from "./rawImports.ts";
25
- import { js, type JsRaw, toJsRaw } from "./quasiquote.ts";
26
-
27
- interface WebpackFreshCompilation extends Webpack.Compilation {
28
- freshRoutes: FsRouteFileNoMod<unknown>[];
29
- freshIslands: { entryName: string; filePath: string }[];
30
- freshRoot: string;
31
- buildId: string;
32
-
33
- prodBuildCache: ProdBuildCache<unknown>;
34
- }
35
-
36
- export function assertFreshCompilation(
37
- compilation: Webpack.Compilation,
38
- ): asserts compilation is WebpackFreshCompilation {
39
- assert(
40
- "freshRoutes" in compilation && "freshIslands" in compilation &&
41
- "freshRoot" in compilation,
42
- "missing fresh data in compilation, did you add WebpackFreshEntries plugin?",
43
- );
44
- }
45
-
46
- type CacheStaticFile = {
47
- name: string;
48
- filePath: string;
49
- contentType: string;
50
- hash: string;
51
- data: Uint8Array;
52
- size: number;
53
- };
54
-
55
- function getMainChunkName(
56
- basePath: string,
57
- e: Webpack.Entrypoint,
58
- ): string {
59
- const entryChunk = e.getEntrypointChunk();
60
- const files = [...entryChunk.files].map((v) => joinPosix(basePath, v));
61
- return files[0];
62
- }
63
- function getChunkFiles(
64
- basePath: string,
65
- e: Webpack.Entrypoint,
66
- ): string[] {
67
- return e.getFiles().map((v) => joinPosix(basePath, v));
68
- }
69
-
70
- export class FreshPlugin {
71
- /**
72
- * @param baseUrl Location of fresh project root directory, you can specify it as `new URL('.', import.meta.url)` in build.ts
73
- * @param importHelper JSR dynamic file import workaround: You should pass `(path) => import(path)` here, where the function
74
- * should be defined anywhere outside of JSR published package. See this for details: https://github.com/denoland/deno/discussions/26266
75
- * This function will always be called with absolute path.
76
- */
77
- constructor(
78
- public baseUrl: URL,
79
- public importHelper: (path: string) => Promise<Record<string, unknown>>,
80
- public options: { env?: DenoEnvOptions; rawImports?: RawImportsOptions } =
81
- {},
82
- ) {
83
- assertDirURL(this.baseUrl);
84
- if (!importHelper) {
85
- console.warn(
86
- "[FreshPlugin]",
87
- "importHelper is not set, jsr release of @freshpack/webpack doesn't work without it: https://github.com/denoland/deno/discussions/26266#discussioncomment-12198284",
88
- );
89
- this.importHelper = (path: string) => import(path);
90
- }
91
- }
92
- pathRelativeToBase(path: string) {
93
- return relativePosix(this.baseUrl.pathname, path);
94
- }
95
- #dist?: string;
96
- pathRelativeToDist(path: string) {
97
- assert(this.#dist, "dist path was not determined yet");
98
- return relativePosix(this.#dist, path);
99
- }
100
-
101
- apply(compiler: Webpack.Compiler) {
102
- {
103
- // HACK: Webpack does not export EntryDependency, and it is impossible to use EntryPlugin, as
104
- // it wants to modify make stage, yet we have already reached this stage when we want to use
105
- // this plugin.
106
- //
107
- // Solvable by creating custom dependency plugin, or requiring user to manually specify
108
- // at least one entry... Or by registering EntryDependency manually as done here.
109
- const EntryDependency =
110
- Webpack.EntryPlugin.createDependency(`dummy`, {}).constructor;
111
-
112
- compiler.hooks.compilation.tap(
113
- FreshPlugin.name,
114
- (compilation, { normalModuleFactory }) => {
115
- compilation.dependencyFactories.set(
116
- EntryDependency as any,
117
- normalModuleFactory,
118
- );
119
- },
120
- );
121
- }
122
-
123
- (new UnmapPlugin()).apply(compiler);
124
- (new DenoEnvPlugin(this.options.env)).apply(compiler);
125
- (new ViteIgnorePlugin()).apply(compiler);
126
- (new RawImportsPlugin(this.options.rawImports)).apply(compiler);
127
- // Some @std and other packages detect deno on presence of Deno global, dead-code-elimnate this stuff
128
- (new Webpack.DefinePlugin({ Deno: "undefined" })).apply(compiler);
129
-
130
- compiler.hooks.make.tapPromise(
131
- FreshPlugin.name,
132
- async (_compilation: Webpack.Compilation) => {
133
- const compilation = _compilation as WebpackFreshCompilation;
134
- this.#dist = compilation.outputOptions.path;
135
-
136
- const compilationId = Date.now().toString(36);
137
-
138
- // Ensure hot chunks are resolved from correct path, they can't contain compilationId in name
139
- compilation.outputOptions.publicPath = "/";
140
- {
141
- // Chunks are content-addressed in prod, and have readable names using standard fresh cache pruning in dev
142
- if (compiler.options.mode === "production") {
143
- compilation.outputOptions.filename =
144
- `_fresh/js/c/[contenthash].mjs`;
145
- compilation.outputOptions.chunkFilename =
146
- `_fresh/js/c/[contenthash].mjs`;
147
- compilation.outputOptions.workerChunkFilename =
148
- `_fresh/js/c/[contenthash].mjs`;
149
- } else {
150
- compilation.outputOptions.filename =
151
- `_fresh/js/${compilationId}/[id].mjs`;
152
- compilation.outputOptions.chunkFilename =
153
- `_fresh/js/${compilationId}/[id].mjs`;
154
- compilation.outputOptions.workerChunkFilename =
155
- `_fresh/js/${compilationId}/[id].mjs`;
156
- }
157
- // Assets are always content-addressed
158
- compilation.outputOptions.assetModuleFilename =
159
- `_fresh/js/c/[hash][ext][query]`;
160
- compilation.outputOptions.webassemblyModuleFilename =
161
- `_fresh/js/c/[hash].wasm`;
162
- }
163
-
164
- compilation.hooks.processAssets.tapPromise(
165
- {
166
- name: FreshPlugin.name,
167
- stage: compiler.webpack.Compilation.PROCESS_ASSETS_STAGE_SUMMARIZE,
168
- },
169
- async (assets) => {
170
- compilation.getAssets();
171
-
172
- const cacheOut: JsRaw[] = [
173
- js`import{IslandPreparer,ProdBuildCache}from"@freshpack/core/internal"`,
174
- js`const islands=new Map()`,
175
- js`const islandPreparer=new IslandPreparer()`,
176
- ];
177
-
178
- const staticFiles = new Map<string, CacheStaticFile>();
179
-
180
- const islands = new Map();
181
- const islandPreparer = new IslandPreparer();
182
- for (const island of compilation.freshIslands) {
183
- const entrypoint = compilation.entrypoints.get(island.entryName);
184
- assert(
185
- entrypoint,
186
- `unable to find island entrypoint: ${island.entryName}`,
187
- );
188
- const file = getMainChunkName(
189
- `/`,
190
- entrypoint,
191
- );
192
-
193
- islandPreparer.prepare(
194
- islands,
195
- await this.importHelper(island.filePath),
196
- file,
197
- island.entryName,
198
- [],
199
- );
200
- const importPath = this.pathRelativeToDist(island.filePath);
201
- cacheOut.push(
202
- js`islandPreparer.prepare(islands,await import(${importPath}),${file},${island.entryName},[])`,
203
- );
204
- }
205
-
206
- const fsRoutesOut: JsRaw[] = [];
207
- const fsRoutes = await Promise.all(
208
- compilation.freshRoutes.map(async (v) => {
209
- const importPath = this.pathRelativeToDist(v.filePath);
210
- fsRoutesOut.push(toJsRaw({
211
- id: v.id,
212
- mod: v.lazy
213
- ? js`()=>import(${importPath})`
214
- : js`await import(${importPath})`,
215
- type: v.type,
216
- pattern: v.pattern,
217
- routePattern: v.routePattern,
218
- }));
219
- assertAbsolutePath(v.filePath);
220
- return {
221
- ...v,
222
- mod: v.lazy
223
- ? () => this.importHelper(v.filePath)
224
- : await this.importHelper(v.filePath),
225
- };
226
- }),
227
- );
228
- cacheOut.push(js`const fsRoutes=${fsRoutesOut}`);
229
-
230
- const clientEntrypoint = compilation.entrypoints.get(
231
- "client-entry",
232
- );
233
- assert(
234
- clientEntrypoint,
235
- `unable to find client entrypoint`,
236
- );
237
- const clientEntry = getMainChunkName(
238
- `/`,
239
- clientEntrypoint,
240
- );
241
- const clientEntryAssets = getChunkFiles(
242
- `/`,
243
- clientEntrypoint,
244
- );
245
- const staticFilesOut = new Map<string, JsRaw>();
246
- for (const _asset of compilation.getAssets()) {
247
- const asset = compilation.getAsset(_asset.name)!;
248
- const file_: Uint8Array<ArrayBufferLike> = assets[asset.name]
249
- .buffer();
250
- const file = file_ as Uint8Array<ArrayBuffer>;
251
- const hash = await crypto.subtle.digest("SHA-1", file.buffer);
252
-
253
- const ext = extnamePosix(asset.name);
254
- const contentType = getStdContentType(ext) ?? "text/plain";
255
-
256
- const name = "/" + asset.name;
257
- staticFiles.set(name, {
258
- name,
259
- filePath: asset.name,
260
- contentType,
261
- hash: encodeHex(hash),
262
- data: file,
263
- size: file.length,
264
- });
265
- staticFilesOut.set(
266
- name,
267
- toJsRaw({
268
- name,
269
- filePath:
270
- js`new URL(${asset.name}, import.meta.url).pathname`,
271
- hash: encodeHex(hash),
272
- contentType,
273
- }),
274
- );
275
- }
276
- cacheOut.push(js`const staticFiles=${staticFilesOut}`);
277
-
278
- cacheOut.push(
279
- js`export default new ProdBuildCache(${compilation.freshRoot}, ${({
280
- version: compilationId,
281
- clientEntry,
282
- entryAssets: toJsRaw(clientEntryAssets),
283
- islands: js`islands`,
284
- fsRoutes: js`fsRoutes`,
285
- staticFiles: js`staticFiles`,
286
- })})`,
287
- );
288
- // Here ProdBuildCache is being used as MemoryBuildCache from fresh
289
- const cache = new ProdBuildCache(compilation.freshRoot, {
290
- version: compilationId,
291
- clientEntry,
292
- fsRoutes,
293
- staticFiles,
294
- islands,
295
- entryAssets: clientEntryAssets,
296
- });
297
- cache.readFile = (pathname) => {
298
- const st = staticFiles.get(pathname);
299
- if (!st) {
300
- return Promise.resolve(null);
301
- }
302
- return Promise.resolve({
303
- contentType: st.contentType,
304
- hash: st.hash,
305
- readable: new ReadableStream({
306
- start(v) {
307
- v.enqueue(st.data);
308
- v.close();
309
- },
310
- }),
311
- size: st.size,
312
- close() {},
313
- });
314
- };
315
- compilation.prodBuildCache = cache;
316
-
317
- compilation.emitAsset(
318
- "./cache.mjs",
319
- new compiler.webpack.sources.RawSource(
320
- cacheOut.map((v) => v._jsRaw).join("\n"),
321
- ),
322
- );
323
- },
324
- );
325
-
326
- const item = await crawlFsItem({
327
- islandDir: stripFileUrl(new URL("islands", this.baseUrl).href),
328
- routeDir: stripFileUrl(new URL("routes", this.baseUrl).href),
329
- ignore: [],
330
- });
331
- compilation.freshRoutes = item.routes;
332
- compilation.freshIslands = [];
333
- compilation.freshRoot = this.pathRelativeToBase(".");
334
-
335
- const addEntryPromises = [];
336
- let isId = 0;
337
- for (const island of item.islands) {
338
- const name = compiler.options.mode === "production"
339
- ? `is${isId++}`
340
- : manglePath(island);
341
- compilation.freshIslands.push({ entryName: name, filePath: island });
342
- addEntryPromises.push(
343
- new Promise<void>((res, rej) =>
344
- compilation.addEntry(
345
- "",
346
- Webpack.EntryPlugin.createDependency(`${island}`, {
347
- name,
348
- }),
349
- {
350
- name,
351
- library: {
352
- type: "module",
353
- },
354
- },
355
- (err) => {
356
- if (err) return rej(err);
357
- res();
358
- },
359
- )
360
- ),
361
- );
362
- }
363
- {
364
- const name = "client-entry";
365
- const file = stripFileUrl(new URL("./client.ts", this.baseUrl).href);
366
- addEntryPromises.push(
367
- new Promise<void>((res, rej) =>
368
- compilation.addEntry(
369
- "",
370
- Webpack.EntryPlugin.createDependency(file, {
371
- name,
372
- }),
373
- {
374
- name,
375
- library: {
376
- type: "module",
377
- },
378
- },
379
- (e) => {
380
- if (e) return rej(e);
381
- res();
382
- },
383
- )
384
- ),
385
- );
386
- }
387
- await Promise.all(addEntryPromises);
388
- },
389
- );
390
- }
391
- }
package/mod.ts DELETED
@@ -1,7 +0,0 @@
1
- export { DenoEnvPlugin } from "./denoEnv.ts";
2
- export { FreshPlugin } from "./fresh.ts";
3
- export { ViteIgnorePlugin } from "./viteComment.ts";
4
- export { DenoPreactRefreshPlugin } from "./prefresh-forked/index.ts";
5
- export { DenoLoaderPlugin } from "./resolve.ts";
6
- export { type RawImportsOptions, RawImportsPlugin } from "./rawImports.ts";
7
- export { UnmapPlugin } from "./unmap.ts";