import file without extension suffix
See original GitHub issueimport-all.macro
version:node
version:npm
(oryarn
) version:
Relevant code or config
import importAll from 'import-all.macro'
const entityClassesMap = importAll.sync('../../entities/*.*')
What you did:
What happened:
Output:
var _entitiesAppRepositoryTs = _interopRequireWildcard(require("../../entities/app-repository.ts"));
var _entitiesAppTs = _interopRequireWildcard(require("../../entities/app.ts"));
Reproduction repository:
Problem description:
I use typescript to code my project, so the files under ../../entities/*.*
directory are all with extension .ts
, importAll.sync()
also generated imports for full paths with suffix .ts
too.
The babel-node
can execute the codes generated by import-all.marco
. But after those .ts
files were compiled into .js
files, we can’t execute the .js
file contain require
for .ts
files. Because there are not .ts
files in dist directory.
Suggested solution:
Usually, we import js or ts modules without extension, so our import or requirement will work very well with the “same” file with different extensions.
So maybe import-all.macro
can provide an option to strip the extension suffix when generated import statements?
The configuration in babel-plugin-macro.config.js
importAll: {
ignoreExtensions: ['.js', '.ts']
}
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (6 by maintainers)
Top GitHub Comments
I have an idea for this. How about we give you this API:
This would allow for all kinds of flexibility.
Thanks @chengjianhua. This is fixed in #24