Skip to content

Commit

Permalink
convert adapter-node to ESM (#387)
Browse files Browse the repository at this point in the history
  • Loading branch information
Rich Harris authored Feb 11, 2021
1 parent d9fc240 commit ab2367d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
5 changes: 5 additions & 0 deletions .changeset/few-singers-pump.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@sveltejs/adapter-node': patch
---

Convert to ESM
14 changes: 7 additions & 7 deletions packages/adapter-node/index.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
'use strict';
import { copyFileSync } from 'fs';
import { dirname, join } from 'path';
import { fileURLToPath } from 'url';

const fs = require('fs');
const { join } = require('path');

module.exports = async function adapter(builder) {
export default async function adapter(builder) {
const dir = dirname(fileURLToPath(import.meta.url));
const out = 'build'; // TODO implement adapter options

builder.log.minor('Writing client application...');
Expand All @@ -14,10 +14,10 @@ module.exports = async function adapter(builder) {
builder.log.minor('Building server');
builder.copy_server_files(out);

fs.copyFileSync(`${__dirname}/files/server.js`, `${out}/index.js`);
copyFileSync(`${dir}/files/server.js`, `${out}/index.js`);

builder.log.minor('Prerendering static pages...');
await builder.prerender({
dest: `${out}/prerendered`
});
};
}

0 comments on commit ab2367d

Please sign in to comment.