From cf7aa3c8d0a6f80bea4a24bc34c632078917c274 Mon Sep 17 00:00:00 2001 From: Efthymis Sarmpanis Date: Tue, 12 Dec 2017 23:07:52 +0100 Subject: [PATCH 1/8] Ignore intellij's system files --- .gitignore | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 40b878db..e47ca26d 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,3 @@ -node_modules/ \ No newline at end of file +node_modules/ +.idea/ +*.iml \ No newline at end of file From 64affb87cf560c18da56eb1d8c25b21e210f6ea3 Mon Sep 17 00:00:00 2001 From: Efthymis Sarmpanis Date: Tue, 12 Dec 2017 23:08:07 +0100 Subject: [PATCH 2/8] Update sevelte version dependency --- package-lock.json | 26 +++++++++++++------------- package.json | 4 ++-- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/package-lock.json b/package-lock.json index 0773a9bf..4532cd73 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "svelte-loader", - "version": "2.1.0", + "version": "2.2.1", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -1277,6 +1277,15 @@ "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=", "dev": true }, + "string_decoder": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.3.tgz", + "integrity": "sha512-4AH6Z5fzNNBcH+6XDMfA/BTt87skxqJlO0lAh3Dker5zThcAxG6mKz+iGu308UKoPPQ8Dcqx/4JhujzltRa+hQ==", + "dev": true, + "requires": { + "safe-buffer": "5.1.1" + } + }, "string-width": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz", @@ -1288,15 +1297,6 @@ "strip-ansi": "3.0.1" } }, - "string_decoder": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.3.tgz", - "integrity": "sha512-4AH6Z5fzNNBcH+6XDMfA/BTt87skxqJlO0lAh3Dker5zThcAxG6mKz+iGu308UKoPPQ8Dcqx/4JhujzltRa+hQ==", - "dev": true, - "requires": { - "safe-buffer": "5.1.1" - } - }, "strip-ansi": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", @@ -1325,9 +1325,9 @@ "dev": true }, "svelte": { - "version": "1.28.1", - "resolved": "https://registry.npmjs.org/svelte/-/svelte-1.28.1.tgz", - "integrity": "sha512-/RloCDdGKA9yUXpfQ6ebQuj3syS0wbDJJrGCxxD8HdpEOASAvq+pF7ByttV+wwOkcH59tafChlLWgzqVUUpUcA==", + "version": "1.47.2", + "resolved": "https://registry.npmjs.org/svelte/-/svelte-1.47.2.tgz", + "integrity": "sha512-yOoN1J618NB4NYuGKMh+SAt60dL8jZl2ug5rloCdHPfKfhs4Qmctt+U9CjK4NDtdaEk9maSsRCd7oEWbkUomIw==", "dev": true }, "table": { diff --git a/package.json b/package.json index 4577818f..30686107 100644 --- a/package.json +++ b/package.json @@ -25,10 +25,10 @@ "mocha": "^3.2.0", "sinon": "^1.17.6", "sinon-chai": "^2.8.0", - "svelte": "^1.6.0" + "svelte": "^1.47.2" }, "peerDependencies": { - "svelte": "^1.0.7" + "svelte": "^1.44.0" }, "repository": { "type": "git", From 8efb967795d37a3acc30fedaec6c26ab65387a44 Mon Sep 17 00:00:00 2001 From: Efthymis Sarmpanis Date: Wed, 13 Dec 2017 07:09:37 +0100 Subject: [PATCH 3/8] Fix test cases --- index.js | 2 +- test/loader.spec.js | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/index.js b/index.js index 85823ce4..078da7ec 100644 --- a/index.js +++ b/index.js @@ -48,6 +48,6 @@ module.exports = function(source, map) { } catch (err) { // wrap error to provide correct // context when logging to console - this.callback(new Error(err.toString() + '\n' + err.frame)); + this.callback(new Error(`${err.name}: ${err.toString()}`)); } }; diff --git a/test/loader.spec.js b/test/loader.spec.js index 495955e1..92347de6 100644 --- a/test/loader.spec.js +++ b/test/loader.spec.js @@ -57,7 +57,7 @@ describe('loader', () => { expect(err).to.exist; expect(err.message).to.eql(d` - ParseError: Expected }}} + ParseError: Expected }}} (1:18) 1:

Count: {{{count}}

^ 2: ` @@ -79,7 +79,7 @@ describe('loader', () => { expect(err).to.exist; expect(err.message).to.eql(d` - ParseError: Unexpected token + ParseError: Unexpected token (5:7) 3: ` - ); + ); - expect(code).not.to.exist; - expect(map).not.to.exist; - }) + expect(code).not.to.exist; + expect(map).not.to.exist; + }) ); it( - 'should validation error', - testLoader('test/fixtures/validation-error.html', function( - err, - code, - map, - context - ) { - expect(err).to.exist; - - expect(err.message).to.eql(d` + 'should validation error', + testLoader('test/fixtures/validation-error.html', function( + err, + code, + map, + context) { + expect(err).to.exist; + + expect(err.message).to.eql(d` ValidationError: Computed properties can be function expressions or arrow function expressions (6:11) 4: export default { 5: computed: { @@ -119,146 +117,151 @@ describe('loader', () => { ^ 7: } 8: };` - ); + ); - expect(code).not.to.exist; - expect(map).not.to.exist; - }) + expect(code).not.to.exist; + expect(map).not.to.exist; + }) ); }); describe('ES2015 features', () => { it( - 'should keep imports / methods', - testLoader('test/fixtures/es2015.html', function(err, code, map) { - expect(err).not.to.exist; + 'should keep imports / methods', + testLoader('test/fixtures/es2015.html', function(err, code, map) { + expect(err).not.to.exist; - expect(code).to.exist; - expect(map).to.exist; + expect(code).to.exist; + expect(map).to.exist; - // es2015 statements remain - expect(code).to.contain(`import { hello } from './utils';`); - expect(code).to.contain('data() {'); - }) + // es2015 statements remain + expect(code).to.contain(`import { hello } from './utils';`); + expect(code).to.contain('data() {'); + }) ); it( - 'should keep nested Component import', - testLoader('test/fixtures/parent.html', function(err, code, map) { - expect(err).not.to.exist; + 'should keep nested Component import', + testLoader('test/fixtures/parent.html', function(err, code, map) { + expect(err).not.to.exist; - // es2015 statements remain - expect(code).to.contain(`import Nested from './nested';`); + // es2015 statements remain + expect(code).to.contain(`import Nested from './nested';`); - expect(code).to.exist; - expect(map).to.exist; - }) + expect(code).to.exist; + expect(map).to.exist; + }) ); }); describe('configuration via query', () => { describe('css', () => { it( - 'should configure css (default)', - testLoader('test/fixtures/css.html', function(err, code, map) { - expect(err).not.to.exist; - expect(code).to.contain('function add_css()'); - }) + 'should configure css (default)', + testLoader('test/fixtures/css.html', function(err, code, map) { + expect(err).not.to.exist; + expect(code).to.contain('function add_css()'); + }) ); it( - 'should configure no css', - testLoader( - 'test/fixtures/css.html', - function(err, code, map) { - expect(err).not.to.exist; - expect(code).not.to.contain('function add_css()'); - }, - { css: false } - ) + 'should configure no css', + testLoader( + 'test/fixtures/css.html', + function(err, code, map) { + expect(err).not.to.exist; + expect(code).not.to.contain('function add_css()'); + }, + { css: false } + ) ); }); describe('shared', () => { 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 - ) + '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 } - ) + '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', () => { it( - 'should configure generate=undefined (default)', - testLoader('test/fixtures/good.html', function(err, code, map) { - expect(err).not.to.exist; + 'should configure generate=undefined (default)', + testLoader('test/fixtures/good.html', function(err, code, map) { + expect(err).not.to.exist; - expect(code).not.to.contain('.render = function(state, options = {}) {'); - }) + expect(code). + not. + to. + contain('.render = function(state, options = {}) {'); + }) ); it( - 'should configure generate=ssr', - testLoader( - 'test/fixtures/good.html', - function(err, code, map) { - expect(err).not.to.exist; - - expect(code).to.contain('.render = function(state, options = {}) {'); - }, - { generate: 'ssr' } - ) + 'should configure generate=ssr', + testLoader( + 'test/fixtures/good.html', + function(err, code, map) { + expect(err).not.to.exist; + + expect(code). + to. + contain('.render = function(state, options = {}) {'); + }, + { generate: 'ssr' } + ) ); }); describe('emitCss', function() { it( - 'should configure emitCss=false (default)', - testLoader( - 'test/fixtures/css.html', - function(err, code, map) { - expect(err).not.to.exist; - - expect(code).not.to.match(/require\('.+\.css'\);/); - }, - {} - ) + 'should configure emitCss=false (default)', + testLoader( + 'test/fixtures/css.html', + function(err, code, map) { + expect(err).not.to.exist; + + expect(code).not.to.match(/require\('.+\.css'\);/); + }, + {} + ) ); it( - 'should configure emitCss=true', - testLoader( - 'test/fixtures/css.html', - function(err, code, map) { - expect(err).not.to.exist; - - expect(code).to.match(/require\('.+\.css'\);/); - }, - { emitCss: true } - ) + 'should configure emitCss=true', + testLoader( + 'test/fixtures/css.html', + function(err, code, map) { + expect(err).not.to.exist; + + expect(code).to.match(/require\('.+\.css'\);/); + }, + { emitCss: true } + ) ); }); @@ -283,7 +286,7 @@ describe('loader', () => { } const fileContents = readFileSync('test/fixtures/style-valid.html', - 'utf-8'); + 'utf-8'); const cacheableSpy = spy(() => { }); const callbackSpy = spy(cb); @@ -302,15 +305,16 @@ describe('loader', () => { resourcePath: 'test/fixtures/style-valid.html', options, }, - fileContents, - null - ); + fileContents, + null + ); expect(cacheableSpy).to.have.been.called; }); it('should not preprocess successfully', () => { - const fileContents = readFileSync('test/fixtures/style-valid.html', 'utf-8'); + const fileContents = readFileSync('test/fixtures/style-valid.html', + 'utf-8'); const cacheableSpy = spy(() => { }); const options = { @@ -328,9 +332,9 @@ describe('loader', () => { resourcePath: 'test/fixtures/style-valid.html', options, }, - fileContents, - null - ); + fileContents, + null + ); }); }); From 23a0014155a58e0bed07aa5eb1b62ce06bf405b1 Mon Sep 17 00:00:00 2001 From: esarbanis Date: Thu, 14 Dec 2017 11:37:25 +0200 Subject: [PATCH 7/8] Make loader compatible with node 8.0.0 --- index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 4d5594b6..4406b8c9 100644 --- a/index.js +++ b/index.js @@ -41,8 +41,8 @@ module.exports = function(source, map) { code = code + `\nrequire('${tmpobj.name}');\n`; writeFileSync(tmpobj.name, css); - const stats = statSync(tmpobj.name); - utimesSync(tmpobj.name, stats.atimeMs - 9999, stats.mtimeMs - 9999); + const { atime, mtime } = statSync(tmpobj.name); + utimesSync(tmpobj.name, atime.getTime() - 9999, mtime.getTime() - 9999); } callback(null, code, map); From 8b777f6cf3b3c2edaba5dea4bd3acd0a565c7dfa Mon Sep 17 00:00:00 2001 From: esarbanis Date: Thu, 14 Dec 2017 12:46:41 +0200 Subject: [PATCH 8/8] Extend node compatibility coverage in travis --- .travis.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 65b38240..78a54b8f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,8 @@ language: node_js -node_js: '8.0' +node_js: +- '9' +- '8' +- '6' script: - npm run all \ No newline at end of file