Skip to content

Commit

Permalink
fix: webpack v4 support via ejs trick (#78)
Browse files Browse the repository at this point in the history
* fix: webpack v4 support via ejs trick

* comma
  • Loading branch information
marbemac authored May 13, 2021
1 parent de1cb96 commit 612bcbd
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/commands/bundle/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { flags as flagHelpers } from '@oclif/command';
import { buildCommand, getConfigFilePath } from '../../utils';
import * as fs from 'fs';

import { buildCommand, buildPath, getConfigFilePath } from '../../utils';
import BuildCommand from '../build';

export default class BundleCommand extends BuildCommand {
Expand Down Expand Up @@ -44,15 +46,25 @@ export default class BundleCommand extends BuildCommand {

protected preparePackageJson() {
const pkg = super.preparePackageJson();

Object.assign(pkg, {
type: 'commonjs',
main: './index.js',
module: './index.mjs',
// webpack v4 support
module: './index.ejs',
exports: {
require: './index.js',
import: './index.mjs',
},
});

return pkg;
}

public postPublish() {
// webpack v4 support
fs.copyFileSync(buildPath('dist', 'index.mjs'), buildPath('dist', 'index.ejs'));

super.postPublish();
}
}

0 comments on commit 612bcbd

Please sign in to comment.