nodo 1.6.3 → 1.6.4

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 42cd6c0e3e07674ceb2f10dd670c490b7f23ed6534f22f978a40e0b91d529570
4
- data.tar.gz: b560df0c25e2b72842e6d6d5be610503252069bfd1741fb2cd9228066d28f91e
3
+ metadata.gz: a4870340520e40bf14cf0e9261711983d5332eaf04419ff1281626ed5b4716e1
4
+ data.tar.gz: 162b5e4f6739728c91f64422acb579db9c004429f92402db5f393cfb76ffa675
5
5
  SHA512:
6
- metadata.gz: 012ed2197c0ea3e519884b3295a62986158326027adb08c484fbf87903874763594fe72236bebcc01f47a919a4893ef92cdc7a14b1f8ad02da7ea527ae5eab38
7
- data.tar.gz: 6a953be3a789671c966248dcc385740c5964ad0bbb370411d93cdc44ee7ea129c14537d73c08e7a44eb4c19ca1bc2b5465873bec65fd4d56884ba9ed339981d6
6
+ metadata.gz: dbe6fb8dce3f39968b26800a28f50b7d2c1ac49ffc60537a50950af598bc329b6ae59fae2db8285b16167238448ef370502d7b6f736c4dc4e66563ae0050ccfd
7
+ data.tar.gz: 37dd504e71489566a9b57df0e217c2f25d09ce3d511dab2ac6daf849829b90f1293ed07dd4e320eb70ef573da7b466263c704bb99cf46cb555449a8253909089
data/README.md CHANGED
@@ -91,6 +91,23 @@ class FooBar < Nodo::Core
91
91
  end
92
92
  ```
93
93
 
94
+ ### Dynamic ESM imports
95
+
96
+ ES modules can be imported dynamically using `nodo.import()`:
97
+
98
+ ```ruby
99
+ class DynamicFoo < Nodo::Core
100
+ function :v4, <<~JS
101
+ async () => {
102
+ const uuid = await nodo.import('uuid');
103
+ return await uuid.v4()
104
+ }
105
+ JS
106
+ end
107
+ ```
108
+
109
+ Note that the availability of dynamic imports depends on your Node version.
110
+
94
111
  ### Alternate function definition syntax
95
112
 
96
113
  JS code can also be supplied using the `code:` keyword argument:
data/lib/nodo/nodo.js CHANGED
@@ -9,7 +9,7 @@ module.exports = (function() {
9
9
  const path = require('path');
10
10
  const fs = require('fs');
11
11
  const performance = require('perf_hooks').performance;
12
-
12
+
13
13
  let server, closing;
14
14
  const classes = {};
15
15
  const contexts = {};
@@ -48,7 +48,11 @@ module.exports = (function() {
48
48
  console.log(`[Nodo] ${message}`);
49
49
  }
50
50
  }
51
-
51
+
52
+ async function import_module(specifier) {
53
+ return await import(specifier);
54
+ }
55
+
52
56
  const core = {
53
57
  run: (socket) => {
54
58
  debug('Starting up...');
@@ -135,5 +139,5 @@ module.exports = (function() {
135
139
  }
136
140
  };
137
141
 
138
- return { core: core, debug: debug };
142
+ return { core: core, debug: debug, import: import_module };
139
143
  })();
data/lib/nodo/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Nodo
2
- VERSION = '1.6.3'
2
+ VERSION = '1.6.4'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nodo
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.3
4
+ version: 1.6.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matthias Grosser