npm_ext 0.1.2 → 0.1.3

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: 6b22aef9431b51fb055fc039ce7345a71679c247da3c1d01308696ce08dc32a0
4
- data.tar.gz: c3932eb4ecca826574d7e1f2d123ff2d033f7538fe2227276e26a76d6f4d4cd2
3
+ metadata.gz: 014df2845c93a8f9bb6d14c4d9b11d921af128104a0cdc52f492d639325d4a22
4
+ data.tar.gz: 1397cb03abb4af017e079d6c4b8d1fdfbfe2062e1cfcffdcc2bcf20806701552
5
5
  SHA512:
6
- metadata.gz: fe7bd61bf6eeeb0c8e0a4980ad779e51ab8d116249547b4dfb8b97089670520e078f205d6f741edc4fd7a04ff6067276b1680d77a28ba6ad6a0832d1f80b94eb
7
- data.tar.gz: 2026f7eebc502e2aa4f320523a34fa2911e45a01e9a10e1a0a52f599dc954648d2ef111338694176b66f5f20e5aa77bc6df0237aa974c19951d1210072754d1d
6
+ metadata.gz: 8779ec6d715fc7d00659a00c0090961b37c055815c69831379be633efb6f26ee6aa285a4eef4a72c37b26948f68385b573fd0b6b9e4b1ca635318abba6e142cb
7
+ data.tar.gz: d2606c9a071219009b30255e0dde9b84658662253f2efc6eaf15eaa5478227fb166a49578e978ffcaef4bae7b433cdff660575f1cc2104175d411e949f491f1f
data/lib/npm_ext/mkmf.rb CHANGED
@@ -42,15 +42,16 @@ module NpmExt
42
42
  end
43
43
 
44
44
  def create_rollup_config(dir)
45
- parse_package_json(dir).map do |package|
45
+ parse_package_json(dir).to_h do |package|
46
46
  hash = Digest::MD5.hexdigest(package.name.to_s)
47
- configs = "rollup.config.#{hash}.js"
48
- File.write(configs, "module.exports = #{JSON.generate(
47
+ config = "rollup.config.#{hash}.js"
48
+ output_js = "#{hash}.npm_ext.js"
49
+ File.write(config, "module.exports = #{JSON.generate(
49
50
  {
50
51
  # TODO: if no file provided get the input file from package.json
51
52
  input: "node_modules/#{package.name}/#{package.file_to_bundle}",
52
53
  output: {
53
- file: "#{hash}.npm_ext.so",
54
+ file: output_js,
54
55
  name: package.name,
55
56
  format: "iife",
56
57
  },
@@ -59,7 +60,10 @@ module NpmExt
59
60
  end,
60
61
  },
61
62
  )}")
62
- configs
63
+ [package.name, {
64
+ rollup_config: config,
65
+ output_js: output_js,
66
+ }]
63
67
  end
64
68
  end
65
69
 
@@ -70,10 +74,13 @@ module NpmExt
70
74
  \tcp #{dir}/package*.json ./ || :
71
75
  \tnpm ci
72
76
  \tnpm i #{ROLLUP_PACKAGES.join(" ")}
73
- #{configs.map { |x| "\tnpx rollup --config #{x}" }.join("\n")}
77
+ #{configs.map { |_, x| "\tnpx rollup --config #{x[:rollup_config]}" }.join("\n")}
78
+ \trm -rf npm_ext.so
79
+ \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")]))))'
74
80
  cleanup:
75
81
  \trm -rf node_modules
76
82
  \trm -rf rollup.config.*.js
83
+ \trm -rf *npm_ext.js
77
84
  MAKE
78
85
  end
79
86
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module NpmExt
4
- VERSION = "0.1.2"
4
+ VERSION = "0.1.3"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: npm_ext
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexandra Østermark