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