diff --git a/.gitignore b/.gitignore index 42b64dde0..4c97eecd6 100644 --- a/.gitignore +++ b/.gitignore @@ -12,3 +12,4 @@ npm-debug.log sauce_connect.log* .idea yarn-error.log +/handlebars-release.tgz diff --git a/integration-testing/run-integration-tests.sh b/integration-testing/run-integration-tests.sh index 79bfa87a4..dd6e72764 100755 --- a/integration-testing/run-integration-tests.sh +++ b/integration-testing/run-integration-tests.sh @@ -1,6 +1,7 @@ #!/bin/bash cd "$( dirname "$( readlink -f "$0" )" )" || exit 1 + for i in */test.sh ; do ( echo "----------------------------------------" diff --git a/integration-testing/webpack-handlebars-loader-test-npm/.gitignore b/integration-testing/webpack-handlebars-loader-test-npm/.gitignore deleted file mode 100644 index e69de29bb..000000000 diff --git a/integration-testing/webpack-handlebars-loader-test-npm/package-lock.json b/integration-testing/webpack-handlebars-loader-test-npm/package-lock.json deleted file mode 100644 index f5074caf6..000000000 --- a/integration-testing/webpack-handlebars-loader-test-npm/package-lock.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "name": "webpack-handlebars-loader-test", - "version": "1.0.0", - "lockfileVersion": 1, - "requires": true, - "dependencies": { - "handlebars": { - "version": "file:../..", - "requires": { - "neo-async": "^2.6.0", - "optimist": "^0.6.1", - "source-map": "^0.6.1", - "uglify-js": "^3.1.4" - } - } - } -} diff --git a/integration-testing/webpack-handlebars-loader-test-npm/package.json b/integration-testing/webpack-handlebars-loader-test-npm/package.json deleted file mode 100644 index 7bc7d19d0..000000000 --- a/integration-testing/webpack-handlebars-loader-test-npm/package.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "name": "webpack-handlebars-loader-test", - "version": "1.0.0", - "description": "", - "main": "index.js", - "scripts": { - "test": "echo \"Error: no test specified\"" - }, - "keywords": [], - "author": "", - "license": "ISC", - "dependencies": { - "handlebars": "file:../.." - } -} diff --git a/integration-testing/webpack-handlebars-loader-test-npm/test.sh b/integration-testing/webpack-handlebars-loader-test-npm/test.sh deleted file mode 100755 index 828e8a6da..000000000 --- a/integration-testing/webpack-handlebars-loader-test-npm/test.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash - -npm install -npm test - diff --git a/integration-testing/webpack-test/.gitignore b/integration-testing/webpack-test/.gitignore new file mode 100644 index 000000000..3a8ec2b3f --- /dev/null +++ b/integration-testing/webpack-test/.gitignore @@ -0,0 +1,3 @@ +node_modules +dist +package-lock.json \ No newline at end of file diff --git a/integration-testing/webpack-test/package.json b/integration-testing/webpack-test/package.json new file mode 100644 index 000000000..bb5757f48 --- /dev/null +++ b/integration-testing/webpack-test/package.json @@ -0,0 +1,21 @@ +{ + "name": "webpack-test", + "version": "1.0.0", + "main": "index.js", + "scripts": { + "build": "webpack --config webpack.config.js", + "test": "node dist/main.js" + }, + "private": true, + "keywords": [], + "author": "", + "license": "ISC", + "dependencies": {}, + "devDependencies": { + "handlebars": "file:../..", + "handlebars-loader": "^1.7.1", + "webpack": "^4.39.3", + "webpack-cli": "^3.3.7" + }, + "description": "" +} diff --git a/integration-testing/webpack-test/src/handlebars-default-import-pre-4.2-test.js b/integration-testing/webpack-test/src/handlebars-default-import-pre-4.2-test.js new file mode 100644 index 000000000..6bc630da3 --- /dev/null +++ b/integration-testing/webpack-test/src/handlebars-default-import-pre-4.2-test.js @@ -0,0 +1,6 @@ +import Handlebars from 'handlebars/dist/handlebars'; + +import {assertEquals} from './lib/assert'; + +const template = Handlebars.compile('Author: {{author}}'); +assertEquals(template({author: 'Yehuda'}), 'Author: Yehuda'); diff --git a/integration-testing/webpack-test/src/handlebars-default-import-test.js b/integration-testing/webpack-test/src/handlebars-default-import-test.js new file mode 100644 index 000000000..97fc3f8b7 --- /dev/null +++ b/integration-testing/webpack-test/src/handlebars-default-import-test.js @@ -0,0 +1,6 @@ +import Handlebars from 'handlebars'; +import {assertEquals} from './lib/assert'; + + +const template = Handlebars.compile('Author: {{author}}'); +assertEquals(template({author: 'Yehuda'}), 'Author: Yehuda'); diff --git a/integration-testing/webpack-test/src/handlebars-loader-test.js b/integration-testing/webpack-test/src/handlebars-loader-test.js new file mode 100644 index 000000000..4727c7a3a --- /dev/null +++ b/integration-testing/webpack-test/src/handlebars-loader-test.js @@ -0,0 +1,8 @@ +import {assertEquals} from './lib/assert'; + +import testTemplate from './test-template.handlebars'; +assertEquals(testTemplate({author: 'Yehuda'}).trim(), 'Author: Yehuda'); + + +const testTemplateRequire = require('./test-template.handlebars'); +assertEquals(testTemplateRequire({author: 'Yehuda'}).trim(), 'Author: Yehuda'); diff --git a/integration-testing/webpack-test/src/handlebars-wildcard-import-pre-4.2-test.js b/integration-testing/webpack-test/src/handlebars-wildcard-import-pre-4.2-test.js new file mode 100644 index 000000000..3731c5ac8 --- /dev/null +++ b/integration-testing/webpack-test/src/handlebars-wildcard-import-pre-4.2-test.js @@ -0,0 +1,6 @@ +import * as Handlebars from 'handlebars/dist/handlebars'; + +import {assertEquals} from './lib/assert'; + +const template = Handlebars.compile('Author: {{author}}'); +assertEquals(template({author: 'Yehuda'}), 'Author: Yehuda'); diff --git a/integration-testing/webpack-test/src/handlebars-wildcard-import-test.js b/integration-testing/webpack-test/src/handlebars-wildcard-import-test.js new file mode 100644 index 000000000..2ea0c1b49 --- /dev/null +++ b/integration-testing/webpack-test/src/handlebars-wildcard-import-test.js @@ -0,0 +1,5 @@ +import * as Handlebars from 'handlebars'; +import {assertEquals} from './lib/assert'; + +const template = Handlebars.compile('Author: {{author}}'); +assertEquals(template({author: 'Yehuda'}), 'Author: Yehuda'); diff --git a/integration-testing/webpack-test/src/lib/assert.js b/integration-testing/webpack-test/src/lib/assert.js new file mode 100644 index 000000000..9f33188db --- /dev/null +++ b/integration-testing/webpack-test/src/lib/assert.js @@ -0,0 +1,5 @@ +export function assertEquals(actual, expected) { + if (actual !== expected) { + throw new Error(`Expected "${actual}" to equal "${expected}"`); + } +} diff --git a/integration-testing/webpack-test/src/test-template.handlebars b/integration-testing/webpack-test/src/test-template.handlebars new file mode 100644 index 000000000..788f9c05d --- /dev/null +++ b/integration-testing/webpack-test/src/test-template.handlebars @@ -0,0 +1,2 @@ +Author: {{author}} + diff --git a/integration-testing/webpack-test/test.sh b/integration-testing/webpack-test/test.sh new file mode 100755 index 000000000..a45d5625f --- /dev/null +++ b/integration-testing/webpack-test/test.sh @@ -0,0 +1,16 @@ +#!/bin/bash + +set -e + +# Cleanup: package-lock and "npm ci" is not working with local dependencies +rm dist package-lock.json -rf +npm install +npm run build + +for i in dist/*-test.js ; do + echo "----------------------" + echo "-- Running $i" + echo "----------------------" + node "$i" + echo "Success" +done \ No newline at end of file diff --git a/integration-testing/webpack-test/webpack.config.js b/integration-testing/webpack-test/webpack.config.js new file mode 100644 index 000000000..957321223 --- /dev/null +++ b/integration-testing/webpack-test/webpack.config.js @@ -0,0 +1,22 @@ +const fs = require('fs'); + +const testFiles = fs.readdirSync('src'); +const entryPoints = {}; +testFiles + .filter(file => file.match(/-test.js$/)) + .forEach(file => { + entryPoints[file] = `./src/${file}`; + }); + +module.exports = { + entry: entryPoints, + output: { + filename: '[name]', + path: __dirname + '/dist' + }, + module: { + rules: [ + {test: /\.handlebars$/, loader: 'handlebars-loader'} + ] + } +}; diff --git a/package-lock.json b/package-lock.json index bb74117ea..bf7c18267 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "handlebars", - "version": "4.1.1", + "version": "4.1.2-0", "lockfileVersion": 1, "requires": true, "dependencies": {