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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 27ffa525453e8eb743255eb79866ae2c5e0ee6399b04a24c538c4141810e9297
4
- data.tar.gz: d098315971c4c017236b4572804e63ac06172e5b2ebc0973e7e2aff11c14d5b7
3
+ metadata.gz: ab2466075be3e449081ba4700c280dcee8b9fbf92b2c6d32dac09955fc5ac0d6
4
+ data.tar.gz: 3c1f9db83bfb9f985c4cef0c8070c6e51953902a3c00c155c620f1e15e5d4780
5
5
  SHA512:
6
- metadata.gz: 19068b4ab14096926db6dcd50e258083a41b4f8ba58efeda55cdd1c98e1211dcc2997640674bad2bdbf73baf0cff6ce44cf01d7751ea4f8f1819c8a6c233928e
7
- data.tar.gz: 03a986f10cd2e5ea11ec4ca33fead5072bc250fae247d29cd6c979bec00b695f6a1ec2937d3c67426bf43ec9a27f41f2ab85b63ffc1d2eabec7aa94639ca0b94
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
- <<~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,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 { |_, x| "\tnpx rollup --config #{x[:rollup_config]}" }.join("\n")}
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module NpmExt
4
- VERSION = "0.1.4"
4
+ VERSION = "0.1.6"
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.4
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexandra Østermark