Skip to content

Comments

Modern api#1012

Merged
alexander-akait merged 28 commits intomasterfrom
modern-api
Feb 14, 2022
Merged

Modern api#1012
alexander-akait merged 28 commits intomasterfrom
modern-api

Conversation

@alexander-akait
Copy link
Member

This PR contains a:

  • bugfix
  • new feature
  • code refactor
  • test update
  • typo fix
  • metadata update

Motivation / Use-Case

#774

Added:

  • added api: "modern" and api: "old"
  • added sass-embedded support

Breaking Changes

No

Additional Info

  • default importer is not implemented for modern API
  • no ability to get webpack loader context in importers

@alexander-akait alexander-akait mentioned this pull request Jan 10, 2022
6 tasks
@codecov
Copy link

codecov bot commented Jan 11, 2022

Codecov Report

Merging #1012 (aa3383a) into master (ff8d078) will decrease coverage by 1.32%.
The diff coverage is 94.87%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1012      +/-   ##
==========================================
- Coverage   95.91%   94.59%   -1.33%     
==========================================
  Files           5        5              
  Lines         294      370      +76     
  Branches       97      138      +41     
==========================================
+ Hits          282      350      +68     
- Misses         11       18       +7     
- Partials        1        2       +1     
Impacted Files Coverage Δ
src/SassError.js 93.33% <85.71%> (-6.67%) ⬇️
src/utils.js 93.97% <94.06%> (-1.55%) ⬇️
src/index.js 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ff8d078...aa3383a. Read the comment docs.

@alexander-akait
Copy link
Member Author

alexander-akait commented Jan 11, 2022

@nex3 I integrated new API and sass-embedded here (just skip tests with own importer) and I think we have a problem on macos, tests work fine on ubuntu/linux and windows, but broken on macos with an error:

SassError: SassError: NoSuchMethodError: method not found: 'map$1$1' (J.getInterceptor$ax(...).map$1$1 is not a function)

I think somewhere is bug in sass (dart), it happens only for modern API - compileStringAsync

You can look at our github actions, if you need more information I can try to debug

@nex3
Copy link
Contributor

nex3 commented Jan 11, 2022

Are you using Jest for your tests? That looks like the sort of issue that's caused by Jest breaking instanceof (jestjs/jest#2549). You can work around it using jest-environment-node-single-context.

@alexander-akait
Copy link
Member Author

@nex3 Thanks, works fine 👍

@alexander-akait
Copy link
Member Author

@nex3 I updated sass-embedded to ^1.0.0-rc.1 (with legacy API supporting), almost all tests are passed, but some not, we have two problems:

  1. Source maps - legacy API return stdin in sources of source map when you use custom importer, I can't find issues related to this problem, but it breaks source maps
  2. In some tests I got:
 Error: TypeError: Cannot read property 'url' of undefined
      ╷
    8 │ @import "~scss/underscore";
      │         ^^^^^^^^^^^^^^^^^^
      ╵
      test/scss/imports.scss 8:9  root stylesheet

Error from sass-embedded itself.

Raw:

 Error: Error: TypeError: Cannot read property 'url' of undefined
      ╷
    8 │ @import ~sass/underscore
      │         ^^^^^^^^^^^^^^^^
      ╵
      test/sass/imports.sass 8:9  root stylesheet
        at handleCompileResponse (/home/evilebottnawi/IdeaProjects/sass-loader/node_modules/sass-embedded/lib/src/compile.ts:304:10)
        at compileRequestAsync (/home/evilebottnawi/IdeaProjects/sass-loader/node_modules/sass-embedded/dist/lib/src/compile.js:102:16)
        at processTicksAndRejections (internal/process/task_queues.js:97:5) {
      status: 1,
      formatted: "Error: TypeError: Cannot read property 'url' of undefined\n" +
        '\u001b[34m  ╷\u001b[0m\n' +
        '\u001b[34m8 │\u001b[0m @import \u001b[31m~sass/underscore\u001b[0m\n' +
        '\u001b[34m  │\u001b[0m \u001b[31m        ^^^^^^^^^^^^^^^^\u001b[0m\n' +
        '\u001b[34m  ╵\u001b[0m\n' +
        '  test/sass/imports.sass 8:9  root stylesheet',
      toString: [Function: toString],
      line: 8,
      column: 9,
      file: '/home/evilebottnawi/IdeaProjects/sass-loader/test/sass/imports.sass'
    }

@alexander-akait
Copy link
Member Author

Also bugs on widows:

SassError: TypeError [ERR_INVALID_FILE_URL_PATH]: File URL path must be absolute, when we have @import '/sass/language.sass' (fine on linux and macos)

And @import 'file:///language' is not resolved on windows

@nex3
Copy link
Contributor

nex3 commented Feb 1, 2022

  1. Source maps - legacy API return stdin in sources of source map when you use custom importer, I can't find issues related to this problem, but it breaks source maps
  2. In some tests I got:
 Error: TypeError: Cannot read property 'url' of undefined
      ╷
    8 │ @import "~scss/underscore";
      │         ^^^^^^^^^^^^^^^^^^
      ╵
      test/scss/imports.scss 8:9  root stylesheet

Error from sass-embedded itself.

Can you provide me with minimal reproductions for these errors? Is the latter error for the legacy API or the new API?

SassError: TypeError [ERR_INVALID_FILE_URL_PATH]: File URL path must be absolute, when we have @import '/sass/language.sass' (fine on linux and macos)

And @import 'file:///language' is not resolved on windows

Same question as above, are these for the legacy API or the new API?

@alexander-akait
Copy link
Member Author

@nex3

Same question as above, are these for the legacy API or the new API?

Legacy API

@alexander-akait alexander-akait merged commit afbe114 into master Feb 14, 2022
@alexander-akait alexander-akait deleted the modern-api branch February 14, 2022 15:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants