Skip to content

Commit

Permalink
fix: add commonjs step to bob and configure main and module fields pr…
Browse files Browse the repository at this point in the history
…operly (#1415)
  • Loading branch information
Trancever committed Oct 23, 2019
1 parent 6234c9a commit 9b74d21
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 3 additions & 1 deletion package.json
Expand Up @@ -2,7 +2,8 @@
"name": "react-native-paper",
"version": "3.0.0",
"description": "Material design for React Native",
"main": "lib/module/index.js",
"main": "lib/commonjs/index.js",
"module": "lib/module/index.js",
"types": "lib/typescript/src/index.d.ts",
"files": [
"lib",
Expand Down Expand Up @@ -126,6 +127,7 @@
"source": "src",
"output": "lib",
"targets": [
"commonjs",
"module",
"typescript"
],
Expand Down
3 changes: 2 additions & 1 deletion scripts/generate-mappings.js
Expand Up @@ -5,6 +5,7 @@ const fs = require('fs');
const types = require('babel-types');
const parser = require('@babel/parser');

const packageJson = require('../package.json');
const root = path.resolve(__dirname, '..');
const output = path.join(root, 'lib/mappings.json');
const source = fs.readFileSync(path.resolve(root, 'src', 'index.tsx'), 'utf8');
Expand All @@ -20,7 +21,7 @@ const ast = parser.parse(source, {
});

const relative = (value /* : string */) =>
path.relative(root, path.resolve(path.dirname(require.resolve('..')), value));
path.relative(root, path.resolve(path.dirname(packageJson.module), value));

const mappings = ast.program.body.reduce((acc, declaration, index, self) => {
if (types.isExportNamedDeclaration(declaration)) {
Expand Down

0 comments on commit 9b74d21

Please sign in to comment.