Skip to content

Commit 7ea7c6f

Browse files
committed
reinstate test, resolve shared path. closes #19
1 parent 68cd2ef commit 7ea7c6f

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed

index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ module.exports = function(source, map) {
2222

2323
options.filename = this.resourcePath;
2424
options.format = this.version === 1 ? options.format || 'cjs' : 'es';
25-
options.shared = options.format === 'es';
25+
options.shared = options.format === 'es' && require.resolve( 'svelte/shared.js' );
2626

2727
if (!options.name) options.name = capitalize(sanitize(options.filename));
2828

test/loader.spec.js

+24-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const loader = require('../');
1515

1616
describe('loader', function() {
1717

18-
function testLoader(fileName, callback, query) {
18+
function testLoader(fileName, callback, query, version = 2) {
1919

2020
return function() {
2121

@@ -29,6 +29,7 @@ describe('loader', function() {
2929
cacheable: cacheableSpy,
3030
callback: callbackSpy,
3131
resourcePath: fileName,
32+
version,
3233
query,
3334
}, fileContents, null);
3435

@@ -164,6 +165,28 @@ describe('loader', function() {
164165

165166
});
166167

168+
describe('shared', function() {
169+
170+
it('should configure shared=false (default)',
171+
testLoader('test/fixtures/good.html', function(err, code, map) {
172+
expect(err).not.to.exist;
173+
174+
expect(code).not.to.contain('import {');
175+
expect(code).not.to.contain('svelte/shared.js');
176+
}, {}, 1)
177+
);
178+
179+
180+
it('should configure shared=true',
181+
testLoader('test/fixtures/good.html', function(err, code, map) {
182+
expect(err).not.to.exist;
183+
184+
expect(code).to.contain('import {');
185+
expect(code).to.contain('svelte/shared.js');
186+
}, { shared: true })
187+
);
188+
189+
});
167190

168191
describe('generate', function() {
169192

0 commit comments

Comments
 (0)