sprockets-commoner 0.6.0 → 0.6.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b5d2ada3e40387a555b4b1be5c0284eeb8b82078
4
- data.tar.gz: 00145faf36173d45a06d3fd4e8bd840b31a80c72
3
+ metadata.gz: b44e3e2485acd4eabd86a0f61663bc2efabd08d4
4
+ data.tar.gz: ab6bcbe414eda57988e9908eb2aeb8a5c82bc4fa
5
5
  SHA512:
6
- metadata.gz: 609da3bec1c0a44a191105feafbe84e29bea5d299651c391b58b2fa8b76c867afccb1e44e4c8b7fe41d596305a6d955515a72a545d544cf313e2ae17fdec4f36
7
- data.tar.gz: a46ce177fc4f3d19aa70c1bb872526da7251dc59866df310b2ccacd7064395f938c4cb1990c3a39407d66a926c96a0b752276ee8863918c5b13119300f22186a
6
+ metadata.gz: e513972c63f822bd3088135ff260d0f8433a35b66aafe078151d95f403567b5e804dd5cdf3e7f2289993aae405590fa26f07f9c2dbb3986ec0031ab13b44ad73
7
+ data.tar.gz: 460b3ae9a16c52436473a32b22dd874836963ad93701daaf6ea9592a72d94e731dd74109ab37a6da1b1fe6c35791d1c1786ae784437e1ee96758cb24e8e3142e
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ## v0.6.1
4
+
5
+ * Ensure a file's cache is busted if it depends on an environment variable.
6
+
3
7
  ## v0.6.0
4
8
 
5
9
  * Adds support for resolving files in other bundles to global variables.
@@ -203,13 +203,17 @@ module.exports = function (context) {
203
203
  if (file.metadata.targetsToProcess == null) {
204
204
  file.metadata.targetsToProcess = [];
205
205
  }
206
+ if (file.metadata.includedEnvironmentVariables == null) {
207
+ file.metadata.includedEnvironmentVariables = [];
208
+ }
206
209
  },
207
210
 
208
211
  visitor: {
209
- MemberExpression: function MemberExpression(path) {
212
+ MemberExpression: function MemberExpression(path, state) {
210
213
  if (path.get("object").matchesPattern("process.env")) {
211
214
  var key = path.toComputedKey();
212
215
  if (t.isStringLiteral(key)) {
216
+ state.file.metadata.includedEnvironmentVariables.push(key.value);
213
217
  path.replaceWith(t.valueToNode(process.env[key.value]));
214
218
  }
215
219
  }
@@ -13,6 +13,10 @@ module Sprockets
13
13
  register_bundle_metadata_reducer 'application/javascript', :commoner_required, Set.new, :+
14
14
  register_bundle_metadata_reducer 'application/javascript', :commoner_used_helpers, Set.new, :+
15
15
  register_bundle_processor 'application/javascript', ::Sprockets::Commoner::Bundle
16
+ register_dependency_resolver 'commoner-environment-variable' do |env, str|
17
+ _, variable = str.split(':', 2)
18
+ ENV[variable]
19
+ end
16
20
  end
17
21
 
18
22
  require 'sprockets/commoner/railtie' if defined?(Rails)
@@ -7,7 +7,7 @@ module Sprockets
7
7
 
8
8
  ExcludedFileError = Class.new(::StandardError)
9
9
 
10
- VERSION = '2'.freeze
10
+ VERSION = '3'.freeze
11
11
  BABELRC_FILE = '.babelrc'.freeze
12
12
  PACKAGE_JSON = 'package.json'.freeze
13
13
  JS_PACKAGE_PATH = File.expand_path('../../../js', __dir__)
@@ -100,6 +100,10 @@ module Sprockets
100
100
  @required.insert(insertion_index, asset)
101
101
  end
102
102
 
103
+ result['metadata']['includedEnvironmentVariables'].each do |env|
104
+ @dependencies << "commoner-environment-variable:#{env}"
105
+ end
106
+
103
107
  {
104
108
  data: result['code'],
105
109
  dependencies: @dependencies,
@@ -1,5 +1,5 @@
1
1
  module Sprockets
2
2
  module Commoner
3
- VERSION = '0.6.0'
3
+ VERSION = '0.6.1'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sprockets-commoner
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bouke van der Bijl
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-08-10 00:00:00.000000000 Z
11
+ date: 2016-08-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sprockets