babel-plugin-htmlbars-inline-precompile
Advanced tools
Comparing version 3.0.1 to 3.1.0
@@ -90,2 +90,18 @@ 'use strict'; | ||
it('avoids a build time error when passed `insertRuntimeErrors`', function() { | ||
precompile = () => { | ||
throw new Error('NOOOOOOOOOOOOOOOOOOOOOO'); | ||
}; | ||
let transformed = transform( | ||
`import hbs from 'htmlbars-inline-precompile';\nvar compiled = hbs('hello', { insertRuntimeErrors: true });` | ||
); | ||
expect(transformed).toMatchInlineSnapshot(` | ||
"var compiled = function () { | ||
throw new Error(\\"NOOOOOOOOOOOOOOOOOOOOOO\\"); | ||
}();" | ||
`); | ||
}); | ||
it('escapes any */ included in the template string', function() { | ||
@@ -92,0 +108,0 @@ let transformed = transform(stripIndent` |
@@ -0,1 +1,13 @@ | ||
## v3.1.0 (2020-05-06) | ||
#### :rocket: Enhancement | ||
* [#208](https://github.com/ember-cli/babel-plugin-htmlbars-inline-precompile/pull/208) Add ability to transfer compilation errors into runtime. ([@rwjblue](https://github.com/rwjblue)) | ||
#### :house: Internal | ||
* [#209](https://github.com/ember-cli/babel-plugin-htmlbars-inline-precompile/pull/209) Add Node 14 to CI. ([@rwjblue](https://github.com/rwjblue)) | ||
#### Committers: 2 | ||
- Robert Jackson ([@rwjblue](https://github.com/rwjblue)) | ||
- [@dependabot-preview[bot]](https://github.com/apps/dependabot-preview) | ||
## v3.0.1 (2019-12-11) | ||
@@ -2,0 +14,0 @@ |
17
index.js
@@ -6,2 +6,6 @@ 'use strict'; | ||
const runtimeErrorIIFE = babel.template( | ||
`(function() {\n throw new Error('ERROR_MESSAGE');\n})();` | ||
); | ||
function buildExpression(value) { | ||
@@ -92,3 +96,14 @@ switch (typeof value) { | ||
let precompileResult = precompile(template, options); | ||
let precompileResult; | ||
if (options.insertRuntimeErrors) { | ||
try { | ||
precompileResult = precompile(template, options); | ||
} catch (error) { | ||
return runtimeErrorIIFE({ ERROR_MESSAGE: error.message }); | ||
} | ||
} else { | ||
precompileResult = precompile(template, options); | ||
} | ||
let precompiled = JSON.parse(precompileResult); | ||
@@ -95,0 +110,0 @@ |
{ | ||
"name": "babel-plugin-htmlbars-inline-precompile", | ||
"version": "3.0.1", | ||
"version": "3.1.0", | ||
"description": "Babel plugin to replace tagged template strings with precompiled HTMLBars templates", | ||
@@ -18,11 +18,11 @@ "repository": "https://github.com/ember-cli/babel-plugin-htmlbars-inline-precompile", | ||
"devDependencies": { | ||
"@babel/core": "^7.7.5", | ||
"@babel/plugin-transform-modules-amd": "^7.7.5", | ||
"@babel/plugin-transform-template-literals": "^7.7.4", | ||
"@babel/core": "^7.9.6", | ||
"@babel/plugin-transform-modules-amd": "^7.9.6", | ||
"@babel/plugin-transform-template-literals": "^7.8.3", | ||
"common-tags": "^1.8.0", | ||
"ember-source": "^3.15.0", | ||
"eslint": "^6.7.2", | ||
"eslint-config-prettier": "^6.7.0", | ||
"eslint-plugin-node": "^10.0.0", | ||
"eslint-plugin-prettier": "^3.1.1", | ||
"ember-source": "^3.17.3", | ||
"eslint": "^6.8.0", | ||
"eslint-config-prettier": "^6.11.0", | ||
"eslint-plugin-node": "^11.1.0", | ||
"eslint-plugin-prettier": "^3.1.3", | ||
"jest": "^24.9.0", | ||
@@ -29,0 +29,0 @@ "prettier": "^1.19.1", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
38572
515