8000 fix(commonjs): use correct version and add package exports (#1038) · rollup/plugins@1424249 · GitHub
[go: up one dir, main page]

Skip to content

Commit 1424249

Browse files
committed
fix(commonjs): use correct version and add package exports (#1038)
1 parent 0dc11e6 commit 1424249

File tree

5 files changed

+12
-5
lines changed

5 files changed

+12
-5
lines changed

packages/commonjs/package.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,12 @@
1313
"author": "Rich Harris <richard.a.harris@gmail.com>",
1414
"homepage": "https://github.com/rollup/plugins/tree/master/packages/commonjs/#readme",
1515
"bugs": "https://github.com/rollup/plugins/issues",
16-
"main": "dist/index.js",
17-
"module": "dist/index.es.js",
16+
"main": "./dist/cjs/index.js",
17+
"module": "./dist/es/index.js",
18+
"exports": {
19+
"require": "./dist/cjs/index.js",
20+
"import": "./dist/es/index.js"
21+
},
1822
"engines": {
1923
"node": ">= 12.0.0"
2024
},

packages/commonjs/rollup.config.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import json from '@rollup/plugin-json';
22

3+
import { emitModulePackageFile } from '../../shared/rollup.config';
4+
35
import pkg from './package.json';
46

57
export default {
@@ -10,6 +12,7 @@ export default {
1012
{
1113
file: pkg.module,
1214
format: 'es',
15+
plugins: [emitModulePackageFile()],
1316
sourcemap: true
1417
},
1518
{

packages/commonjs/test/fixtures/samples/caching/rollupWorker.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ const { workerData, parentPort } = require('worker_threads');
22

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

5-
const commonjs = require('../../../../dist/index');
5+
const commonjs = require('../../../..');
66
const { getCodeFromBundle } = require('../../../helpers/util');
77

88
generateCode(workerData);

packages/commonjs/test/helpers/util.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const path = require('path');
22

3-
const commonjsPlugin = require('../../dist/index');
3+
const commonjsPlugin = require('../..');
44

55
function commonjs(options) {
66
delete require.cache[require.resolve('../..')];

packages/commonjs/test/test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,7 @@ test('does not warn even if the ES module does not export "default"', async (t)
451451
test('compiles with cache', async (t) => {
452452
// specific commonjs require() to ensure same instance is 599F used
453453
// eslint-disable-next-line global-require
454-
const commonjsInstance = require('../dist/index');
454+
const commonjsInstance = require('..');
455455

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

0 commit comments

Comments
 (0)
0