Skip to content

Commit

Permalink
fix: target ES6 for ESM bundles, fixes #526
Browse files Browse the repository at this point in the history
  • Loading branch information
harttle committed Aug 14, 2022
1 parent e874b40 commit 905a6dd
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"@typescript-eslint/no-unused-vars": ["error", { "vars": "all", "args": "none", "ignoreRestSiblings": false }]
},
"overrides": [{
"files": ["**/*.js", "*.js"],
"files": ["**/*.js", "**/*.mjs"],
"rules": {
"@typescript-eslint/no-var-requires": "off"
}
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
},
"types": "dist/liquid.d.ts",
"scripts": {
"lint": "eslint \"**/*.ts\" .",
"lint": "eslint \"**/*.mjs\" \"**/*.ts\" .",
"check": "npm run build && npm test && npm run lint && npm run perf:diff",
"test": "nyc mocha \"test/**/*.ts\"",
"test:e2e": "mocha \"test/e2e/**/*.ts\"",
Expand All @@ -20,7 +20,7 @@
"perf:engines": "cd benchmark && npm run engines",
"postversion": "npm run build:dist",
"build": "npm run build:dist && npm run build:docs",
"build:dist": "rollup -c rollup.config.ts",
"build:dist": "rollup -c rollup.config.mjs",
"build:docs": "bin/build-docs.sh"
},
"bin": {
Expand Down
19 changes: 10 additions & 9 deletions rollup.config.ts → rollup.config.mjs
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { uglify } from 'rollup-plugin-uglify'
import pkg from './package.json'
import typescript from 'rollup-plugin-typescript2'
import replace from 'rollup-plugin-replace'
import versionInjector from 'rollup-plugin-version-injector'
import { createRequire } from 'module'

const pkg = createRequire(import.meta.url)('./package.json')
const version = process.env.VERSION || pkg.version
const sourcemap = true
const banner = `/*
Expand All @@ -14,16 +15,16 @@ const banner = `/*
const treeshake = {
propertyReadSideEffects: false
}
const tsconfig = {
const tsconfig = (target) => ({
tsconfigOverride: {
include: [ 'src' ],
exclude: [ 'test', 'benchmark' ],
compilerOptions: {
target: 'es5',
target,
module: 'ES2015'
}
}
}
})
const versionInjection = versionInjector({
injectInComments: false,
injectInTags: {
Expand Down Expand Up @@ -60,7 +61,7 @@ const nodeCjs = {
banner
}],
external: ['path', 'fs'],
plugins: [versionInjection, typescript(tsconfig)],
plugins: [versionInjection, typescript(tsconfig('es5'))],
treeshake,
input
}
Expand All @@ -75,7 +76,7 @@ const nodeEsm = {
plugins: [
versionInjection,
replace(esmRequire),
typescript(tsconfig)
typescript(tsconfig('es6'))
],
treeshake,
input
Expand All @@ -92,7 +93,7 @@ const browserEsm = {
versionInjection,
replace(browserFS),
replace(browserStream),
typescript(tsconfig)
typescript(tsconfig('es6'))
],
treeshake,
input
Expand All @@ -110,7 +111,7 @@ const browserUmd = {
versionInjection,
replace(browserFS),
replace(browserStream),
typescript(tsconfig)
typescript(tsconfig('es5'))
],
treeshake,
input
Expand All @@ -128,7 +129,7 @@ const browserMin = {
versionInjection,
replace(browserFS),
replace(browserStream),
typescript(tsconfig),
typescript(tsconfig('es5')),
uglify()
],
treeshake,
Expand Down

0 comments on commit 905a6dd

Please sign in to comment.