diff --git a/package.json b/package.json index 22d2b9fb6b..a31c90fe69 100644 --- a/package.json +++ b/package.json @@ -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", @@ -126,6 +127,7 @@ "source": "src", "output": "lib", "targets": [ + "commonjs", "module", "typescript" ], diff --git a/scripts/generate-mappings.js b/scripts/generate-mappings.js index e6d462d17f..265cb5febc 100644 --- a/scripts/generate-mappings.js +++ b/scripts/generate-mappings.js @@ -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'); @@ -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)) {