-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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 RangeError in not export
error with other file type
#7295
Fix RangeError in not export
error with other file type
#7295
Conversation
|
not export
error with other file type
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great find! Could you also move the test to packages/core/integration-tests/test/postcss.js
and call it something like "should throw an error when importing a missing class"?
Here's an example for a test using scope hoisting in that file:
parcel/packages/core/integration-tests/test/postcss.js
Lines 156 to 195 in f651829
it('should produce correct css without symbol propagation for css modules classes with a namespace import', async () => { | |
let b = await bundle( | |
path.join( | |
__dirname, | |
'/integration/postcss-modules-import-namespace/index.js', | |
), | |
{ | |
mode: 'production', | |
defaultTargetOptions: { | |
shouldScopeHoist: false, | |
}, | |
}, | |
); | |
assertBundles(b, [ | |
{ | |
name: 'index.js', | |
assets: ['index.js', 'style.module.css'], | |
}, | |
{ | |
name: 'index.css', | |
assets: ['global.css', 'style.module.css'], | |
}, | |
]); | |
let {output} = await run(b, null, {require: false}); | |
assert(/_b-2_[0-9a-z]/.test(output)); | |
let css = await outputFS.readFile( | |
b.getBundles().find(b => b.type === 'css').filePath, | |
'utf8', | |
); | |
let includedRules = new Set(); | |
postcss.parse(css).walkRules(rule => { | |
includedRules.add(rule.selector); | |
}); | |
assert(includedRules.has('body')); | |
assert(includedRules.has(`.${output}`)); | |
assert(includedRules.has('.page')); | |
}); |
….type Co-authored-by: Niklas Mischkulnig <4586894+mischnic@users.noreply.github.com>
Thank you for reviewing and helping! I moved the test into |
* v2: (68 commits) Fix RangeError in `not export` error with other file type (#7295) Apply sourcemap in @parcel/transformer-typescript-tsc (#7287) Fix side effects glob matching (#7288) Fix changelog headings v2.0.1 Changelog for v2.0.1 Resolve GLSL relative to the importer, not the asset (#7263) fix: add @parcel/diagnostic as dependency of @parcel/transformer-typescript-types (#7248) Fixed missing "Parcel" export member in Module "@parcel/core" (#7250) Add script to sync engines with core version (#7207) Bump swc (#7216) Make Webpack loader detection regex dramatically faster (#7226) swc optimizer (#7212) Update esbuild in optimizer (#7233) Properly visit member expressions (#7228) Update to prettier 2 (#7209) Fix serve mode with target override and target source fields (#7187) Update package.json to include the repository (#7184) fix #6730: add transformer-raw as dependency of config-webextension (#7193) Log warning instead of crash if image optimizer fails (#7119) ...
* v2: Fix RangeError in `not export` error with other file type (#7295) Apply sourcemap in @parcel/transformer-typescript-tsc (#7287) Fix side effects glob matching (#7288) Fix changelog headings v2.0.1 Changelog for v2.0.1 Resolve GLSL relative to the importer, not the asset (#7263) fix: add @parcel/diagnostic as dependency of @parcel/transformer-typescript-types (#7248) Fixed missing "Parcel" export member in Module "@parcel/core" (#7250)
* v2: (68 commits) Fix RangeError in `not export` error with other file type (#7295) Apply sourcemap in @parcel/transformer-typescript-tsc (#7287) Fix side effects glob matching (#7288) Fix changelog headings v2.0.1 Changelog for v2.0.1 Resolve GLSL relative to the importer, not the asset (#7263) fix: add @parcel/diagnostic as dependency of @parcel/transformer-typescript-types (#7248) Fixed missing "Parcel" export member in Module "@parcel/core" (#7250) Add script to sync engines with core version (#7207) Bump swc (#7216) Make Webpack loader detection regex dramatically faster (#7226) swc optimizer (#7212) Update esbuild in optimizer (#7233) Properly visit member expressions (#7228) Update to prettier 2 (#7209) Fix serve mode with target override and target source fields (#7187) Update package.json to include the repository (#7184) fix #6730: add transformer-raw as dependency of config-webextension (#7193) Log warning instead of crash if image optimizer fails (#7119) ...
↪️ Pull Request
Fixes: #7278
Hi team ! 👋
I'm interested in contributing to parcel, and I have been doing some research on #7278, and I noticed that this RangeError is caused by language mismatch in highlighting. For example, in the situation of this issue, the JavaScript highlight that is the source of the css import is being done as a css one, and the resulting change in the number of lines is causing a RangeError.
I fixed this Range error by setting the language of codeFrame in
A does not export B
error to the file type of the file from which A imports (JavaScript in the above example). However, I am not yet familiar with the inner code of parcel, and there may be some context that I missed. If you find something I missed, please feel free to point it out to me.💻 Examples
🚨 Test instructions
I was wondering how to test it, and I wrote it in
scope-hoisting
integration test, but it may not be the right test to write here. If you have a better idea, I'd appreciate it if you could point it out.For now, I wrote a test to see if the language of the codeFrame is javascript instead of css in the
hoge.module.css does not export notExisting
error in a case like an example above✔️ PR Todo