New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: the empty string importee should not always be treated as external module id #2733
Conversation
Thanks for your contribution. Could you explain, in what situation the code you changed caused a bug and what the nature of the bug was? The best category to add a test to is usually the |
Sure! When we pack this: // rollup-import.js#.js
export var importee = 'xxx';
// rollup-import.js
import { importee } from '';
export var importer = importee;
// rollup-input.js
import { importer } from './rollup-importer.js';
export default importer; (using this:) const { rollup } = require('rollup');
( async function () {
const bundle = await rollup({
input: __dirname+'/rollup-input.js',
external: () => false,
plugins: [{
resolveId (importee, importer) {
if ( importee==='' ) { return importer+'#.js'; }
}
}]
});
const { output } = await bundle.generate({
format: 'cjs',
interop: false,
exports: 'default'
});
const [{ code }] = output;
console.log(code);
} )().catch(console.error); We will always got this: 'use strict';
var = require('');
var importer = .importee;
module.exports = importer; Because after custom
After my fix, we will got: 'use strict';
var importee = 'xxx';
var importer = importee;
module.exports = importer;
I think I really need... thank you. After this time, I think I can learn how to write the test correctly... |
I have added a simple test based on your example, please have a look. I'll add some comments to explain how it works. |
@lukastaegert |
This PR contains:
Are tests included?
Breaking Changes?
List any relevant issue numbers:
Description
I'm not sure which category to put test about this bug.