Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integrate Glimmer Macros For Binary VM #14781

Merged
merged 3 commits into from
Jan 17, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
114 changes: 79 additions & 35 deletions ember-cli-build.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ function rsvp() {
function routeRecognizer() {
var packageJson = require('route-recognizer/package');
var packageDir = path.dirname(require.resolve('route-recognizer/package'));
var entry = path.join(packageDir, packageJson['module'] || packageJson['js:next'] || packageJson['main'].replace(/dist\//, 'dist/es6/'));
var entry = path.join(packageDir, packageJson['module'] || packageJson['jsnext:main'] || packageJson['main'].replace(/dist\//, 'dist/es6/'));
var basename = path.basename(entry);
var es6 = new Funnel(path.dirname(entry), {
files: [ basename ]
Expand All @@ -107,6 +107,46 @@ function routeRecognizer() {
});
}

function buildPackage(name, options) {
options = options ? options : {};
var packageJson = require(name + '/package');
var packageDir = path.dirname(require.resolve(name + '/package'));

if (options.entry && !options.srcDir) {
throw new Error('If resolving from a non-package.json entry point, you must supply the srcDirectory.');
}

var entryModule = packageJson['module'] || packageJson['jsnext:main'] || packageJson['main'].replace(/dist\//, 'dist/es6/');
var funnelDir = path.join(packageDir, options.entry ? options.srcDir : path.dirname(entryModule));
var sourceEntry = options.entry ? options.entry : path.basename(entryModule);

var es6 = new Funnel(funnelDir, {
include: ['**/*.js' ]
});
var moduleId = options.moduleId ? options.moduleId : name;
var destination = options.dest ? options.dest + '.js': moduleId + '.js';
var external = options.external ? options.external : [];
var plugins = options.plugins ? options.plugins : [];
var rolledUp = new Rollup(es6, {
rollup: {
external: external,
entry: sourceEntry,
dest: destination,
plugins: plugins,
format: 'es',
moduleId: moduleId,
exports: 'named'
},
annotation: destination
});

var transpileES6 = require('emberjs-build/lib/utils/transpile-es6');

return transpileES6(rolledUp, name, {
stripRuntimeChecks: true
});
}

function router() {
return new Rollup(path.resolve(path.dirname(require.resolve('router_js')), '../lib'), {
rollup: {
Expand Down Expand Up @@ -197,27 +237,6 @@ function babelConfigFor(environment) {
};
}

var glimmerEngine = require('glimmer-engine/ember-cli-build')({
shouldExternalizeHelpers: true,
stripRuntimeChecks: true
});

function glimmerPackage(name) {
return replace(new Funnel(glimmerEngine, {
include: [
'named-amd/' + name + '.js',
'named-amd/' + name + '/**/*.js'
]
}), {
files: ['**/*.js'],
pattern: {
match: /\/\/#\s+sourceMappingURL.*/g,
replacement: ''
},
annotation: 'strip sourceMappingURL'
});
}

function getVersion() {
var projectPath = process.cwd();
var info = getGitInfo(projectPath);
Expand Down Expand Up @@ -254,6 +273,21 @@ function qunit() {
});
}

function handlebarsFix() {
var HANDLEBARS_UTIL = /\/utils.js$/;
return {
load: function(id) {
if (HANDLEBARS_UTIL.test(id)) {
var code = fs.readFileSync(id, 'utf8');
return {
code: code.replace(/export var isFunction/, 'export { isFunction }'),
map: { mappings: null }
};
}
}
}
}

module.exports = function() {
var features = getFeatures();
var version = getVersion();
Expand All @@ -266,18 +300,28 @@ module.exports = function() {
'router': router(),
'dag-map': dag(),
'route-recognizer': routeRecognizer(),
'simple-html-tokenizer': htmlbarsPackage('simple-html-tokenizer', { libPath: 'node_modules/glimmer-engine/dist/es6' }),

'glimmer': glimmerPackage('glimmer'),
'glimmer-compiler': glimmerPackage('glimmer-compiler'),
'glimmer-reference': glimmerPackage('glimmer-reference'),
'glimmer-runtime': glimmerPackage('glimmer-runtime'),
'glimmer-node': glimmerPackage('glimmer-node'),
'glimmer-syntax': glimmerPackage('glimmer-syntax'),
'glimmer-test-helpers': glimmerPackage('glimmer-test-helpers'),
'glimmer-util': glimmerPackage('glimmer-util'),
'glimmer-wire-format': glimmerPackage('glimmer-wire-format'),
'handlebars': glimmerPackage('handlebars') // inlined parser
'simple-html-tokenizer': buildPackage('simple-html-tokenizer'),

'@glimmer/compiler': buildPackage('@glimmer/compiler', {
external: ['@glimmer/syntax', '@glimmer/wire-format', '@glimmer/util']
}),
'@glimmer/reference': buildPackage('@glimmer/reference', { external: ['@glimmer/util'] }),
'@glimmer/runtime': buildPackage('@glimmer/runtime', {
external: ['@glimmer/util',
'@glimmer/reference',
'@glimmer/wire-format',
'@glimmer/syntax']
}),
'@glimmer/node': buildPackage('@glimmer/node', { external: ['@glimmer/runtime'] }),
'@glimmer/syntax': buildPackage('@glimmer/syntax', { external: ['handlebars', 'simple-html-tokenizer'] }),
'@glimmer/test-helpers': buildPackage('@glimmer/test-helpers'),
'@glimmer/util': buildPackage('@glimmer/util', { external: [] }),
'@glimmer/wire-format': buildPackage('@glimmer/wire-format', { external: ['@glimmer/util'] }),
'handlebars': buildPackage('handlebars', {
srcDir: 'lib',
entry: 'handlebars/compiler/base.js',
plugins: [handlebarsFix()]
}) // inlined parser
};

// Replace _getBowerTree with one from npm
Expand Down Expand Up @@ -349,7 +393,7 @@ module.exports = function() {
development: getFeatures('development'),
production: getFeatures('production')
},
glimmer: require('glimmer-engine'),
glimmer: require('@glimmer/compiler'),
packages: getPackages(features),
vendoredPackages: vendorPackages,
version: version
Expand Down
23 changes: 11 additions & 12 deletions lib/packages.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ module.exports = function(features) {
templateCompilerVendor: [
'simple-html-tokenizer',
'backburner',
'glimmer-wire-format',
'glimmer-syntax',
'glimmer-util',
'glimmer-compiler',
'glimmer-reference',
'glimmer-runtime',
'@glimmer/wire-format',
'@glimmer/syntax',
'@glimmer/util',
'@glimmer/compiler',
'@glimmer/reference',
'@glimmer/runtime',
'handlebars'
]
},
Expand All @@ -37,12 +37,11 @@ module.exports = function(features) {
requirements: ['container', 'ember-metal', 'ember-routing' ],
hasTemplates: true,
vendorRequirements: [
'glimmer',
'glimmer-runtime',
'glimmer-reference',
'glimmer-util',
'glimmer-wire-format',
'glimmer-node'
'@glimmer/runtime',
'@glimmer/reference',
'@glimmer/util',
'@glimmer/wire-format',
'@glimmer/node'
],
testingVendorRequirements: []
}
Expand Down
11 changes: 9 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@
"test:testem": "testem -f testem.dist.json"
},
"dependencies": {
"@glimmer/compiler": "^0.21.1",
"@glimmer/node": "^0.21.1",
"@glimmer/reference": "^0.21.0",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should these all be the same version?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No I don't believe so. The way lerna publish works is that it looks if packages were effected in between the HEAD and the last tag if its not effected it will not publish a new version.

"@glimmer/runtime": "^0.21.1",
"@glimmer/util": "^0.21.0",
"broccoli-stew": "^1.2.0",
"ember-cli-get-component-path-option": "^1.0.0",
"ember-cli-normalize-entity-name": "^1.0.0",
Expand All @@ -35,12 +40,15 @@
"ember-cli-test-info": "^1.0.0",
"ember-cli-valid-component-name": "^1.0.0",
"ember-cli-version-checker": "^1.1.7",
"handlebars": "~3",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does ember have a handlebars dep? Seems like this should be in Glimmer and handled upon its publishing, or am I missing something?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@krisselden might want to chime in here. I don't remember why we did this.

"jquery": "^3.1.1",
"resolve": "^1.1.7",
"rsvp": "^3.3.3",
"simple-dom": "^0.3.0"
"simple-dom": "^0.3.0",
"simple-html-tokenizer": "^0.3.0"
},
"devDependencies": {
"@glimmer/test-helpers": "^0.21.1",
"aws-sdk": "~2.2.43",
"babel-plugin-feature-flags": "^0.2.3",
"babel-plugin-filter-imports": "~0.2.0",
Expand All @@ -64,7 +72,6 @@
"git-repo-info": "^1.1.4",
"git-repo-version": "^0.3.1",
"github": "^0.2.3",
"glimmer-engine": "^0.19.4",
"glob": "^5.0.13",
"html-differ": "^1.3.4",
"mocha": "^2.4.5",
Expand Down
4 changes: 2 additions & 2 deletions packages/ember-glimmer/lib/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ import {
deprecate
} from 'ember-metal';
import { UPDATE, RootReference } from './utils/references';
import { DirtyableTag } from 'glimmer-reference';
import { readDOMAttr } from 'glimmer-runtime';
import { DirtyableTag } from '@glimmer/reference';
import { readDOMAttr } from '@glimmer/runtime';

export const DIRTY_TAG = symbol('DIRTY_TAG');
export const ARGS = symbol('ARGS');
Expand Down
4 changes: 2 additions & 2 deletions packages/ember-glimmer/lib/dom.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export { DOMChanges, DOMTreeConstruction } from 'glimmer-runtime';
export { NodeDOMTreeConstruction } from 'glimmer-node';
export { DOMChanges, DOMTreeConstruction } from '@glimmer/runtime';
export { NodeDOMTreeConstruction } from '@glimmer/node';
Loading