Commit e47b5ec 1 parent c55a7be commit e47b5ec Copy full SHA for e47b5ec
File tree 8 files changed +113
-0
lines changed
8 files changed +113
-0
lines changed Original file line number Diff line number Diff line change
1
+ {
2
+ "plugins" : [
3
+ "@roundingwellos/babel-plugin-handlebars-inline-precompile"
4
+ // "istanbul"
5
+ ] ,
6
+ "presets" : [
7
+ [
8
+ "@babel/preset-env"
9
+ ]
10
+ ]
11
+ }
Original file line number Diff line number Diff line change
1
+ node_modules
2
+ dist
3
+ package-lock.json
Original file line number Diff line number Diff line change
1
+ {
2
+ "name" : " webpack-babel-test" ,
3
+ "version" : " 1.0.0" ,
4
+ "description" : " " ,
5
+ "main" : " index.js" ,
6
+ "keywords" : [],
7
+ "author" : " " ,
8
+ "license" : " ISC" ,
9
+ "dependencies" : {
10
+ "@babel/core" : " ^7.5.5" ,
11
+ "@babel/preset-env" : " ^7.5.5" ,
12
+ "@roundingwellos/babel-plugin-handlebars-inline-precompile" : " ^3.0.1" ,
13
+ "babel-loader" : " ^8.0.6" ,
14
+ "babel-plugin-istanbul" : " ^5.2.0" ,
15
+ "handlebars" : " file:../.." ,
16
+ "handlebars-loader" : " ^1.7.1" ,
17
+ "nyc" : " ^14.1.1" ,
18
+ "webpack" : " ^4.39.3" ,
19
+ "webpack-cli" : " ^3.3.7"
20
+ },
21
+ "scripts" : {
22
+ "build" : " webpack --config webpack.config.js"
23
+ }
24
+ }
Original file line number Diff line number Diff line change
1
+ import * as Handlebars from 'handlebars/runtime'
2
+ import hbs from 'handlebars-inline-precompile' ;
3
+ import { assertEquals } from "../../webpack-test/src/lib/assert" ;
4
+
5
+ Handlebars . registerHelper ( 'loud' , function ( text ) {
6
+ return text . toUpperCase ( ) ;
7
+ } ) ;
8
+
9
+ const template = hbs `{{loud name}}` ;
10
+ const output = template ( { name : 'yehuda' } )
11
+
12
+ assertEquals ( output , 'YEHUDA' )
Original file line number Diff line number Diff line change
1
+ export function assertEquals ( actual , expected ) {
2
+ if ( actual !== expected ) {
3
+ throw new Error ( `Expected "${ actual } " to equal "${ expected } "` ) ;
4
+ }
5
+ }
Original file line number Diff line number Diff line change
1
+ #! /bin/bash
2
+
3
+ set -e
4
+
5
+ # Cleanup: package-lock and "npm ci" is not working with local dependencies
6
+ rm dist package-lock.json -rf
7
+ npm install
8
+ npm run build
9
+
10
+ for i in dist/* -test.js ; do
11
+ echo " ----------------------"
12
+ echo " -- Running $i "
13
+ echo " ----------------------"
14
+ node " $i "
15
+ echo " Success"
16
+ done
Original file line number Diff line number Diff line change
1
+ const fs = require ( 'fs' ) ;
2
+
3
+ const testFiles = fs . readdirSync ( 'src' ) ;
4
+ const entryPoints = { } ;
5
+ testFiles
6
+ . filter ( file => file . match ( / - t e s t .j s $ / ) )
7
+ . forEach ( file => {
8
+ entryPoints [ file ] = `./src/${ file } ` ;
9
+ } ) ;
10
+
11
+ module . exports = {
12
+ entry : entryPoints ,
13
+ output : {
14
+ filename : '[name]' ,
15
+ path : __dirname + '/dist'
16
+ } ,
17
+ module : {
18
+ rules : [
19
+ {
20
+ test : / \. j s ? $ / ,
21
+ exclude : / n o d e _ m o d u l e s / ,
22
+ use : {
23
+ loader : 'babel-loader' ,
24
+ options : { cacheDirectory : false } ,
25
+ }
26
+ }
27
+ ]
28
+ } ,
29
+ optimization : {
30
+ minimize : false
31
+ }
32
+ } ;
Original file line number Diff line number Diff line change
1
+ import * as HandlebarsViaImport from 'handlebars' ;
2
+ const HandlebarsViaRequire = require ( 'handlebars' ) ;
3
+ import { assertEquals } from './lib/assert' ;
4
+
5
+ HandlebarsViaImport . registerHelper ( 'loud' , function ( text ) {
6
+ return text . toUpperCase ( ) ;
7
+ } ) ;
8
+
9
+ const template = HandlebarsViaRequire . compile ( 'Author: {{loud author}}' ) ;
10
+ assertEquals ( template ( { author : 'Yehuda' } ) , 'Author: YEHUDA' ) ;
You can’t perform that action at this time.
0 commit comments