Skip to content

Commit 905a6dd

Browse files
committedAug 14, 2022
fix: target ES6 for ESM bundles, fixes #526
1 parent e874b40 commit 905a6dd

File tree

3 files changed

+13
-12
lines changed

3 files changed

+13
-12
lines changed
 

‎.eslintrc.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
"@typescript-eslint/no-unused-vars": ["error", { "vars": "all", "args": "none", "ignoreRestSiblings": false }]
3333
},
3434
"overrides": [{
35-
"files": ["**/*.js", "*.js"],
35+
"files": ["**/*.js", "**/*.mjs"],
3636
"rules": {
3737
"@typescript-eslint/no-var-requires": "off"
3838
}

‎package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
},
1212
"types": "dist/liquid.d.ts",
1313
"scripts": {
14-
"lint": "eslint \"**/*.ts\" .",
14+
"lint": "eslint \"**/*.mjs\" \"**/*.ts\" .",
1515
"check": "npm run build && npm test && npm run lint && npm run perf:diff",
1616
"test": "nyc mocha \"test/**/*.ts\"",
1717
"test:e2e": "mocha \"test/e2e/**/*.ts\"",
@@ -20,7 +20,7 @@
2020
"perf:engines": "cd benchmark && npm run engines",
2121
"postversion": "npm run build:dist",
2222
"build": "npm run build:dist && npm run build:docs",
23-
"build:dist": "rollup -c rollup.config.ts",
23+
"build:dist": "rollup -c rollup.config.mjs",
2424
"build:docs": "bin/build-docs.sh"
2525
},
2626
"bin": {

‎rollup.config.ts ‎rollup.config.mjs

+10-9
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import { uglify } from 'rollup-plugin-uglify'
2-
import pkg from './package.json'
32
import typescript from 'rollup-plugin-typescript2'
43
import replace from 'rollup-plugin-replace'
54
import versionInjector from 'rollup-plugin-version-injector'
5+
import { createRequire } from 'module'
66

7+
const pkg = createRequire(import.meta.url)('./package.json')
78
const version = process.env.VERSION || pkg.version
89
const sourcemap = true
910
const banner = `/*
@@ -14,16 +15,16 @@ const banner = `/*
1415
const treeshake = {
1516
propertyReadSideEffects: false
1617
}
17-
const tsconfig = {
18+
const tsconfig = (target) => ({
1819
tsconfigOverride: {
1920
include: [ 'src' ],
2021
exclude: [ 'test', 'benchmark' ],
2122
compilerOptions: {
22-
target: 'es5',
23+
target,
2324
module: 'ES2015'
2425
}
2526
}
26-
}
27+
})
2728
const versionInjection = versionInjector({
2829
injectInComments: false,
2930
injectInTags: {
@@ -60,7 +61,7 @@ const nodeCjs = {
6061
banner
6162
}],
6263
external: ['path', 'fs'],
63-
plugins: [versionInjection, typescript(tsconfig)],
64+
plugins: [versionInjection, typescript(tsconfig('es5'))],
6465
treeshake,
6566
input
6667
}
@@ -75,7 +76,7 @@ const nodeEsm = {
7576
plugins: [
7677
versionInjection,
7778
replace(esmRequire),
78-
typescript(tsconfig)
79+
typescript(tsconfig('es6'))
7980
],
8081
treeshake,
8182
input
@@ -92,7 +93,7 @@ const browserEsm = {
9293
versionInjection,
9394
replace(browserFS),
9495
replace(browserStream),
95-
typescript(tsconfig)
96+
typescript(tsconfig('es6'))
9697
],
9798
treeshake,
9899
input
@@ -110,7 +111,7 @@ const browserUmd = {
110111
versionInjection,
111112
replace(browserFS),
112113
replace(browserStream),
113-
typescript(tsconfig)
114+
typescript(tsconfig('es5'))
114115
],
115116
treeshake,
116117
input
@@ -128,7 +129,7 @@ const browserMin = {
128129
versionInjection,
129130
replace(browserFS),
130131
replace(browserStream),
131-
typescript(tsconfig),
132+
typescript(tsconfig('es5')),
132133
uglify()
133134
],
134135
treeshake,

0 commit comments

Comments
 (0)
Please sign in to comment.