sprockets-commoner 0.2.0 → 0.2.1

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
  SHA1:
3
- metadata.gz: 8a5ceb584e1eacf7990a65e0dfb94534f9d2fdd2
4
- data.tar.gz: 4ba4cc82f4df684af207003516778fa80ee9fd81
3
+ metadata.gz: ee42f65a12ad9e9a4b5dedb998af38e8fcdd2f4d
4
+ data.tar.gz: 020f3d0f782c8a1fcc6afd382a5162e667328e32
5
5
  SHA512:
6
- metadata.gz: 424bfe23119eef889e07d452835e7bae3ca03f96017e4be8614792aaedf6b2172a93abdb577263953641fba60a95d0641fdddae9a1eef67bf29ee77a1871723d
7
- data.tar.gz: f094b1ba53d8da39d3fd06272960a5af01d8e366dc67abb6e740b8466b6990b184537b7a27d72b79e9ac096357a6687ad3d7ec99f901d6d42f88c4b381f58866
6
+ metadata.gz: 180123fc5d46f1bb21f9a60938e42fb8fd2d2662087e5473a53a6c13f276068825d4a2c8c34f05e5b4247f2f3844801e91afaab020b85df9afb328d957930f06
7
+ data.tar.gz: 2c3938f74a7664b7c1b78aedeb76036b960ed3eb82650af95b9183a943e7a1fd2d5c29ec86787a337291bc70fbbdee265c932dc7fa41e9203ceeff02b16b0688
data/CHANGELOG.md CHANGED
@@ -1,9 +1,14 @@
1
1
  # Changelog
2
2
 
3
+ ## v0.2.1
4
+
5
+ * Fix bug with `browser` field stubbing out modules.
6
+ * Add support for requiring CoffeeScript files that don't define any globals.
7
+
3
8
  ## v0.2.0
4
9
 
5
- Add support for requiring JSON files.
10
+ * Add support for requiring JSON files.
6
11
 
7
12
  ## v0.1.0
8
13
 
9
- Initial version.
14
+ * Initial version.
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Shopify Inc.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -25,7 +25,9 @@ if (typeof Object.assign != 'function') {
25
25
 
26
26
  var fs = require('fs');
27
27
  var dirname = require('path').dirname;
28
+ var join = require('path').join;
28
29
  var resolve = require('browser-resolve').sync;
30
+ var emptyModule = join(__dirname, 'node_modules', 'browser-resolve', 'empty.js');
29
31
 
30
32
  module.exports = function (context) {
31
33
  var t = context.types;
@@ -63,7 +65,7 @@ module.exports = function (context) {
63
65
  }
64
66
 
65
67
  if (identifiers.length === 0) {
66
- throw new Error('No identifiers found in ' + path);
68
+ return false;
67
69
  } else if (identifiers.length > 1) {
68
70
  throw new Error('Multiple identifiers found in ' + path);
69
71
  }
@@ -120,6 +122,10 @@ module.exports = function (context) {
120
122
  return name;
121
123
  } else {
122
124
  var resolvedPath = resolve(path, opts);
125
+ if (resolvedPath === emptyModule) {
126
+ return false;
127
+ }
128
+
123
129
  file.metadata.required.push(resolvedPath);
124
130
 
125
131
  // Check if the path is under sourceRoot
@@ -155,6 +161,10 @@ module.exports = function (context) {
155
161
  }
156
162
 
157
163
  var name = resolveTarget(state.file, target);
164
+ if (name === false) {
165
+ path.get('init').replaceWith(t.objectExpression([]));
166
+ return;
167
+ }
158
168
  path.scope.rename(name);
159
169
  path.scope.rename(path.node.id.name, name);
160
170
  path.remove();
@@ -171,14 +181,18 @@ module.exports = function (context) {
171
181
 
172
182
  var replacement = resolveTarget(state.file, target);
173
183
  switch (path.parent.type) {
174
- case "ExpressionStatement":
175
- // We just need to know there's a dependency, we can remove it then
176
- path.remove();
177
- break;
178
- default:
179
- // Otherwise we just look for the module by referencing its Special Identifier™
184
+ case "ExpressionStatement":
185
+ // We just need to know there's a dependency, we can remove it then
186
+ path.remove();
187
+ break;
188
+ default:
189
+ // Otherwise we just look for the module by referencing its Special Identifier™
190
+ if (replacement === false) {
191
+ path.replaceWith(t.objectExpression([]));
192
+ } else {
180
193
  path.replaceWith(t.identifier(replacement));
181
- break;
194
+ }
195
+ break;
182
196
  }
183
197
  }
184
198
  };
@@ -1,5 +1,5 @@
1
1
  module Sprockets
2
2
  module Commoner
3
- VERSION = '0.2.0'
3
+ VERSION = '0.2.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.2.0
4
+ version: 0.2.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-05-04 00:00:00.000000000 Z
11
+ date: 2016-05-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sprockets
@@ -127,6 +127,7 @@ files:
127
127
  - CHANGELOG.md
128
128
  - CODE_OF_CONDUCT.md
129
129
  - Gemfile
130
+ - LICENSE.txt
130
131
  - README.md
131
132
  - Rakefile
132
133
  - circle.yml