js-api-loader icon indicating copy to clipboard operation
js-api-loader copied to clipboard

fix: rollup/typescript configuration

Open usefulthink opened this issue 1 year ago • 1 comments

This is a full refactoring of the rollup configuration to speed up builds, simplify the configuration, prevent warnings and fix an error with the generated source maps.

In detail:

  • refactor: Combine the three non-esm outputs into a single configuration.

  • refactor: add {babelHelpers:'bundled'} to configuration. This doesn't change the behavior (since it's the default if unspecified), but it prevents the corresponding warning from showing up.

  • feat: Enabled source-maps for all build outputs.

  • fix: Use a separate TypeScript configuration (tsconfig.build.json) during build. This configuration only compiles the required typescript files and doesn't reproduce the directory structure in the dist-folder (see also the change in package.json). It also now generates source maps correctly (#834).

  • chore: Moved fast-deep-equal from dependencies to devDependencies. It is a very small function, and it has always been bundled in all of our outputs, so it's not actually required at runtime. This will be changed in the next major release.

fixes #834

usefulthink avatar Feb 23 '24 08:02 usefulthink

Additional testing:

Ran publint over the new package. Result:

@googlemaps/js-api-loader lint results:
Suggestions:
1. pkg.module is used to output ESM, but pkg.exports is not defined. As NodeJS doesn't read pkg.module, the ESM output may be skipped. Consider adding pkg.exports to export the ESM output. pkg.module can usually be removed alongside too. (This will be a breaking change)

So no errors or warnings, migration to using only exports is something for the next major release.

Install tests in multiple setups (always installing this package via npm pack ../path/to/js-api-loader and npm install googlemaps-js-api-loader-x.xx.xx.tgz) and confirmed

  • no build-errors or warnings
  • types are available
  • package works as expected
  • debugging in chrome works with sourcemaps

Test setups:

  • [x] create-react-app (webpack / TS)
  • [x] next.js (babel / TS)
  • [x] vite (vite / TS)
  • [x] loading UMD with script-tag (no bundler / JS)
  • [x] loading IIFE (min/dev) with script-tag
  • [x] loading ESM with native import

usefulthink avatar Feb 23 '24 08:02 usefulthink