npm_ext 0.1.4 → 0.1.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.
- checksums.yaml +4 -4
- data/lib/npm_ext/mkmf.rb +11 -7
- data/lib/npm_ext/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ab2466075be3e449081ba4700c280dcee8b9fbf92b2c6d32dac09955fc5ac0d6
|
4
|
+
data.tar.gz: 3c1f9db83bfb9f985c4cef0c8070c6e51953902a3c00c155c620f1e15e5d4780
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c5ce0f44017c8a7679977913c3b10e2c6662308c481d4736608a30254fcfabe6c9364514eff792a8616b663beebb8951496164856c77f60bea58d73797221f5c
|
7
|
+
data.tar.gz: 9f1cab867d35da784ec71ace559d3f1ce9bd9428d75766c222b4d36692ff5e779774ee9412a0775ff05948ce8abda300865a0a612bbe803ca7832ed848278f3e
|
data/lib/npm_ext/mkmf.rb
CHANGED
@@ -10,9 +10,7 @@ module NpmExt
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def to_json(*_args)
|
13
|
-
|
14
|
-
require("#{@name}")()
|
15
|
-
JS
|
13
|
+
"require(\"#{@name}\")()"
|
16
14
|
end
|
17
15
|
end
|
18
16
|
|
@@ -44,9 +42,8 @@ module NpmExt
|
|
44
42
|
def create_rollup_config(dir)
|
45
43
|
parse_package_json(dir).to_h do |package|
|
46
44
|
hash = Digest::MD5.hexdigest(package.name.to_s)
|
47
|
-
config = "rollup.config.#{hash}.js"
|
48
45
|
output_js = "#{hash}.npm_ext.js"
|
49
|
-
|
46
|
+
config = "module.exports = #{JSON.generate(
|
50
47
|
{
|
51
48
|
# TODO: if no file provided get the input file from package.json
|
52
49
|
input: "node_modules/#{package.name}/#{package.file_to_bundle}",
|
@@ -59,7 +56,7 @@ module NpmExt
|
|
59
56
|
RollupConfigPlugin.new x
|
60
57
|
end,
|
61
58
|
},
|
62
|
-
)}"
|
59
|
+
)}"
|
63
60
|
[package.name, {
|
64
61
|
rollup_config: config,
|
65
62
|
output_js: output_js,
|
@@ -70,17 +67,24 @@ module NpmExt
|
|
70
67
|
def create_npm_makefile(dir)
|
71
68
|
configs = create_rollup_config(dir)
|
72
69
|
File.write("Makefile", <<~MAKE)
|
70
|
+
sitearchdir ?= /tmp/
|
71
|
+
.PHONY: install
|
73
72
|
install:
|
74
73
|
\tcp #{dir}/package*.json ./ || :
|
75
74
|
\tnpm ci
|
76
75
|
\tnpm i #{ROLLUP_PACKAGES.join(" ")}
|
77
|
-
#{configs.map
|
76
|
+
#{configs.map do |_, x|
|
77
|
+
"\techo '#{x[:rollup_config]}' > rollup.config.cjs && npx rollup --config && rm -rf rollup.config.cjs"
|
78
|
+
end.join("\n")}
|
78
79
|
\trm -rf npm_ext.so
|
79
80
|
\tnode -e 'const fs = require("fs"); fs.writeFileSync("npm_ext.so", JSON.stringify(Object.fromEntries(#{configs.transform_values { |x| x[:output_js] }.to_a.to_json}.map(([k, v]) => [k, fs.readFileSync(v, "utf8")]))))'
|
81
|
+
\tcp npm_ext.so $(sitearchdir)$(target_prefix)
|
82
|
+
.PHONY: clean
|
80
83
|
clean:
|
81
84
|
\trm -rf node_modules
|
82
85
|
\trm -rf rollup.config.*.js
|
83
86
|
\trm -rf *npm_ext.js
|
87
|
+
\trm -rf npm_ext.so
|
84
88
|
MAKE
|
85
89
|
end
|
86
90
|
end
|
data/lib/npm_ext/version.rb
CHANGED