Skip to content

Commit

Permalink
feat: fix esm not accepting extensionless files
Browse files Browse the repository at this point in the history
  • Loading branch information
iwaduarte committed Oct 13, 2022
1 parent c7f12b6 commit 14e5d94
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion bin/express-sire.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ const start = async () => {
{ filename: 'env.js', output: '.env' },
{ filename: 'app.js', prettify: 'app.js' },
{ filename: 'package.json.js', prettify: 'package.json', output: 'package.json' },
{ filename: join('bin', 'www.js'), mode: MODE_0755, output: join('bin', 'www') },
{ filename: join('bin', 'www.js'), mode: MODE_0755, output: join('bin', 'www.js') },
...(gitIgnore ? [{ filename: 'gitignore', output: '.gitignore' }] : []),
join('routes', 'routes.js'),
...(sequelize
Expand Down
2 changes: 1 addition & 1 deletion templates/bin/www.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
${
opts.esm || ''
? `import app from '../app';
? `import app from '../app.js';
import _debug from 'debug';
import http from 'http';
Expand Down
2 changes: 1 addition & 1 deletion templates/controllers/user.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
`${
opts.esm
? "import SequelizeObject from '../database/connect'"
? "import SequelizeObject from '../database/connect.js'"
: "const SequelizeObject = require('../database/connect')"
};
Expand Down
2 changes: 1 addition & 1 deletion templates/database/connect.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
`${
opts.esm
? `import Sequelize from 'sequelize';
import loadModels from './loadModels';
import loadModels from './loadModels.js';
`
: `const Sequelize = require('sequelize');
const loadModels = require('./loadModels');
Expand Down
2 changes: 1 addition & 1 deletion templates/database/syncDatabase.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
`${opts.esm ? 'import { sequelize } from "./connect"' : "const { sequelize } = require('./connect');"}
`${opts.esm ? 'import { sequelize } from "./connect.js"' : "const { sequelize } = require('./connect');"}
// update database tables (columns and metadata).
// quick alternative to migrations.
Expand Down
2 changes: 1 addition & 1 deletion templates/routes/users.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
`${
opts.esm
? `import express from 'express';\nimport UserModel from "../controllers/user";`
? `import express from 'express';\nimport UserModel from "../controllers/user.js";`
: `const express = require('express');\nconst UserModel = require('../controllers/user');`
}
Expand Down

0 comments on commit 14e5d94

Please sign in to comment.