marko 5.39.48 → 5.39.50

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/bin/markoc.js CHANGED
@@ -95,13 +95,13 @@ var args = require("argly")
95
95
  })
96
96
  .parse();
97
97
  var Minimatch = require("minimatch").Minimatch;
98
- var resolveFrom = require("resolve-from").silent;
98
+ var cwdRequire = require("module").createRequire(nodePath.join(cwd, "_"));
99
99
 
100
100
  // Try to use the Marko compiler installed with the project
101
- var markoCompilerPath = resolveFrom(process.cwd(), "marko/compiler");
101
+ var markoCompilerPath = tryResolve("marko/compiler");
102
102
  const markocPkgVersion = require("../package.json").version;
103
103
 
104
- var markoPkgPath = resolveFrom(process.cwd(), "marko/package.json");
104
+ var markoPkgPath = tryResolve("marko/package.json");
105
105
  var markoPkgVersion = markoPkgPath && require(markoPkgPath).version;
106
106
 
107
107
  var markoCompiler = markoCompilerPath
@@ -439,3 +439,11 @@ if (args.clean) {
439
439
  );
440
440
  }
441
441
  }
442
+
443
+ function tryResolve(id) {
444
+ try {
445
+ return cwdRequire.resolve(id);
446
+ } catch {
447
+ return undefined;
448
+ }
449
+ }
@@ -1,8 +1,7 @@
1
1
  "use strict";
2
2
  // eslint-disable-next-line no-constant-binary-expression
3
3
 
4
- const path = require("path");
5
- const resolveFrom = require("resolve-from");
4
+ const { createRequire } = require("module");
6
5
  const requiredCompilerOptions = { modules: "cjs" };
7
6
  const defaultCompilerOptions = {
8
7
  // eslint-disable-next-line no-constant-condition
@@ -67,9 +66,9 @@ function install(options) {
67
66
 
68
67
  function markoRequireExtension(module, filename) {
69
68
  // Resolve the appropriate compiler relative to the location of the
70
- // marko template file on disk using the "resolve-from" module.
71
- var dirname = path.dirname(filename);
72
- var markoCompilerModulePath = resolveFrom(dirname, "@marko/compiler");
69
+ // marko template file on disk.
70
+ var markoCompilerModulePath =
71
+ createRequire(filename).resolve("@marko/compiler");
73
72
  var markoCompiler = require(markoCompilerModulePath);
74
73
 
75
74
  // Now use the appropriate Marko compiler to compile the Marko template
@@ -1,5 +1,5 @@
1
1
  "use strict";var nodePath = require("path");
2
- var defaultResolveFrom = require("resolve-from");
2
+ var createRequire = require("module").createRequire;
3
3
  var env = process.env.NODE_ENV;
4
4
  var production = !env || env !== "development";
5
5
 
@@ -174,4 +174,8 @@ function patch(Template) {
174
174
 
175
175
  exports.getDeps = getRootDeps;
176
176
  exports.resolveDep = resolveDep;
177
- exports.patch = patch;
177
+ exports.patch = patch;
178
+
179
+ function defaultResolveFrom(dir, id) {
180
+ return createRequire(nodePath.join(dir, "_")).resolve(id);
181
+ }
@@ -773,7 +773,8 @@ function getClassHydrationMode(file, visited = new Set()) {
773
773
 
774
774
  visited.add(fileName);
775
775
 
776
- if (meta.component) {
776
+ // A legacy `w-bind` widget can register through a dependency instead of `component`.
777
+ if (meta.component || meta.widgetBind) {
777
778
  return meta.classHydration = CLASS_HYDRATION_SELF;
778
779
  }
779
780
 
@@ -10,14 +10,13 @@ function enter(path) {
10
10
  'You must provide a promise argument to the "<await>" tag, eg: "<await(promise)>".'
11
11
  );
12
12
  } else if (args.length > 1) {
13
- const {
14
- loc: { start }
15
- } = args[1].node;
16
- const {
17
- loc: { end }
18
- } = args[args.length - 1].node;
13
+ // A built argument has no loc, so the error then marks the tag.
14
+ const first = args[1].node;
15
+ const last = args[args.length - 1].node;
19
16
  throw path.hub.file.buildCodeFrameError(
20
- { loc: { start, end } },
17
+ first.loc && last.loc ?
18
+ { loc: { start: first.loc.start, end: last.loc.end } } :
19
+ path.node,
21
20
  'You can only pass one argument to the "<await>" tag.'
22
21
  );
23
22
  }
@@ -7,7 +7,7 @@ var _babelUtils = require("@marko/compiler/babel-utils");
7
7
 
8
8
 
9
9
  var _modules = _interopRequireDefault(require("@marko/compiler/modules"));
10
- var _magicString = _interopRequireDefault(require("magic-string"));function _interopRequireDefault(e) {return e && e.__esModule ? e : { default: e };}
10
+ var _magicString = require("magic-string");function _interopRequireDefault(e) {return e && e.__esModule ? e : { default: e };}
11
11
  const kEntryState = Symbol();
12
12
  const lassoDepPrefix = "package: ";var _default =
13
13
 
@@ -219,7 +219,7 @@ function addBrowserImports(seenImports, lassoDeps, body, file, entryFile) {
219
219
  let map;
220
220
 
221
221
  if (sourceMaps && dep.startPos !== undefined) {
222
- s = s || new _magicString.default(file.code, { filename });
222
+ s = s || new _magicString.MagicString(file.code, { filename });
223
223
  map = s.snip(dep.startPos, dep.endPos).generateMap({
224
224
  source: filename,
225
225
  includeContent: true
@@ -871,12 +871,12 @@ Each lifecycle event has a corresponding component lifecycle method that can lis
871
871
 
872
872
  ```js
873
873
  class {
874
- onCreate(input, out) { }
875
- onInput(input, out) { }
876
- onRender(out) { }
877
- onMount() { }
878
- onUpdate() { }
879
- onDestroy() { }
874
+ onCreate(input, out) {}
875
+ onInput(input, out) {}
876
+ onRender(out) {}
877
+ onMount() {}
878
+ onUpdate() {}
879
+ onDestroy() {}
880
880
  }
881
881
  ```
882
882
 
package/docs/express.md CHANGED
@@ -32,8 +32,9 @@ Express’s builtin view engine may be asynchronous, but it doesn’t support st
32
32
  > **ProTip**: By using `res.marko()`, properties from [`app.locals`](https://expressjs.com/en/api.html#app.locals) and [`res.locals`](https://expressjs.com/en/api.html#res.locals) are automatically [available on `$global`](https://markojs.com/docs/rendering/#global-data).
33
33
 
34
34
  ```js
35
- import express from "express";
36
35
  import markoPlugin from "@marko/express";
36
+ import express from "express";
37
+
37
38
  import template from "./template.marko";
38
39
 
39
40
  const app = express();
package/docs/fastify.md CHANGED
@@ -24,8 +24,9 @@ The [`@marko/fastify`](https://github.com/marko-js/fastify/) adds a `reply.marko
24
24
  By using `reply.marko` you'll automatically have access to `app.locals`, and `reply.locals` from within your Marko template and custom tags. These values are added to `$global`.
25
25
 
26
26
  ```javascript
27
- import fastify from "fastify";
28
27
  import markoPlugin from "@marko/fastify";
28
+ import fastify from "fastify";
29
+
29
30
  import Template from "./template.marko";
30
31
 
31
32
  const app = fastify();
package/docs/http.md CHANGED
@@ -7,6 +7,7 @@ project for a working example.
7
7
 
8
8
  ```js
9
9
  import http from "http";
10
+
10
11
  import Template from "./index.marko";
11
12
 
12
13
  const port = 8080;
package/docs/koa.md CHANGED
@@ -13,6 +13,7 @@ npm install koa marko --save
13
13
 
14
14
  ```javascript
15
15
  import Koa from "koa";
16
+
16
17
  import Template from "./index.marko";
17
18
 
18
19
  const app = new Koa();
@@ -663,8 +663,8 @@ var html = ReactDOMServer.renderToString(<HelloMessage name="John" />);
663
663
  With React, all custom tags for UI components must be explicitly imported:
664
664
 
665
665
  ```jsx
666
- import Hello from "./components/Hello";
667
666
  import GoodBye from "./components/GoodBye";
667
+ import Hello from "./components/Hello";
668
668
 
669
669
  export default function HelloGoodBye(props) {
670
670
  return (
@@ -770,6 +770,7 @@ Markdown to HTML at _compile-time_:
770
770
 
771
771
  ```js
772
772
  import marked from "marked";
773
+
773
774
  import { removeIndentation } from "./util";
774
775
 
775
776
  export default function generateCode(el, codegen) {
package/docs/redux.md CHANGED
@@ -55,6 +55,7 @@ In `counter.marko`, the imported store module exports a Redux store created with
55
55
 
56
56
  ```js
57
57
  import redux from "redux";
58
+
58
59
  import counter from "./reducer.js";
59
60
 
60
61
  export default redux.createStore(counter);
package/docs/rendering.md CHANGED
@@ -104,6 +104,7 @@ The HTML output is written to the passed `stream`. Render errors are emitted as
104
104
 
105
105
  ```js
106
106
  import http from "http";
107
+
107
108
  import View from "./view.marko";
108
109
 
109
110
  http.createServer((req, res) => {
@@ -177,6 +178,7 @@ The `stream` method returns a Node.js-style stream of the output HTML.
177
178
 
178
179
  ```js
179
180
  import fs from "fs";
181
+
180
182
  import View from "./view.marko";
181
183
  const writeStream = fs.createWriteStream("output.html");
182
184
 
package/docs/rollup.md CHANGED
@@ -80,16 +80,18 @@ The following configuration file is long and hairy, which may be upsetting to so
80
80
  ```js
81
81
  import { builtinModules } from "module";
82
82
  import path from "path";
83
- import autoprefixer from "autoprefixer";
83
+
84
+ import markoPlugin from "@marko/rollup";
84
85
  import babelPlugin from "@rollup/plugin-babel";
85
86
  import commonjsPlugin from "@rollup/plugin-commonjs";
86
87
  import jsonPlugin from "@rollup/plugin-json";
87
- import markoPlugin from "@marko/rollup";
88
88
  import nodeResolvePlugin from "@rollup/plugin-node-resolve";
89
89
  import replacePlugin from "@rollup/plugin-replace";
90
90
  import runPlugin from "@rollup/plugin-run";
91
- import stylesPlugin from "rollup-plugin-styles";
92
91
  import urlPlugin from "@rollup/plugin-url";
92
+ import autoprefixer from "autoprefixer";
93
+ import stylesPlugin from "rollup-plugin-styles";
94
+
93
95
  import pkg from "./package.json";
94
96
 
95
97
  const __DEV__ = process.env.NODE_ENV === "development";
package/docs/vite.md CHANGED
@@ -9,8 +9,8 @@ npm install @marko/vite vite
9
9
  # Example config
10
10
 
11
11
  ```javascript
12
- import { defineConfig } from "vite";
13
12
  import marko from "@marko/vite";
13
+ import { defineConfig } from "vite";
14
14
  export default defineConfig({
15
15
  plugins: [marko()],
16
16
  });
package/docs/webpack.md CHANGED
@@ -127,6 +127,7 @@ For example, with the Webpack internationalization plugin, you might have a conf
127
127
  ```js
128
128
  import MarkoPlugin from "@marko/webpack/plugin";
129
129
  import I18nPlugin from "i18n-webpack-plugin";
130
+
130
131
  import germanTranslations from "./de.json";
131
132
 
132
133
  const languages = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "marko",
3
- "version": "5.39.48",
3
+ "version": "5.39.50",
4
4
  "private": false,
5
5
  "description": "UI Components + streaming, async, high performance, HTML templating for Node.js and the browser.",
6
6
  "keywords": [
@@ -67,8 +67,8 @@
67
67
  },
68
68
  "types": "index.d.ts",
69
69
  "dependencies": {
70
- "@marko/compiler": "^5.42.14",
71
- "@marko/runtime-tags": "^6.4.8",
70
+ "@marko/compiler": "^5.42.17",
71
+ "@marko/runtime-tags": "^6.4.11",
72
72
  "app-module-path": "^2.2.0",
73
73
  "argly": "^1.2.0",
74
74
  "browser-refresh-client": "1.1.4",
@@ -76,18 +76,17 @@
76
76
  "csstype": "^3.2.3",
77
77
  "events-light": "^1.0.5",
78
78
  "listener-tracker": "^2.0.0",
79
- "magic-string": "^0.30.21",
80
- "minimatch": "^10.2.5",
79
+ "magic-string": "^1.4.5",
80
+ "minimatch": "^11.0.4",
81
81
  "raptor-util": "^3.2.0",
82
- "resolve-from": "^5.0.0",
83
82
  "self-closing-tags": "^1.0.1",
84
83
  "warp10": "^2.1.0"
85
84
  },
86
85
  "devDependencies": {
87
- "marko": "5.39.48"
86
+ "marko": "5.39.50"
88
87
  },
89
88
  "engines": {
90
- "node": ">=22"
89
+ "node": ">=22.12.0"
91
90
  },
92
91
  "logo": {
93
92
  "url": "https://raw.githubusercontent.com/marko-js/branding/master/marko-logo-small.png"
@@ -1,8 +1,7 @@
1
1
  "use strict";
2
2
  // eslint-disable-next-line no-constant-binary-expression
3
3
  const complain = "MARKO_DEBUG" && require("complain");
4
- const path = require("path");
5
- const resolveFrom = require("resolve-from");
4
+ const { createRequire } = require("module");
6
5
  const requiredCompilerOptions = { modules: "cjs" };
7
6
  const defaultCompilerOptions = {
8
7
  // eslint-disable-next-line no-constant-condition
@@ -67,9 +66,9 @@ function install(options) {
67
66
 
68
67
  function markoRequireExtension(module, filename) {
69
68
  // Resolve the appropriate compiler relative to the location of the
70
- // marko template file on disk using the "resolve-from" module.
71
- var dirname = path.dirname(filename);
72
- var markoCompilerModulePath = resolveFrom(dirname, "@marko/compiler");
69
+ // marko template file on disk.
70
+ var markoCompilerModulePath =
71
+ createRequire(filename).resolve("@marko/compiler");
73
72
  var markoCompiler = require(markoCompilerModulePath);
74
73
 
75
74
  // Now use the appropriate Marko compiler to compile the Marko template
@@ -1,5 +1,5 @@
1
1
  var nodePath = require("path");
2
- var defaultResolveFrom = require("resolve-from");
2
+ var createRequire = require("module").createRequire;
3
3
  var env = process.env.NODE_ENV;
4
4
  var production = !env || env !== "development";
5
5
 
@@ -175,3 +175,7 @@ function patch(Template) {
175
175
  exports.getDeps = getRootDeps;
176
176
  exports.resolveDep = resolveDep;
177
177
  exports.patch = patch;
178
+
179
+ function defaultResolveFrom(dir, id) {
180
+ return createRequire(nodePath.join(dir, "_")).resolve(id);
181
+ }
@@ -773,7 +773,8 @@ function getClassHydrationMode(file, visited = new Set()) {
773
773
 
774
774
  visited.add(fileName);
775
775
 
776
- if (meta.component) {
776
+ // A legacy `w-bind` widget can register through a dependency instead of `component`.
777
+ if (meta.component || meta.widgetBind) {
777
778
  return (meta.classHydration = CLASS_HYDRATION_SELF);
778
779
  }
779
780
 
@@ -10,14 +10,13 @@ export function enter(path) {
10
10
  'You must provide a promise argument to the "<await>" tag, eg: "<await(promise)>".',
11
11
  );
12
12
  } else if (args.length > 1) {
13
- const {
14
- loc: { start },
15
- } = args[1].node;
16
- const {
17
- loc: { end },
18
- } = args[args.length - 1].node;
13
+ // A built argument has no loc, so the error then marks the tag.
14
+ const first = args[1].node;
15
+ const last = args[args.length - 1].node;
19
16
  throw path.hub.file.buildCodeFrameError(
20
- { loc: { start, end } },
17
+ first.loc && last.loc
18
+ ? { loc: { start: first.loc.start, end: last.loc.end } }
19
+ : path.node,
21
20
  'You can only pass one argument to the "<await>" tag.',
22
21
  );
23
22
  }
@@ -7,7 +7,7 @@ import {
7
7
  resolveRelativePath,
8
8
  } from "@marko/compiler/babel-utils";
9
9
  import markoModules from "@marko/compiler/modules";
10
- import MagicString from "magic-string";
10
+ import { MagicString } from "magic-string";
11
11
  const kEntryState = Symbol();
12
12
  const lassoDepPrefix = "package: ";
13
13