Skip to content

Commit

Permalink
Add "type":"module" to published root package.json file.
Browse files Browse the repository at this point in the history
The root package.json file was neglected in #8396, since it isn't
generated in the same way as the other (nested) package.json files.

This commit puts `"type": "module"` in the _published_
`@apollo/client/package.json` file, which is generated at build time as
the file `dist/package.json`. The root `package.json` file that's
checked into the repository does _not_ contain `"type": "module"` (even
though putting it there would also put it in `dist/package.json`).
Attempting to enable ES module syntax at that level interfered pretty
severely with tools like ts-node, which we use to run various
config/*.ts scripts. Rewriting those scripts is a job for another time.

I'm happy to revisit this as the ecosystem progresses.
  • Loading branch information
benjamn committed Jul 30, 2021
1 parent 0377d22 commit 1f29871
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions config/prepareDist.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ const distRoot = `${__dirname}/../dist`;
const packageJson = require('../package.json');
const entryPoints = require('./entryPoints.js');

// Enable default interpretation of .js files as ECMAScript modules. We don't
// put this in the source ../package.json file because it interferes with tools
// like ts-node, which we use to run various ../config/*.ts scripts.
// TODO(benjamn) Fully diagnose that interference.
packageJson.type = 'module';

// The root package.json is marked as private to prevent publishing
// from happening in the root of the project. This sets the package back to
// public so it can be published from the "dist" directory.
Expand Down

0 comments on commit 1f29871

Please sign in to comment.