Fix rollup warning when importing Handlebars as ESM

Closes #1696
This commit is contained in:
Jakob Linskeseder
2021-12-23 19:57:46 +01:00
committed by Jay Linski
parent e0f50b4eec
commit 03d387bf8e
8 changed files with 59 additions and 1 deletions
+1
View File
@@ -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 -
+1 -1
View File
@@ -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);
@@ -0,0 +1,11 @@
module.exports = {
root: true,
extends: ['eslint:recommended', 'prettier'],
env: {
browser: true
},
parserOptions: {
sourceType: 'module',
ecmaVersion: 6
}
};
+3
View File
@@ -0,0 +1,3 @@
node_modules
dist
package-lock.json
@@ -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"
}
}
@@ -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()]
};
@@ -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
View File
@@ -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"