Skip to content

Commit

Permalink
Fix rollup warning when importing Handlebars as ESM
Browse files Browse the repository at this point in the history
Closes #1696
  • Loading branch information
jaylinski committed Dec 29, 2021
1 parent e0f50b4 commit 03d387b
Show file tree
Hide file tree
Showing 8 changed files with 59 additions and 1 deletion.
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ jobs:
# https://github.com/webpack/webpack/issues/14532
if: ${{ matrix.node-version != '17' }}
run: |
cd ./tests/integration/rollup-test && ./test.sh && cd -
cd ./tests/integration/webpack-babel-test && ./test.sh && cd -
cd ./tests/integration/webpack-test && ./test.sh && cd -
Expand Down
2 changes: 1 addition & 1 deletion lib/handlebars/internal/proto-access.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { createNewLookupObject } from './create-new-lookup-object';
import * as logger from '../logger';
import logger from '../logger';

const loggedProperties = Object.create(null);

Expand Down
11 changes: 11 additions & 0 deletions tests/integration/rollup-test/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module.exports = {
root: true,
extends: ['eslint:recommended', 'prettier'],
env: {
browser: true
},
parserOptions: {
sourceType: 'module',
ecmaVersion: 6
}
};
3 changes: 3 additions & 0 deletions tests/integration/rollup-test/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules
dist
package-lock.json
14 changes: 14 additions & 0 deletions tests/integration/rollup-test/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"name": "rollup-test",
"description": "Various tests with Handlebars and rollup",
"version": "1.0.0",
"scripts": {
"build": "rollup --config rollup.config.js --failAfterWarnings"
},
"private": true,
"devDependencies": {
"@rollup/plugin-node-resolve": "^13.1.1",
"handlebars": "file:../../..",
"rollup": "^2.61.1"
}
}
10 changes: 10 additions & 0 deletions tests/integration/rollup-test/rollup.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { nodeResolve } from '@rollup/plugin-node-resolve';

export default {
input: 'src/index.js',
output: {
file: 'dist/bundle.js',
format: 'es'
},
plugins: [nodeResolve()]
};
8 changes: 8 additions & 0 deletions tests/integration/rollup-test/src/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import Handlebars from 'handlebars/lib/handlebars';

const template = Handlebars.compile('Author: {{author}}');
const result = template({ author: 'Yehuda' });

if (result !== 'Author: Yehuda') {
throw Error('Assertion failed');
}
11 changes: 11 additions & 0 deletions tests/integration/rollup-test/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash

set -e

# Cleanup: package-lock and "npm ci" is not working with local dependencies
rm dist package-lock.json -rf
npm install
npm run build

node dist/bundle.js
echo "Success"

0 comments on commit 03d387b

Please sign in to comment.