Skip to content

Commit

Permalink
Merge pull request #198 from yumauri/main
Browse files Browse the repository at this point in the history
  • Loading branch information
sergeysova authored Feb 17, 2022
2 parents 374b3a8 + 2c64a63 commit 605b80d
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 22 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
"cleanup": "rm -rf dist && mkdir dist",
"build:indexes": "node scripts/build.js",
"build:types": "tsc --project ./tsconfig.build.json",
"build:commonjs": "yarn babel --verbose --out-dir dist src -x .ts --ignore '**/*.test.ts','**/*.d.ts'",
"build:mjs": "ESMODULES=true yarn build:commonjs --out-file-extension .mjs",
"build:commonjs": "yarn babel --verbose --out-dir dist src -x .ts --ignore '**/*.test.ts','**/*.d.ts' --out-file-extension .cjs",
"build:mjs": "ESMODULES=true yarn build:commonjs --out-file-extension .js",
"build:bundles": "rollup -c",
"build": "run-s cleanup build:indexes build:types build:commonjs build:mjs build:bundles",
"prepublishOnly": "yarn build:methods && yarn build:cjs"
Expand Down
8 changes: 4 additions & 4 deletions rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@ const plugins = [
terser({}),
];

const input = 'dist/index.js';
const input = 'dist/index.cjs';

// eslint-disable-next-line import/no-anonymous-default-export
export default [
{
input: 'dist/index.mjs',
input: 'dist/index.js',
external: ['effector'],
plugins,
output: {
file: './dist/patronum.mjs',
file: './dist/patronum.js',
format: 'es',
sourcemap: true,
externalLiveBindings: false,
Expand All @@ -28,7 +28,7 @@ export default [
external: ['effector'],
plugins,
output: {
file: './dist/patronum.cjs.js',
file: './dist/patronum.cjs',
format: 'cjs',
freeze: false,
exports: 'named',
Expand Down
14 changes: 7 additions & 7 deletions scripts/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ async function main() {
pkg.exports = {
'./package.json': './package.json',
'.': {
require: './index.js',
import: './index.mjs',
default: './index.mjs',
require: './index.cjs',
import: './index.js',
default: './index.js',
},
'./babel-preset': {
require: './babel-preset.cjs',
Expand All @@ -47,8 +47,8 @@ async function main() {

const internalPkg = {
type: 'module',
main: 'index.js',
module: 'index.mjs',
main: 'index.cjs',
module: 'index.js',
types: 'index.d.ts',
};

Expand All @@ -58,8 +58,8 @@ async function main() {
),
);

await directory.write('index.js', createCommonJsIndex(names));
await directory.write('index.mjs', createMjsIndex(names));
await directory.write('index.cjs', createCommonJsIndex(names));
await directory.write('index.js', createMjsIndex(names));
await directory.write('index.d.ts', createTypingsIndex(names));
await directory.write('macro.d.ts', 'export * from "./index";');

Expand Down
8 changes: 4 additions & 4 deletions scripts/libraries.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const mkdir = promisify(fs.mkdir);
function createCommonJsIndex(names) {
const imports = names.sort().map((name) => {
const camel = camelCase(name);
return `module.exports.${camel} = require('./${name}').${camel};`;
return `module.exports.${camel} = require('./${name}/index.cjs').${camel};`;
});

return imports.join('\n') + '\n';
Expand All @@ -20,7 +20,7 @@ function createCommonJsIndex(names) {
function createMjsIndex(names) {
const imports = names.sort().map((name) => {
const camel = camelCase(name);
return `export { ${camel} } from './${name}/index.mjs'`;
return `export { ${camel} } from './${name}/index.js'`;
});

return imports.join('\n') + '\n';
Expand Down Expand Up @@ -49,8 +49,8 @@ function createExportsMap(names) {
names.forEach((name) => {
object[`./${name}/package.json`] = `./${name}/package.json`;
object[`./${name}`] = {
require: `./${name}/index.js`,
import: `./${name}/index.mjs`,
require: `./${name}/index.cjs`,
import: `./${name}/index.js`,
};
});
return object;
Expand Down
6 changes: 3 additions & 3 deletions scripts/libraries.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ const {
test('commonjs index with multiple words', () => {
expect(createCommonJsIndex(['first', 'second-item', 'another-text-demo']))
.toMatchInlineSnapshot(`
"module.exports.anotherTextDemo = require('./another-text-demo').anotherTextDemo;
module.exports.first = require('./first').first;
module.exports.secondItem = require('./second-item').secondItem;
"module.exports.anotherTextDemo = require('./another-text-demo/index.cjs').anotherTextDemo;
module.exports.first = require('./first/index.cjs').first;
module.exports.secondItem = require('./second-item/index.cjs').secondItem;
"
`);
});
Expand Down
4 changes: 2 additions & 2 deletions scripts/source.package.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ module.exports = () => ({
version: '0.0.0-real-version-will-be-set-on-ci',
description: '☄️ Effector utility library delivering modularity and convenience',
type: 'module',
main: 'patronum.cjs.js',
main: 'patronum.cjs',
types: 'index.d.ts',
module: 'patronum.mjs',
module: 'patronum.js',
browser: 'patronum.umd.js',
sideEffects: false,
repository: {
Expand Down

0 comments on commit 605b80d

Please sign in to comment.