Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[FEAT] Extract the Handlebars parser (#1713)
Extracts the parser to `@handlebars/parser`, where it can be shared
between different implementations. This means that e.g. Glimmer/Ember
will be able to iterate on new features without forcing Handlebars to
adopt them immediately, and vice versa. All implementors will be able to
absorb changes as it makes sense for them.
  • Loading branch information
Chris Garrett committed Feb 15, 2021
1 parent 071003b commit 19bdace
Show file tree
Hide file tree
Showing 34 changed files with 58 additions and 2,268 deletions.
1 change: 0 additions & 1 deletion .eslintignore
Expand Up @@ -12,7 +12,6 @@ node_modules
.nyc_output

# Generated files
lib/handlebars/compiler/parser.js
/coverage/
/dist/
/integration-testing/*/dist/
Expand Down
3 changes: 1 addition & 2 deletions .gitignore
Expand Up @@ -13,8 +13,7 @@ node_modules
.nyc_output

# Generated files
lib/handlebars/compiler/parser.js
/coverage/
/dist/
/integration-testing/*/dist/
/spec/tmp/*
/spec/tmp/*
1 change: 0 additions & 1 deletion .prettierignore
Expand Up @@ -12,7 +12,6 @@ node_modules
.nyc_output

# Generated files
lib/handlebars/compiler/parser.js
/coverage/
/dist/
/integration-testing/*/dist/
Expand Down
9 changes: 2 additions & 7 deletions Gruntfile.js
Expand Up @@ -3,12 +3,7 @@ module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),

clean: [
'tmp',
'dist',
'lib/handlebars/compiler/parser.js',
'integration-testing/**/node_modules'
],
clean: ['tmp', 'dist', 'integration-testing/**/node_modules'],

copy: {
dist: {
Expand Down Expand Up @@ -198,7 +193,7 @@ module.exports = function(grunt) {
this.registerTask(
'build',
'Builds a distributable version of the current project',
['parser', 'node', 'globals']
['node', 'globals']
);

this.registerTask('node', ['babel:cjs']);
Expand Down
13 changes: 7 additions & 6 deletions lib/handlebars.js
@@ -1,15 +1,16 @@
import {
parser as Parser,
parse,
parseWithoutProcessing,
Visitor
} from '@handlebars/parser';

import runtime from './handlebars.runtime';

// Compiler imports
import AST from './handlebars/compiler/ast';
import {
parser as Parser,
parse,
parseWithoutProcessing
} from './handlebars/compiler/base';
import { Compiler, compile, precompile } from './handlebars/compiler/compiler';
import JavaScriptCompiler from './handlebars/compiler/javascript-compiler';
import Visitor from './handlebars/compiler/visitor';

import noConflict from './handlebars/no-conflict';

Expand Down
2 changes: 1 addition & 1 deletion lib/handlebars.runtime.js
@@ -1,9 +1,9 @@
import { Exception } from '@handlebars/parser';
import * as base from './handlebars/base';

// Each of these augment the Handlebars object. No need to setup here.
// (This is done to easily share code between commonjs and browse envs)
import SafeString from './handlebars/safe-string';
import Exception from './handlebars/exception';
import * as Utils from './handlebars/utils';
import * as runtime from './handlebars/runtime';

Expand Down
2 changes: 1 addition & 1 deletion lib/handlebars/base.js
@@ -1,5 +1,5 @@
import { Exception } from '@handlebars/parser';
import { createFrame, extend, toString } from './utils';
import Exception from './exception';
import { registerDefaultHelpers } from './helpers';
import { registerDefaultDecorators } from './decorators';
import logger from './logger';
Expand Down
34 changes: 0 additions & 34 deletions lib/handlebars/compiler/base.js

This file was deleted.

2 changes: 1 addition & 1 deletion lib/handlebars/compiler/compiler.js
@@ -1,6 +1,6 @@
/* eslint-disable new-cap */

import Exception from '../exception';
import { Exception } from '@handlebars/parser';
import { isArray, indexOf, extend } from '../utils';
import AST from './ast';

Expand Down
219 changes: 0 additions & 219 deletions lib/handlebars/compiler/helpers.js

This file was deleted.

2 changes: 1 addition & 1 deletion lib/handlebars/compiler/javascript-compiler.js
@@ -1,5 +1,5 @@
import { Exception } from '@handlebars/parser';
import { COMPILER_REVISION, REVISION_CHANGES } from '../base';
import Exception from '../exception';
import { isArray } from '../utils';
import CodeGen from './code-gen';

Expand Down

0 comments on commit 19bdace

Please sign in to comment.