Skip to content

Commit

Permalink
fix(commonjs): use correct version and add package exports (#1038)
Browse files Browse the repository at this point in the history
  • Loading branch information
lukastaegert committed Apr 24, 2022
1 parent 0dc11e6 commit 1424249
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 5 deletions.
8 changes: 6 additions & 2 deletions packages/commonjs/package.json
Expand Up @@ -13,8 +13,12 @@
"author": "Rich Harris <richard.a.harris@gmail.com>",
"homepage": "https://github.com/rollup/plugins/tree/master/packages/commonjs/#readme",
"bugs": "https://github.com/rollup/plugins/issues",
"main": "dist/index.js",
"module": "dist/index.es.js",
"main": "./dist/cjs/index.js",
"module": "./dist/es/index.js",
"exports": {
"require": "./dist/cjs/index.js",
"import": "./dist/es/index.js"
},
"engines": {
"node": ">= 12.0.0"
},
Expand Down
3 changes: 3 additions & 0 deletions packages/commonjs/rollup.config.js
@@ -1,5 +1,7 @@
import json from '@rollup/plugin-json';

import { emitModulePackageFile } from '../../shared/rollup.config';

import pkg from './package.json';

export default {
Expand All @@ -10,6 +12,7 @@ export default {
{
file: pkg.module,
format: 'es',
plugins: [emitModulePackageFile()],
sourcemap: true
},
{
Expand Down
Expand Up @@ -2,7 +2,7 @@ const { workerData, parentPort } = require('worker_threads');

const { rollup } = require('rollup');

const commonjs = require('../../../../dist/index');
const commonjs = require('../../../..');
const { getCodeFromBundle } = require('../../../helpers/util');

generateCode(workerData);
Expand Down
2 changes: 1 addition & 1 deletion packages/commonjs/test/helpers/util.js
@@ -1,6 +1,6 @@
const path = require('path');

const commonjsPlugin = require('../../dist/index');
const commonjsPlugin = require('../..');

function commonjs(options) {
delete require.cache[require.resolve('../..')];
Expand Down
2 changes: 1 addition & 1 deletion packages/commonjs/test/test.js
Expand Up @@ -451,7 +451,7 @@ test('does not warn even if the ES module does not export "default"', async (t)
test('compiles with cache', async (t) => {
// specific commonjs require() to ensure same instance is used
// eslint-disable-next-line global-require
const commonjsInstance = require('../dist/index');
const commonjsInstance = require('..');

const bundle = await rollup({
input: 'fixtures/function/index/main.js',
Expand Down

0 comments on commit 1424249

Please sign in to comment.