Skip to content

Commit 03d387b

Browse files
committed
Fix rollup warning when importing Handlebars as ESM
Closes #1696
1 parent e0f50b4 commit 03d387b

File tree

8 files changed

+59
-1
lines changed

8 files changed

+59
-1
lines changed

.github/workflows/ci.yml

+1
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ jobs:
5656
# https://github.com/webpack/webpack/issues/14532
5757
if: ${{ matrix.node-version != '17' }}
5858
run: |
59+
cd ./tests/integration/rollup-test && ./test.sh && cd -
5960
cd ./tests/integration/webpack-babel-test && ./test.sh && cd -
6061
cd ./tests/integration/webpack-test && ./test.sh && cd -
6162

lib/handlebars/internal/proto-access.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { createNewLookupObject } from './create-new-lookup-object';
2-
import * as logger from '../logger';
2+
import logger from '../logger';
33

44
const loggedProperties = Object.create(null);
55

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
module.exports = {
2+
root: true,
3+
extends: ['eslint:recommended', 'prettier'],
4+
env: {
5+
browser: true
6+
},
7+
parserOptions: {
8+
sourceType: 'module',
9+
ecmaVersion: 6
10+
}
11+
};
+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
node_modules
2+
dist
3+
package-lock.json
+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"name": "rollup-test",
3+
"description": "Various tests with Handlebars and rollup",
4+
"version": "1.0.0",
5+
"scripts": {
6+
"build": "rollup --config rollup.config.js --failAfterWarnings"
7+
},
8+
"private": true,
9+
"devDependencies": {
10+
"@rollup/plugin-node-resolve": "^13.1.1",
11+
"handlebars": "file:../../..",
12+
"rollup": "^2.61.1"
13+
}
14+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { nodeResolve } from '@rollup/plugin-node-resolve';
2+
3+
export default {
4+
input: 'src/index.js',
5+
output: {
6+
file: 'dist/bundle.js',
7+
format: 'es'
8+
},
9+
plugins: [nodeResolve()]
10+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import Handlebars from 'handlebars/lib/handlebars';
2+
3+
const template = Handlebars.compile('Author: {{author}}');
4+
const result = template({ author: 'Yehuda' });
5+
6+
if (result !== 'Author: Yehuda') {
7+
throw Error('Assertion failed');
8+
}

tests/integration/rollup-test/test.sh

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
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+
node dist/bundle.js
11+
echo "Success"

0 commit comments

Comments
 (0)