Skip to content

Commit

Permalink
Merge pull request #20 from sveltejs/gh-19
Browse files Browse the repository at this point in the history
reinstate test, resolve shared path
  • Loading branch information
Rich-Harris authored Mar 26, 2017
2 parents 68cd2ef + 7ea7c6f commit a51e80a
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ module.exports = function(source, map) {

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

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

Expand Down
25 changes: 24 additions & 1 deletion test/loader.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const loader = require('../');

describe('loader', function() {

function testLoader(fileName, callback, query) {
function testLoader(fileName, callback, query, version = 2) {

return function() {

Expand All @@ -29,6 +29,7 @@ describe('loader', function() {
cacheable: cacheableSpy,
callback: callbackSpy,
resourcePath: fileName,
version,
query,
}, fileContents, null);

Expand Down Expand Up @@ -164,6 +165,28 @@ describe('loader', function() {

});

describe('shared', function() {

it('should configure shared=false (default)',
testLoader('test/fixtures/good.html', function(err, code, map) {
expect(err).not.to.exist;

expect(code).not.to.contain('import {');
expect(code).not.to.contain('svelte/shared.js');
}, {}, 1)
);


it('should configure shared=true',
testLoader('test/fixtures/good.html', function(err, code, map) {
expect(err).not.to.exist;

expect(code).to.contain('import {');
expect(code).to.contain('svelte/shared.js');
}, { shared: true })
);

});

describe('generate', function() {

Expand Down

0 comments on commit a51e80a

Please sign in to comment.