Skip to content
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

Cannot read properties of undefined (reading 'url') #120

Closed
frederikbosch opened this issue Mar 29, 2022 · 1 comment · Fixed by #125
Closed

Cannot read properties of undefined (reading 'url') #120

frederikbosch opened this issue Mar 29, 2022 · 1 comment · Fixed by #125
Assignees
Labels
bug Something isn't working

Comments

@frederikbosch
Copy link

{
  "dependencies": {
    "normalize.css": "^8.0.1"
  },
  "devDependencies": {
    "sass-embedded": "^1.49.9"
  }
}
// index.js
require('sass-embedded').renderSync({
  file: 'screen.scss',
  includePaths: [__dirname + '/node_modules'],
  importer: (x) => {
    console.log('never arrives here');
    return x;
  }
});
// test.scss
p {
  margin-bottom: 1.5em;
}
// screen.scss
@import 'test.scss';
@import 'normalize.css/normalize';

The above setup results in:

/srv/libraries/dart-sass-test/node_modules/sass-embedded/dist/lib/src/legacy/index.js:41
        throw newLegacyException(error);
        ^

Error: Error: TypeError: Cannot read properties of undefined (reading 'url')
  ╷
3 │ @import 'normalize.css/normalize';
  │         ^^^^^^^^^^^^^^^^^^^^^^^^^
  ╵
  screen.scss 3:9  root stylesheet
    at handleCompileResponse (/srv/libraries/dart-sass-test/node_modules/sass-embedded/dist/lib/src/compile.js:213:15)
    at compileRequestSync (/srv/libraries/dart-sass-test/node_modules/sass-embedded/dist/lib/src/compile.js:148:24)
    at compileString (/srv/libraries/dart-sass-test/node_modules/sass-embedded/dist/lib/src/compile.js:26:12)
    at Object.renderSync (/srv/libraries/dart-sass-test/node_modules/sass-embedded/dist/lib/src/legacy/index.js:36:43)
    at Object.<anonymous> (/srv/libraries/dart-sass-test/index.js:2:26)
    at Module._compile (node:internal/modules/cjs/loader:1103:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1157:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12) {
  status: 1,
  formatted: "Error: TypeError: Cannot read properties of undefined (reading 'url')\n" +
    '\x1B[34m  ╷\x1B[0m\n' +
    "\x1B[34m3 │\x1B[0m @import \x1B[31m'normalize.css/normalize'\x1B[0m;\n" +
    '\x1B[34m  │\x1B[0m \x1B[31m        ^^^^^^^^^^^^^^^^^^^^^^^^^\x1B[0m\n' +
    '\x1B[34m  ╵\x1B[0m\n' +
    '  screen.scss 3:9  root stylesheet',
  toString: [Function: toString],
  line: 3,
  column: 9,
  file: '/srv/libraries/dart-sass-test/screen.scss'
}

The order of the lines in screen.scss matter. The following succeeds:

// screen.scss
@import 'normalize.css/normalize';
@import 'test.scss';

And if you leave out the importer in the options passed to renderSync, it also succeeds. The error is not generated by the importer itself: it never reaches the console.log statement inside the importer.

I believe the error is related to expectingRelativeLoad property inside the LegacyImporterWrapper class. However, I was not able to solve the issue, otherwise I would have created a PR.

@nex3 nex3 self-assigned this Mar 30, 2022
@nex3 nex3 added the bug Something isn't working label Mar 30, 2022
nex3 added a commit to sass/sass-spec that referenced this issue Apr 6, 2022
nex3 added a commit to sass/sass-spec that referenced this issue Apr 6, 2022
nex3 added a commit that referenced this issue Apr 6, 2022
nex3 added a commit to sass/dart-sass that referenced this issue Apr 6, 2022
nex3 added a commit to sass/sass-spec that referenced this issue Apr 6, 2022
@nex3 nex3 closed this as completed in #125 Apr 6, 2022
nex3 added a commit that referenced this issue Apr 6, 2022
nex3 added a commit to sass/dart-sass that referenced this issue Apr 6, 2022
@frederikbosch
Copy link
Author

Thanks @nex3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants