Skip to content

Commit

Permalink
Fix RangeError in not export error with other file type (#7295)
Browse files Browse the repository at this point in the history
Co-authored-by: Niklas Mischkulnig <4586894+mischnic@users.noreply.github.com>
  • Loading branch information
Shinyaigeek and mischnic committed Nov 14, 2021
1 parent 8928430 commit 145bfb8
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/core/core/src/requests/AssetGraphRequest.js
Expand Up @@ -554,7 +554,7 @@ export class AssetGraphBuilder {
this.options.projectRoot,
loc?.filePath,
) ?? undefined,
language: assetNode.value.type,
language: incomingDep.value.sourceAssetType ?? undefined,
codeHighlights: [
{
start: loc.start,
Expand Down
@@ -0,0 +1,3 @@
{
"source": "src/App.jsx"
}
@@ -0,0 +1,10 @@
import React from "react";
import { render } from "react-dom";

import * as styles from "./app.module.css"

const App = function() {
return <div className={styles.notExisting}></div>
}

render(<App/>, document.getElementById("app"))
49 changes: 49 additions & 0 deletions packages/core/integration-tests/test/postcss.js
Expand Up @@ -623,4 +623,53 @@ describe('postcss', () => {

await subscription.unsubscribe();
});

it('should throw an error when importing a missing class', async function () {
await assert.rejects(
() =>
bundle(
path.join(
__dirname,
'/integration/no-export-error-with-correct-filetype/src/App.jsx',
),
{
shouldDisableCache: true,
defaultTargetOptions: {
shouldScopeHoist: true,
},
},
),
{
name: 'BuildError',
diagnostics: [
{
codeFrames: [
{
filePath: path.join(
__dirname,
'/integration/no-export-error-with-correct-filetype/src/App.jsx',
),
language: 'js',
codeHighlights: [
{
end: {
column: 45,
line: 7,
},
start: {
column: 28,
line: 7,
},
},
],
},
],
message:
"integration/no-export-error-with-correct-filetype/src/app.module.css does not export 'notExisting'",
origin: '@parcel/core',
},
],
},
);
});
});

0 comments on commit 145bfb8

Please sign in to comment.