postlight / lux

Build scalable, Node.js-powered REST JSON APIs with almost no code.
https://lux.postlight.com
MIT License
571 stars 60 forks source link

Fix: Colocated .spec.js files cause rollup failures #743

Closed k-fish closed 3 years ago

k-fish commented 5 years ago

I've put up a PR instead of filing an issue because this is small change that I've already worked around locally and am not sure aligns with the future strategy for testing.

Issue

If you choose to colocate test files (.spec.js) in your generated project, or use any other filename with periods in it (eg. test.something.js), running lux build will fail as the manifest gets created with periods as export names.

//dist/index.js
export {
  default as test.something
} from '../app/test.something.js';

Fix

This modifies the file filter to exclude these files and renames it to a more contextual is-project-file, as filenames with dots aren't supported by the manifest anyway so they aren't valid js files for the project.

Alternatively, the compiler could rewrite these exports as another valid symbol, as it does here: https://github.com/postlight/lux/blob/5da9653212e4693ae6f8dba4c98b91277d055b3c/src/packages/compiler/utils/format-name.js#L16

Other

This could be made more generic with exclusion filters on file names, but that'd likely require additional configuration options, which seem against the 'convention over configuration approach'.