Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@embroider/core

Package Overview
Dependencies
Maintainers
4
Versions
486
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@embroider/core - npm Package Compare versions

Comparing version 0.8.0 to 0.9.0

9

package.json
{
"name": "@embroider/core",
"version": "0.8.0",
"version": "0.9.0",
"description": "A build system for EmberJS applications.",

@@ -20,3 +20,3 @@ "main": "src/index.js",

"@embroider/sample-transforms": "0.0.0",
"@embroider/test-support": "0.8.0",
"@embroider/test-support": "0.9.0",
"@types/babel__core": "^7.0.4",

@@ -45,3 +45,3 @@ "@types/debug": "^0.0.31",

"@babel/types": "^7.3.4",
"@embroider/macros": "0.8.0",
"@embroider/macros": "0.9.0",
"assert-never": "^1.1.0",

@@ -68,4 +68,5 @@ "babel-plugin-syntax-dynamic-import": "^6.18.0",

"typescript-memoize": "^1.0.0-alpha.3",
"walk-sync": "^1.1.3"
"walk-sync": "^1.1.3",
"wrap-legacy-hbs-plugin-if-needed": "^1.0.1"
}
}

@@ -572,3 +572,4 @@ "use strict";

appJSAsset(appFiles, prepared) {
let cached = prepared.get(`assets/${this.app.name}.js`);
let relativePath = `assets/${this.app.name}.js`;
let cached = prepared.get(relativePath);
if (cached) {

@@ -584,3 +585,2 @@ return cached;

}
let relativePath = `assets/${this.app.name}.js`;
let lazyRoutes = [];

@@ -604,3 +604,3 @@ for (let [routeName, routeFiles] of appFiles.routeFiles.children) {

// modules.
this.gatherImplicitModules('implicit-modules', amdModules);
this.gatherImplicitModules('implicit-modules', relativePath, amdModules);
let source = entryTemplate({

@@ -658,3 +658,3 @@ amdModules,

// test support modules.
this.gatherImplicitModules('implicit-test-modules', amdModules);
this.gatherImplicitModules('implicit-test-modules', myName, amdModules);
let source = entryTemplate({

@@ -671,3 +671,3 @@ amdModules,

}
gatherImplicitModules(section, lazyModules) {
gatherImplicitModules(section, relativeTo, lazyModules) {
for (let addon of this.adapter.allActiveAddons) {

@@ -685,3 +685,3 @@ let implicitModules = addon.meta[section];

runtime,
buildtime: paths_1.explicitRelative(path_1.join(this.root, 'assets'), path_1.join(addon.root, name)),
buildtime: paths_1.explicitRelative(path_1.dirname(path_1.join(this.root, relativeTo)), path_1.join(addon.root, name)),
});

@@ -688,0 +688,0 @@ }

@@ -18,3 +18,2 @@ import { Resolver, ResolvedDep } from './resolver';

export default class TemplateCompiler {
private userPluginsCount;
private portableParams;

@@ -36,2 +35,3 @@ private params;

private setup;
private getReversedASTPlugins;
precompile(moduleName: string, contents: string): {

@@ -38,0 +38,0 @@ compiled: string;

@@ -22,9 +22,29 @@ "use strict";

const typescript_memoize_1 = require("typescript-memoize");
// we could directly depend on @glimmer/syntax and have nice types and
// everything. But the problem is, we really want to use the exact version that
// the app itself is using, and its copy is bundled away inside
// ember-template-compiler.js.
function loadGlimmerSyntax(templateCompilerPath) {
let source = fs_1.readFileSync(templateCompilerPath, 'utf8');
const wrap_legacy_hbs_plugin_if_needed_1 = __importDefault(require("wrap-legacy-hbs-plugin-if-needed"));
const CACHE = new Map();
// Today the template compiler seems to not expose a public way to to source 2 source compilation of templates.
// because of this, we must resort to some hackery.
//
// TODO: expose a way to accomplish this via purely public API's.
// Today we use the following API's
// * glimmer/syntax's preprocess
// * glimmer/syntax's print
// * ember-template-compiler/lib/system/compile-options's defaultOptions
function getEmberExports(templateCompilerPath) {
let theExports;
let cacheKey;
let source;
let entry = CACHE.get(templateCompilerPath);
if (entry) {
let currentStat = fs_1.statSync(templateCompilerPath);
// Let's ensure the template is still what we cached
if (currentStat.mode === entry.stat.mode &&
currentStat.size === entry.stat.size &&
currentStat.mtime.getTime() === entry.stat.mtime.getTime()) {
return entry.value;
}
}
let replacedVar = false;
let stat = fs_1.statSync(templateCompilerPath);
source = fs_1.readFileSync(templateCompilerPath, 'utf8');
// here we are stripping off the first `var Ember;`. That one small change

@@ -54,5 +74,9 @@ // lets us crack open the file and get access to its internal loader, because

}
// cacheKey, theExports
cacheKey = crypto_1.createHash('md5')
.update(source)
.digest('hex');
// evades the require cache, which we need because the template compiler
// shares internal module scoped state.
let theExports = new Function(`
theExports = new Function(`
let module = { exports: {} };

@@ -64,2 +88,19 @@ let Ember = {};

`)();
entry = Object.freeze({
value: {
cacheKey,
theExports,
},
stat,
});
CACHE.set(templateCompilerPath, entry);
return entry.value;
}
// we could directly depend on @glimmer/syntax and have nice types and
// everything. But the problem is, we really want to use the exact version that
// the app itself is using, and its copy is bundled away inside
// ember-template-compiler.js.
function loadGlimmerSyntax(templateCompilerPath) {
let { theExports, cacheKey } = getEmberExports(templateCompilerPath);
// TODO: we should work to make this, or what it intends to accomplish, public API
let syntax = theExports.Ember.__loader.require('@glimmer/syntax');

@@ -74,5 +115,3 @@ let compilerOptions = theExports.Ember.__loader.require('ember-template-compiler/lib/system/compile-options');

_Ember: theExports._Ember,
cacheKey: crypto_1.createHash('md5')
.update(source)
.digest('hex'),
cacheKey,
};

@@ -109,3 +148,2 @@ }

constructor(params) {
this.userPluginsCount = 0;
// stage3 packagers don't need to know about our instance, they can just

@@ -168,10 +206,2 @@ // grab the compile function and use it.

let syntax = loadGlimmerSyntax(this.params.compilerPath);
this.userPluginsCount += registerPlugins(syntax, this.params.plugins);
if (this.params.resolver) {
let transform = this.params.resolver.astTransformer(this);
if (transform) {
syntax.registerPlugin('ast', transform);
this.userPluginsCount++;
}
}
initializeEmberENV(syntax, this.params.EmberENV);

@@ -186,2 +216,5 @@ let cacheKey = crypto_1.createHash('md5')

}
getReversedASTPlugins(ast) {
return ast.slice().reverse();
}
// Compiles to the wire format plus dependency list.

@@ -197,2 +230,10 @@ precompile(moduleName, contents) {

}
let opts = this.syntax.defaultOptions({ contents, moduleName });
if (this.params.resolver) {
let transform = this.params.resolver.astTransformer(this);
if (transform) {
this.params.plugins.ast.push(transform);
}
}
opts.plugins.ast = [...this.getReversedASTPlugins(this.params.plugins.ast), ...opts.plugins.ast];
let compiled = this.syntax.precompile(strip_bom_1.default(contents), {

@@ -202,2 +243,3 @@ contents,

filename: moduleName,
plugins: opts.plugins,
});

@@ -237,3 +279,7 @@ if (this.params.resolver) {

// normalization that it does on the user-provided plugins.
opts.plugins.ast = opts.plugins.ast.slice(0, this.userPluginsCount);
opts.plugins.ast = this.getReversedASTPlugins(this.params.plugins.ast).map(plugin => {
// Although the precompile API does, this direct glimmer syntax api
// does not support these legacy plugins, so we must wrap them.
return wrap_legacy_hbs_plugin_if_needed_1.default(plugin);
});
}

@@ -288,2 +334,5 @@ opts.filename = this.params.resolver

], TemplateCompiler.prototype, "setup", null);
__decorate([
typescript_memoize_1.Memoize()
], TemplateCompiler.prototype, "getReversedASTPlugins", null);
exports.default = TemplateCompiler;

@@ -324,12 +373,2 @@ class TemplateCompileTree extends broccoli_persistent_filter_1.default {

}
function registerPlugins(syntax, plugins) {
let userPluginsCount = 0;
if (plugins.ast) {
for (let i = 0, l = plugins.ast.length; i < l; i++) {
syntax.registerPlugin('ast', plugins.ast[i]);
userPluginsCount++;
}
}
return userPluginsCount;
}
function initializeEmberENV(syntax, EmberENV) {

@@ -336,0 +375,0 @@ if (!EmberENV) {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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