Closed stijnvanderlaan closed 7 years ago
Can you pls include the files in file array and try again ? I will check whats going on with the duplicate line.
When I add the files to the entry as an array the result is:
import { testFunc } from 'src/test.js';
testFunc("asdfsdf");
console.log("112233")console.log("112233")
I would expect the import to be './src/test.js'
because webpack thinks it's a node_module now.
jstwister.config.js
module.exports = {
entry: ["src/index.js", "src/test.js"],
resolve: {
alias: {},
extensions: ["", ".js", ".jsx", ".es6", ".css"],
modules: [".", "./node_modules"]
},
files: [],
exclude: [],
printer: {
tabWidth: 4,
useTabs: false,
reuseWhitespace: true,
lineTerminator: "\n",
wrapColumn: 80,
quote: "single",
trailingComma: false,
arrayBracketSpacing: false,
objectCurlySpacing: true,
arrowParensAlways: false,
flowObjectCommas: true
},
autostart: false,
logLevel: "info"
};
Unfortunately adding an entry like "**/src/**/*.js"
is not working.
Sorry for the trouble. So the thing is like this:
import { testFunc } from 'src/test.js';
is actually correct. Same as Webpack the imports are relative to the locations specified in resolve.modules
. In config you have "." specified there, so that's why you get this import.If you wish to have relative imports like './src/test.js'
you can do that too, but i wouldn't recommend it for code maintainance reasons.
In config file just set the ''import-style' like this:
module.exports = {
.....
plugins: {
'imports-manager': {
'import-style': 'relativeToFile' // other option is 'relativeToModules'
}
}
......
}
Thanks, I got it to work, also "**/src/**/*.js"
does seems to work, that was related to something else, I created another issue.
index.js
src/test.js
jstwister.config.js
Running
Add missing imports
onindex.js
results in:Output:
Version 0.0.10