mirror of
https://github.com/harttle/liquidjs.git
synced 2026-09-15 20:30:39 -07:00
fix: ESM bundle for Node.js, #739
This commit is contained in:
@@ -1,3 +1,3 @@
|
|||||||
const { createEngine } = require('./create-liquid')
|
const { createEngine } = require('./create-liquid')
|
||||||
|
|
||||||
module.exports = createEngine(require('../../dist/liquid.node.cjs'))
|
module.exports = createEngine(require('../../dist/liquid.cjs'))
|
||||||
|
|||||||
+3
-3
@@ -1,9 +1,9 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
VERSION_LATEST=$(cat package.json | grep '"version":' | head -1 | awk -F'"' '{print $4}')
|
VERSION_LATEST=$(cat package.json | grep '"version":' | head -1 | awk -F'"' '{print $4}')
|
||||||
FILE_LOCAL=dist/liquid.node.cjs.js
|
FILE_LOCAL=dist/liquid.node.js
|
||||||
FILE_LATEST=dist/liquid.node.cjs.$VERSION_LATEST.js
|
FILE_LATEST=dist/liquid.node.$VERSION_LATEST.js
|
||||||
URL_LATEST=https://unpkg.com/liquidjs@$VERSION_LATEST/dist/liquid.node.cjs.js
|
URL_LATEST=https://unpkg.com/liquidjs@$VERSION_LATEST/dist/liquid.node.js
|
||||||
|
|
||||||
if [ ! -f "$FILE_LATEST" ]; then
|
if [ ! -f "$FILE_LATEST" ]; then
|
||||||
curl $URL_LATEST > $FILE_LATEST
|
curl $URL_LATEST > $FILE_LATEST
|
||||||
|
|||||||
+10
-5
@@ -2,12 +2,16 @@
|
|||||||
"name": "liquidjs",
|
"name": "liquidjs",
|
||||||
"version": "10.16.4",
|
"version": "10.16.4",
|
||||||
"description": "A simple, expressive and safe Shopify / Github Pages compatible template engine in pure JavaScript.",
|
"description": "A simple, expressive and safe Shopify / Github Pages compatible template engine in pure JavaScript.",
|
||||||
"main": "dist/liquid.node.cjs.js",
|
"main": "dist/liquid.node.js",
|
||||||
"module": "dist/liquid.node.esm.js",
|
"module": "dist/liquid.node.mjs",
|
||||||
"es2015": "dist/liquid.browser.esm.js",
|
"es2015": "dist/liquid.browser.mjs",
|
||||||
"browser": {
|
"browser": {
|
||||||
"./dist/liquid.node.cjs.js": "./dist/liquid.browser.umd.js",
|
"./dist/liquid.node.js": "./dist/liquid.browser.umd.js",
|
||||||
"./dist/liquid.node.esm.js": "./dist/liquid.browser.esm.js"
|
"./dist/liquid.node.mjs": "./dist/liquid.browser.mjs"
|
||||||
|
},
|
||||||
|
"exports": {
|
||||||
|
"import": "./dist/liquid.node.mjs",
|
||||||
|
"require": "./dist/liquid.node.js"
|
||||||
},
|
},
|
||||||
"types": "dist/index.d.ts",
|
"types": "dist/index.d.ts",
|
||||||
"engines": {
|
"engines": {
|
||||||
@@ -19,6 +23,7 @@
|
|||||||
"test": "jest",
|
"test": "jest",
|
||||||
"test:coverage": "jest --coverage src test/integration",
|
"test:coverage": "jest --coverage src test/integration",
|
||||||
"test:e2e": "jest test/e2e",
|
"test:e2e": "jest test/e2e",
|
||||||
|
"test:demo": "./test/demo/check.sh",
|
||||||
"perf:diff": "bin/perf-diff.sh",
|
"perf:diff": "bin/perf-diff.sh",
|
||||||
"perf:engines": "cd benchmark && npm run engines",
|
"perf:engines": "cd benchmark && npm run engines",
|
||||||
"version": "npm run build && npm test",
|
"version": "npm run build && npm test",
|
||||||
|
|||||||
+4
-4
@@ -51,14 +51,14 @@ const browserStream = {
|
|||||||
'./streamed-emitter': '../build/streamed-emitter-browser'
|
'./streamed-emitter': '../build/streamed-emitter-browser'
|
||||||
}
|
}
|
||||||
const esmRequire = {
|
const esmRequire = {
|
||||||
include: './src/fs/node.ts',
|
include: './src/fs/fs-impl.ts',
|
||||||
delimiters: ['', ''],
|
delimiters: ['', ''],
|
||||||
'./node-require': '../build/node-require.mjs'
|
'./node-require': '../build/node-require.mjs'
|
||||||
}
|
}
|
||||||
|
|
||||||
const nodeCjs = {
|
const nodeCjs = {
|
||||||
output: [{
|
output: [{
|
||||||
file: 'dist/liquid.node.cjs.js',
|
file: 'dist/liquid.node.js',
|
||||||
format: 'cjs',
|
format: 'cjs',
|
||||||
banner
|
banner
|
||||||
}],
|
}],
|
||||||
@@ -70,7 +70,7 @@ const nodeCjs = {
|
|||||||
|
|
||||||
const nodeEsm = {
|
const nodeEsm = {
|
||||||
output: [{
|
output: [{
|
||||||
file: 'dist/liquid.node.esm.js',
|
file: 'dist/liquid.node.mjs',
|
||||||
format: 'esm',
|
format: 'esm',
|
||||||
banner
|
banner
|
||||||
}],
|
}],
|
||||||
@@ -86,7 +86,7 @@ const nodeEsm = {
|
|||||||
|
|
||||||
const browserEsm = {
|
const browserEsm = {
|
||||||
output: [{
|
output: [{
|
||||||
file: 'dist/liquid.browser.esm.js',
|
file: 'dist/liquid.browser.mjs',
|
||||||
format: 'esm',
|
format: 'esm',
|
||||||
banner
|
banner
|
||||||
}],
|
}],
|
||||||
|
|||||||
@@ -1,10 +1,6 @@
|
|||||||
import { createRequire } from 'module'
|
import { createRequire } from 'module'
|
||||||
|
|
||||||
export function requireResolve (file) {
|
export function requireResolve (file) {
|
||||||
/**
|
const require = createRequire(process.cwd() + '/')
|
||||||
* createRequire() can throw,
|
|
||||||
* when import.meta.url not begin with "file://".
|
|
||||||
*/
|
|
||||||
const require = createRequire(import.meta.url)
|
|
||||||
return require.resolve(file)
|
return require.resolve(file)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import { drainStream } from '../stub/stream'
|
|||||||
|
|
||||||
describe('.renderToNodeStream()', function () {
|
describe('.renderToNodeStream()', function () {
|
||||||
it('should render to stream in Node.js', done => {
|
it('should render to stream in Node.js', done => {
|
||||||
const cjs = require('../../dist/liquid.node.cjs')
|
const cjs = require('../../dist/liquid.node')
|
||||||
const engine = new cjs.Liquid()
|
const engine = new cjs.Liquid()
|
||||||
const tpl = engine.parseFileSync(resolve(__dirname, '../stub/root/foo.html'))
|
const tpl = engine.parseFileSync(resolve(__dirname, '../stub/root/foo.html'))
|
||||||
const stream = engine.renderToNodeStream(tpl)
|
const stream = engine.renderToNodeStream(tpl)
|
||||||
@@ -28,7 +28,7 @@ describe('.renderToNodeStream()', function () {
|
|||||||
|
|
||||||
describe('.renderFileToNodeStream()', function () {
|
describe('.renderFileToNodeStream()', function () {
|
||||||
it('should render to stream in Node.js', async () => {
|
it('should render to stream in Node.js', async () => {
|
||||||
const cjs = require('../../dist/liquid.node.cjs')
|
const cjs = require('../../dist/liquid.node')
|
||||||
const engine = new cjs.Liquid({
|
const engine = new cjs.Liquid({
|
||||||
root: resolve(__dirname, '../stub/root/')
|
root: resolve(__dirname, '../stub/root/')
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user