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

Switch parse-srcset to npm published version #13536

Merged
merged 7 commits into from Sep 27, 2022

Conversation

fisker
Copy link
Member

@fisker fisker commented Sep 26, 2022

Description

Ref #13519 (comment)

I published @fisker/parse-srcset 2 years ago, when I try to use yarn2 in this repo #9569.

@alexander-akait I heard you've rewritten this module? Have you published it?

Checklist

  • I’ve added tests to confirm my change works.
  • (If changing the API or CLI) I’ve documented the changes I’ve made (in the docs/ directory).
  • (If the change is user-facing) I’ve added my changes to changelog_unreleased/*/XXXX.md file following changelog_unreleased/TEMPLATE.md.
  • I’ve read the contributing guidelines.

Try the playground for this PR

@thorn0
Copy link
Member

thorn0 commented Sep 26, 2022

There is also this issue about that package: #12560
Apparently, the UMD wrapper causes trouble. Could you remove it?

@fisker
Copy link
Member Author

fisker commented Sep 26, 2022

I just forked ikatyang's, if we are going to make changes, I'd like to transform to prettier org, so you can also edit. Let me publish under @prettier too?

@thorn0
Copy link
Member

thorn0 commented Sep 26, 2022

👍 I wanted to propose the same.

@fisker
Copy link
Member Author

fisker commented Sep 26, 2022

BTW: It seems ikatyang is not active on github. I think we should try contact him and ask him to transfer repos like yaml-unist-parser prettier/yaml-unist-parser#279, angular-estree-parser prettier/angular-estree-parser#221

@fisker fisker marked this pull request as draft September 26, 2022 14:24
@fisker
Copy link
Member Author

fisker commented Sep 26, 2022

Do you know what's wrong? https://github.com/prettier/prettier/actions/runs/3128719547/jobs/5076912809#step:6:5

@thorn0
Copy link
Member

thorn0 commented Sep 26, 2022

Looks like TS doesn't understand exports in package.json and doesn't know how to resolve this module. I'll look into this.

@sosukesuzuki

This comment was marked as resolved.

@thorn0
Copy link
Member

thorn0 commented Sep 26, 2022

We need to change tsconfig.json:

{
    "compilerOptions": {
        "module": "nodenext",
    }
}

https://www.typescriptlang.org/docs/handbook/esm-node.html

@sosukesuzuki
Copy link
Member

We need to change tsconfig.json:

I've tried to set "module": "nodenext",, but errors:

yarn lint:typecheck
src/common/load-plugins.js:10:46 - error TS1470: The 'import.meta' meta-property is not allowed in files which will build into CommonJS output.

10 const __dirname = path.dirname(fileURLToPath(import.meta.url));
                                                ~~~~~~~~~~~

src/language-html/syntax-attribute.js:1:25 - error TS2307: Cannot find module '@prettier/parse-srcset' or its corresponding type declarations.

1 import parseSrcset from "@prettier/parse-srcset";
                          ~~~~~~~~~~~~~~~~~~~~~~~~

src/language-js/parse/acorn.js:7:31 - error TS1470: The 'import.meta' meta-property is not allowed in files which will build into CommonJS output.

7 const require = createRequire(import.meta.url);
                                ~~~~~~~~~~~

src/language-js/parse/espree.js:7:31 - error TS1470: The 'import.meta' meta-property is not allowed in files which will build into CommonJS output.

7 const require = createRequire(import.meta.url);
                                ~~~~~~~~~~~

src/main/version.evaluate.js:3:31 - error TS1470: The 'import.meta' meta-property is not allowed in files which will build into CommonJS output.

3 const require = createRequire(import.meta.url);
                                ~~~~~~~~~~~


Found 5 errors in 5 files.

Errors  Files
     1  src/common/load-plugins.js:10
     1  src/language-html/syntax-attribute.js:1
     1  src/language-js/parse/acorn.js:7
     1  src/language-js/parse/espree.js:7
     1  src/main/version.evaluate.js:3

@fisker
Copy link
Member Author

fisker commented Sep 26, 2022

👍

@thorn0 thorn0 marked this pull request as ready for review September 26, 2022 16:59
@alexander-akait
Copy link
Member

alexander-akait commented Sep 27, 2022

Sorry for delay, yeah, rewritten by spec, but it is not published, here is code https://github.com/webpack-contrib/html-loader/blob/master/src/utils.js#L20

If someone publishes it I will be glad and help with bugs and improvements (but I don't think we have them, WPT tests passed + a lot of examples)

@fisker
Copy link
Member Author

fisker commented Sep 27, 2022

The original parse-srcset seems tested, I'm fixing prettier/parse-srcset#2.

@fisker fisker merged commit f2c5045 into prettier:next Sep 27, 2022
@fisker fisker deleted the fisker-parse-srcset branch September 27, 2022 08:02
medikoo pushed a commit to medikoo/prettier-elastic that referenced this pull request Feb 5, 2024
Co-authored-by: Georgii Dolzhykov <thorn.mailbox@gmail.com>
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.

Throw Uncaught Error: Mismatched anonymous define() module when using esm/standalone.mjs with RequireJS
4 participants