Skip to content

Commit ce96371

Browse files
committed
Publish inline-email as ESM
1 parent 85565a8 commit ce96371

19 files changed

Lines changed: 76 additions & 39 deletions

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ jobs:
2525

2626
- run: npm install
2727
- run: npm audit --audit-level=high
28-
- run: npm test
2928
- run: npm run build
29+
- run: npm test
3030
- name: Verify tag matches package version
3131
run: node -e "const pkg = require('./package.json'); const expected = 'v' + pkg.version; if (process.env.GITHUB_REF_NAME !== expected) { throw new Error('Tag ' + process.env.GITHUB_REF_NAME + ' does not match package version ' + expected); }"
3232
- name: Resolve npm dist tag

examples/integrations/node-send.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
const { readFileSync } = require('node:fs');
2-
const { join } = require('node:path');
3-
const { compileEmailTemplate } = require('../../dist');
1+
import { readFileSync } from 'node:fs';
2+
import { dirname, join } from 'node:path';
3+
import { fileURLToPath } from 'node:url';
4+
import { compileEmailTemplate } from '../../dist/index.js';
45

6+
const __dirname = dirname(fileURLToPath(import.meta.url));
57
const rootDir = join(__dirname, '..', '..');
68
const template = readFileSync(join(rootDir, 'examples', 'auth', 'welcome-verify.html'), 'utf8');
79
const css = readFileSync(join(rootDir, 'examples', 'auth', 'shared.css'), 'utf8');

examples/integrations/preview-server.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
const { createServer } = require('node:http');
2-
const { readFileSync } = require('node:fs');
3-
const { join } = require('node:path');
4-
const { compileEmailTemplate } = require('../../dist');
1+
import { readFileSync } from 'node:fs';
2+
import { createServer } from 'node:http';
3+
import { dirname, join } from 'node:path';
4+
import { fileURLToPath } from 'node:url';
5+
import { compileEmailTemplate } from '../../dist/index.js';
56

7+
const __dirname = dirname(fileURLToPath(import.meta.url));
68
const rootDir = join(__dirname, '..', '..');
79
const host = '127.0.0.1';
810
const port = Number(process.env.PORT || 4174);

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
{
22
"name": "inline-email",
3-
"version": "3.0.0",
3+
"version": "3.0.1",
44
"description": "Modern email template compilation and rendering for safe HTML email.",
5+
"type": "module",
56
"main": "dist/index.js",
67
"types": "dist/index.d.ts",
78
"publishConfig": {
@@ -10,7 +11,7 @@
1011
"exports": {
1112
".": {
1213
"types": "./dist/index.d.ts",
13-
"require": "./dist/index.js"
14+
"import": "./dist/index.js"
1415
}
1516
},
1617
"files": [
@@ -25,7 +26,7 @@
2526
"examples": "npm run build && node scripts/render-examples.js",
2627
"examples:serve": "npm run examples && node scripts/serve-examples.js",
2728
"examples:auth": "npm run examples",
28-
"prepublishOnly": "npm test && npm run build",
29+
"prepublishOnly": "npm run build && npm test",
2930
"prepack": "npm run build",
3031
"test": "vitest run",
3132
"test:visual": "playwright test",

scripts/render-examples.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
const { copyFileSync, mkdirSync, readFileSync, writeFileSync } = require('node:fs');
2-
const { basename, join } = require('node:path');
3-
const { compileEmailTemplate } = require('../dist');
1+
import { copyFileSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
2+
import { basename, dirname, join } from 'node:path';
3+
import { fileURLToPath } from 'node:url';
4+
import { compileEmailTemplate } from '../dist/index.js';
45

6+
const __dirname = dirname(fileURLToPath(import.meta.url));
57
const rootDir = join(__dirname, '..');
68
const examplesDir = join(rootDir, 'examples');
79
const outputDir = join(examplesDir, 'out');

scripts/serve-examples.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
const { createReadStream, existsSync, statSync } = require('node:fs');
2-
const { createServer } = require('node:http');
3-
const { extname, join, normalize } = require('node:path');
1+
import { createReadStream, existsSync, statSync } from 'node:fs';
2+
import { createServer } from 'node:http';
3+
import { dirname, extname, join, normalize } from 'node:path';
4+
import { fileURLToPath } from 'node:url';
45

6+
const __dirname = dirname(fileURLToPath(import.meta.url));
57
const rootDir = join(__dirname, '..');
68
const outputDir = join(rootDir, 'examples', 'out');
79
const host = '127.0.0.1';

src/cli.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
#!/usr/bin/env node
22

33
import { existsSync, readFileSync, writeFileSync } from 'node:fs';
4-
import { compileEmailTemplate } from './compile';
4+
import { pathToFileURL } from 'node:url';
5+
import { compileEmailTemplate } from './compile.js';
56

67
interface CliOptions {
78
html?: string;
@@ -158,7 +159,7 @@ Options:
158159

159160
class CliError extends Error {}
160161

161-
if (require.main === module) {
162+
if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href) {
162163
main(process.argv.slice(2)).catch((error: Error) => {
163164
console.error('\x1b[31m%s\x1b[0m', error.message);
164165
console.error(usage());

src/compile.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import juice from 'juice';
2-
import { renderResponsiveLayout } from './layout';
3-
import { applyEmailStyle } from './style';
4-
import { renderTemplate } from './template';
2+
import { renderResponsiveLayout } from './layout.js';
3+
import { applyEmailStyle } from './style.js';
4+
import { renderTemplate } from './template.js';
55
import type {
66
CompiledEmailTemplate,
77
CompileEmailTemplateOptions,
@@ -12,7 +12,7 @@ import type {
1212
RenderEmailOptions,
1313
RenderedEmail,
1414
TemplateTransform
15-
} from './types';
15+
} from './types.js';
1616

1717
const DEFAULT_JUICE_OPTIONS: JuiceOptions = {
1818
webResources: {

src/index.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ export {
22
compileEmailTemplate,
33
inlineEmailHtml,
44
renderEmail
5-
} from './compile';
5+
} from './compile.js';
66

7-
export { renderTemplate } from './template';
8-
export { renderResponsiveLayout } from './layout';
7+
export { renderTemplate } from './template.js';
8+
export { renderResponsiveLayout } from './layout.js';
99

1010
export type {
1111
CompiledEmailTemplate,
@@ -20,4 +20,4 @@ export type {
2020
TemplateData,
2121
TemplateTransform,
2222
TemplateValue
23-
} from './types';
23+
} from './types.js';

0 commit comments

Comments
 (0)