npm_ext 0.1.3 → 0.1.5

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: 014df2845c93a8f9bb6d14c4d9b11d921af128104a0cdc52f492d639325d4a22
4
- data.tar.gz: 1397cb03abb4af017e079d6c4b8d1fdfbfe2062e1cfcffdcc2bcf20806701552
3
+ metadata.gz: 2776e0aa8dd1a39049d3e06d06b18f5c7aaeaaba30f1f3991496dde756a58768
4
+ data.tar.gz: 63eb746025e6b76ab01701ebbd363bcdcc11b229effa2f0cc6136d36ad5142a7
5
5
  SHA512:
6
- metadata.gz: 8779ec6d715fc7d00659a00c0090961b37c055815c69831379be633efb6f26ee6aa285a4eef4a72c37b26948f68385b573fd0b6b9e4b1ca635318abba6e142cb
7
- data.tar.gz: d2606c9a071219009b30255e0dde9b84658662253f2efc6eaf15eaa5478227fb166a49578e978ffcaef4bae7b433cdff660575f1cc2104175d411e949f491f1f
6
+ metadata.gz: cb328e0b5971c9c2f2b158845827291aa4d0d709559cc3a12f03d08939dc03b7ea81ff8d16d1fec2066b5a996dcd2cd5a1d3c88353d84336b9e58d2a5ebebdd9
7
+ data.tar.gz: f72156e791973455ee37f9c1c52825e4bee64be189099439157d27776f0eb70456b4aba2d8c2880420ad5da57d30a22f9377ed969630ff4c5bb95a2f576ba38b
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
- <<~JS
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
- File.write(config, "module.exports = #{JSON.generate(
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,14 +67,18 @@ module NpmExt
70
67
  def create_npm_makefile(dir)
71
68
  configs = create_rollup_config(dir)
72
69
  File.write("Makefile", <<~MAKE)
70
+ .PHONY: install
73
71
  install:
74
72
  \tcp #{dir}/package*.json ./ || :
75
73
  \tnpm ci
76
74
  \tnpm i #{ROLLUP_PACKAGES.join(" ")}
77
- #{configs.map { |_, x| "\tnpx rollup --config #{x[:rollup_config]}" }.join("\n")}
75
+ #{configs.map do |_, x|
76
+ "\techo '#{x[:rollup_config]}' > rollup.config.cjs && npx rollup --config && rm -rf rollup.config.cjs"
77
+ end.join("\n")}
78
78
  \trm -rf npm_ext.so
79
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:
80
+ .PHONY: clean
81
+ clean:
81
82
  \trm -rf node_modules
82
83
  \trm -rf rollup.config.*.js
83
84
  \trm -rf *npm_ext.js
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module NpmExt
4
- VERSION = "0.1.3"
4
+ VERSION = "0.1.5"
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.3
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexandra Østermark