Socket
Socket
Sign inDemoInstall

ember-cli-htmlbars

Package Overview
Dependencies
Maintainers
5
Versions
112
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ember-cli-htmlbars - npm Package Compare versions

Comparing version 5.6.5 to 5.7.0

13

CHANGELOG.md
# Changelog
## v5.7.0 (2021-03-18)
#### :rocket: Enhancement
* [#683](https://github.com/ember-cli/ember-cli-htmlbars/pull/683) Disable the modules API polyfill on Ember 3.27+ ([@pzuraq](https://github.com/pzuraq))
#### :house: Internal
* [#684](https://github.com/ember-cli/ember-cli-htmlbars/pull/684) Update babel-plugin-htmlbars-inline-precompile to 4.4.6. ([@rwjblue](https://github.com/rwjblue))
#### Committers: 2
- Chris Garrett ([@pzuraq](https://github.com/pzuraq))
- Robert Jackson ([@rwjblue](https://github.com/rwjblue))
## v5.6.5 (2021-03-12)

@@ -4,0 +17,0 @@

57

lib/colocated-babel-plugin.js

@@ -6,3 +6,7 @@ // For ease of debuggin / tweaking:

function makeSetComponentTemplateMemberExpression() {
function makeSetComponentTemplateExpression(state) {
if (!state.opts.requiresModuleApiPolyfill) {
return state._colocationEnsureImport('setComponentTemplate', '@ember/component');
}
return t.memberExpression(t.identifier('Ember'), t.identifier('_setComponentTemplate'));

@@ -19,2 +23,49 @@ }

visitor: {
Program(path, state) {
let allAddedImports = {};
state._colocationEnsureImport = (exportName, moduleName) => {
let addedImports = (allAddedImports[moduleName] = allAddedImports[moduleName] || {});
if (addedImports[exportName]) return t.identifier(addedImports[exportName].name);
let importDeclarations = path.get('body').filter((n) => n.type === 'ImportDeclaration');
let preexistingImportDeclaration = importDeclarations.find(
(n) => n.get('source').get('value').node === moduleName
);
if (preexistingImportDeclaration) {
let importSpecifier = preexistingImportDeclaration
.get('specifiers')
.find(({ node }) => {
return exportName === 'default'
? t.isImportDefaultSpecifier(node)
: node.imported && node.imported.name === exportName;
});
if (importSpecifier) {
addedImports[exportName] = importSpecifier.node.local;
}
}
if (!addedImports[exportName]) {
let uid = path.scope.generateUidIdentifier(
exportName === 'default' ? moduleName : exportName
);
addedImports[exportName] = uid;
let newImportSpecifier =
exportName === 'default'
? t.importDefaultSpecifier(uid)
: t.importSpecifier(uid, t.identifier(exportName));
let newImport = t.importDeclaration([newImportSpecifier], t.stringLiteral(moduleName));
path.unshiftContainer('body', newImport);
}
return t.identifier(addedImports[exportName].name);
};
},
VariableDeclarator(path, state) {

@@ -43,3 +94,3 @@ if (path.node.id.name === '__COLOCATED_TEMPLATE__') {

let defaultExportDeclaration = path.node.declaration;
let setComponentTemplateMemberExpression = makeSetComponentTemplateMemberExpression();
let setComponentTemplateMemberExpression = makeSetComponentTemplateExpression(state);
let colocatedTemplateIdentifier = makeColocatedTemplateIdentifier();

@@ -91,3 +142,3 @@

t.expressionStatement(
t.callExpression(makeSetComponentTemplateMemberExpression(), [
t.callExpression(makeSetComponentTemplateExpression(state), [
makeColocatedTemplateIdentifier(),

@@ -94,0 +145,0 @@ defaultSpecifier.local,

15

lib/ember-addon-main.js

@@ -6,2 +6,3 @@ 'use strict';

const utils = require('./utils');
const VersionChecker = require('ember-cli-version-checker');

@@ -66,3 +67,3 @@ let registryInvocationCounter = 0;

return new TemplateCompiler(inputTree, htmlbarsOptions);
return new TemplateCompiler(inputTree, htmlbarsOptions, this._requiresModuleApiPolyfill);
},

@@ -174,2 +175,5 @@

let checker = new VersionChecker(this.parent).for('ember-source', 'npm');
this._requiresModuleApiPolyfill = checker.exists() && checker.lt('3.27.0-alpha.1');
// This is an option intended to be used only be `ember-template-imports`.

@@ -196,3 +200,4 @@ // DO NOT USE THIS

isProduction,
customModules
customModules,
this._requiresModuleApiPolyfill
);

@@ -212,2 +217,3 @@

modules: customModules,
requiresModuleApiPolyfill: this._requiresModuleApiPolyfill,
});

@@ -220,3 +226,6 @@

if (this._shouldColocateTemplates() && !utils.isColocatedBabelPluginRegistered(babelPlugins)) {
babelPlugins.push(require.resolve('./colocated-babel-plugin'));
babelPlugins.push([
require.resolve('./colocated-babel-plugin'),
{ requiresModuleApiPolyfill: this._requiresModuleApiPolyfill },
]);
}

@@ -223,0 +232,0 @@ },

@@ -27,3 +27,3 @@ 'use strict';

class TemplateCompiler extends Filter {
constructor(inputTree, _options) {
constructor(inputTree, _options, requiresModuleApiPolyfill = true) {
let options = _options || {};

@@ -39,2 +39,3 @@

this.inputTree = inputTree;
this.requiresModuleApiPolyfill = requiresModuleApiPolyfill;

@@ -56,2 +57,3 @@ // TODO: do we need this?

let srcName = path.join(srcDir, relativePath);
try {

@@ -69,21 +71,19 @@ // we have to reverse these for reasons that are a bit bonkers. the initial

let result =
'export default ' +
utils.template(this.options.templateCompiler, stripBom(string), {
contents: string,
isProduction: this.options.isProduction,
moduleName: relativePath,
parseOptions: {
srcName: srcName,
},
let precompiled = this.options.templateCompiler.precompile(stripBom(string), {
contents: string,
isProduction: this.options.isProduction,
moduleName: relativePath,
parseOptions: {
srcName: srcName,
},
// intentionally not using `plugins: this.options.plugins` here
// because if we do, Ember will mutate the shared plugins object (adding
// all of the built in AST transforms into plugins.ast, which breaks
// persistent caching)
plugins: {
ast: astPlugins,
},
}) +
';';
// intentionally not using `plugins: this.options.plugins` here
// because if we do, Ember will mutate the shared plugins object (adding
// all of the built in AST transforms into plugins.ast, which breaks
// persistent caching)
plugins: {
ast: astPlugins,
},
});
if (this.options.dependencyInvalidation) {

@@ -98,3 +98,8 @@ let plugins = pluginsWithDependencies(this.options.plugins.ast);

}
return result;
if (this.requiresModuleApiPolyfill) {
return `export default Ember.HTMLBars.template(${precompiled});`;
} else {
return `import { createTemplateFactory } from '@ember/template-factory';\n\nexport default createTemplateFactory(${precompiled});`;
}
} catch (error) {

@@ -114,2 +119,4 @@ rethrowBuildError(error);

strippedOptions._requiresModuleApiPolyfill = this.requiresModuleApiPolyfill;
return strippedOptions;

@@ -116,0 +123,0 @@ }

@@ -53,5 +53,7 @@ 'use strict';

function isColocatedBabelPluginRegistered(plugins) {
return plugins.some(
(plugin) => typeof plugin === 'string' && plugin === require.resolve('./colocated-babel-plugin')
);
return plugins.some((plugin) => {
let path = Array.isArray(plugin) ? plugin[0] : plugin;
return typeof path === 'string' && path === require.resolve('./colocated-babel-plugin');
});
}

@@ -64,3 +66,4 @@

isProduction,
customModules
customModules,
requiresModuleApiPolyfill
) {

@@ -76,2 +79,3 @@ let parallelBabelInfo = {

modules: Object.assign({}, customModules, INLINE_PRECOMPILE_MODULES),
requiresModuleApiPolyfill,
},

@@ -205,8 +209,2 @@ };

function template(templateCompiler, string, options) {
let precompiled = templateCompiler.precompile(string, options);
return 'Ember.HTMLBars.template(' + precompiled + ')';
}
function setup(pluginInfo, options) {

@@ -237,15 +235,6 @@ let projectConfig = options.projectConfig || {};

},
..._options,
};
for (let option in _options) {
if (option === 'scope') {
// The template compiler expects this option to be named `locals`, but
// we want users to pass it in as `scope`. In the future, we should update
// the template compiler to accept scope as well and remove this.
options.locals = _options.scope;
} else {
options[option] = _options[option];
}
}
return templatePrecompile(template, options);

@@ -269,3 +258,3 @@ };

isProduction: options.isProduction,
ensureModuleApiPolyfill: true,
ensureModuleApiPolyfill: options.requiresModuleApiPolyfill,
modules: Object.assign({}, options.modules, INLINE_PRECOMPILE_MODULES),

@@ -364,3 +353,2 @@ },

initializeEmberENV,
template,
setup,

@@ -367,0 +355,0 @@ makeCacheKey,

{
"name": "ember-cli-htmlbars",
"version": "5.6.5",
"version": "5.7.0",
"description": "A library for adding htmlbars to ember CLI",

@@ -36,3 +36,3 @@ "keywords": [

"@ember/edition-utils": "^1.2.0",
"babel-plugin-htmlbars-inline-precompile": "^4.4.5",
"babel-plugin-htmlbars-inline-precompile": "^5.0.0",
"broccoli-debug": "^0.6.5",

@@ -43,2 +43,3 @@ "broccoli-persistent-filter": "^3.1.2",

"ember-cli-babel-plugin-helpers": "^1.1.1",
"ember-cli-version-checker": "^5.1.2",
"fs-tree-diff": "^2.0.1",

@@ -71,6 +72,5 @@ "hash-for-dep": "^1.5.1",

"ember-cli-app-version": "^4.0.0",
"ember-cli-babel": "^7.23.1",
"ember-cli-babel": "^7.25.0",
"ember-cli-dependency-checker": "^3.2.0",
"ember-cli-inject-live-reload": "^2.0.2",
"ember-cli-version-checker": "^5.1.1",
"ember-compatibility-helpers": "^1.2.2",

@@ -77,0 +77,0 @@ "ember-export-application-global": "^2.0.1",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc