@package-verse/esmpack 1.0.5 → 1.0.6

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@package-verse/esmpack",
3
- "version": "1.0.5",
3
+ "version": "1.0.6",
4
4
  "description": "ESM Pack Packer and Web Server with PostCSS and ESM Loader",
5
5
  "homepage": "https://github.com/package-verse/esmpack#readme",
6
6
  "bugs": {
@@ -39,7 +39,9 @@
39
39
  "colors": "^1.4.0",
40
40
  "http-proxy-middleware": "^3.0.5",
41
41
  "mime": "^4.1.0",
42
+ "node-forge": "^1.3.3",
42
43
  "portfinder": "^1.0.38",
44
+ "tslib": "^2.8.1",
43
45
  "ws": "^8.19.0"
44
46
  }
45
47
  }
@@ -1,21 +1,37 @@
1
1
  import { IncomingMessage, ServerResponse } from "node:http";
2
2
  import { Babel } from "../../parser/babel.js";
3
- import { parse } from "node:path";
3
+ import path, { parse } from "node:path";
4
+ import { ProcessOptions } from "../../ProcessArgs.js";
5
+ import { readFileSync } from "node:fs";
4
6
 
5
- export default function sendJS(path: string, req: IncomingMessage, res: ServerResponse) {
7
+ export default function sendJS(filePath: string, req: IncomingMessage, res: ServerResponse) {
6
8
 
7
9
 
8
- let text = Babel.transform({ file: path, resolve(url) {
10
+ let text = Babel.transform({ file: filePath, resolve(url) {
9
11
  if (url.endsWith(".css")) {
10
12
  url += ".js";
11
13
  }
14
+ // check if it has no extension...
15
+ const { ext } = parse(url);
16
+ if (!ext) {
17
+ // fetch module...
18
+ const tokens = url.split("/");
19
+ let [packageName] = tokens;
20
+ if (packageName.startsWith("@")) {
21
+ packageName += "/" + tokens.shift();
22
+ }
23
+ const packageJsonPath = path.resolve(ProcessOptions.cwd, "node_modules", packageName, "package.json");
24
+ const packageJson = JSON.parse(readFileSync(packageJsonPath, "utf-8"));
25
+ const start = packageJson["module"] || packageJson["main"];
26
+ return "/node_modules/" + url + "/" + start;
27
+ }
12
28
  if (!url.startsWith(".")) {
13
29
  url = "/node_modules/" + url;
14
30
  }
15
31
  return url;
16
32
  }});
17
33
 
18
- const { base } = parse(path);
34
+ const { base } = parse(filePath);
19
35
 
20
36
  text += `\n//# sourceMappingURL=${base}.map`;
21
37
 
@@ -7,6 +7,8 @@ import https from "https";
7
7
  import url from 'url';
8
8
  import { WebSocketServer } from "ws";
9
9
  import fs from "fs";
10
+ import forge from "node-forge";
11
+
10
12
  var netFaces = os.networkInterfaces();
11
13
 
12
14
  function createCert() {
@@ -17,7 +19,6 @@ function createCert() {
17
19
  return JSON.parse(fs.readFileSync(certPath, { encoding: "utf8", flag: "r" }));
18
20
  }
19
21
 
20
- var forge = require('node-forge');
21
22
  var pki = forge.pki;
22
23
 
23
24
  // generate a key pair or use one you have already
@@ -0,0 +1,2 @@
1
+ export default function LogDecorator(... a: any[]) {
2
+ }
@@ -6,7 +6,9 @@ import DateTime from "@web-atoms/date-time/dist/DateTime.js";
6
6
  import "./TestView.local.css";
7
7
 
8
8
  import "./TestView.global.css";
9
+ import LogDecorator from "./LogDecorator.js";
9
10
 
11
+ @LogDecorator
10
12
  export default class DateView extends HTMLElement {
11
13
 
12
14
  connectedCallback() {
package/tsconfig.json CHANGED
@@ -11,6 +11,7 @@
11
11
  "experimentalDecorators": true,
12
12
  "emitDecoratorMetadata": true,
13
13
  "noUnusedLocals": true,
14
+ "importHelpers": true,
14
15
  "jsxFactory": "XNode.create",
15
16
  "lib": [
16
17
  "ES2018",