{"id":17402353,"url":"https://github.com/malash/linaria-issue-1382","last_synced_at":"2025-03-27T22:29:16.472Z","repository":{"id":207555109,"uuid":"719534385","full_name":"malash/linaria-issue-1382","owner":"malash","description":null,"archived":false,"fork":false,"pushed_at":"2023-11-17T08:03:25.000Z","size":55,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-02T00:44:57.909Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://github.com/callstack/linaria/issues/1382","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/malash.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-11-16T11:25:37.000Z","updated_at":"2023-11-16T12:00:53.000Z","dependencies_parsed_at":"2024-12-06T22:26:32.561Z","dependency_job_id":"c9413d91-124d-474b-9458-3e8237c2713f","html_url":"https://github.com/malash/linaria-issue-1382","commit_stats":{"total_commits":4,"total_committers":1,"mean_commits":4.0,"dds":0.0,"last_synced_commit":"06ba6a72a6315e6c8913a6431e33c3e62131c206"},"previous_names":["malash/linaria-bad-case-babel"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/malash%2Flinaria-issue-1382","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/malash%2Flinaria-issue-1382/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/malash%2Flinaria-issue-1382/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/malash%2Flinaria-issue-1382/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/malash","download_url":"https://codeload.github.com/malash/linaria-issue-1382/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245934134,"owners_count":20696385,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-16T17:26:26.129Z","updated_at":"2025-03-27T22:29:16.439Z","avatar_url":"https://github.com/malash.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Bad case demo for Linaria babel preset\n\n## How to run\n\n```bash\nyarn\nyarn start\n```\n\n## Bad case\n\nYou should checkout the `master` branch. The folder structure looks like this:\n\n```\n├── package.json\n├── src\n│   └── index.ts\n└── yarn.lock\n```\n\nThe `src/index.ts` file contains only one line: `const a: number = 1;`.\n\nThe `yarn start` command will run `babel --presets=@babel/typescript,@linaria src/index.ts` and output will be:\n\n```\nyarn run v1.22.19\n$ babel --presets=@babel/typescript,@linaria src/index.ts\nSyntaxError: /Users/malash/Projects/test-goji/src/index.ts: /Users/malash/Projects/test-goji/src/index.ts: Missing initializer in const declaration. (1:7)\n\n\u003e 1 | const a: number = 1;\n    |        ^\n  2 |\n    at constructor (/Users/malash/Projects/test-goji/node_modules/@babel/parser/lib/index.js:356:19)\n    at Parser.raise (/Users/malash/Projects/test-goji/node_modules/@babel/parser/lib/index.js:3223:19)\n    at Parser.parseVar (/Users/malash/Projects/test-goji/node_modules/@babel/parser/lib/index.js:13267:16)\n    at Parser.parseVarStatement (/Users/malash/Projects/test-goji/node_modules/@babel/parser/lib/index.js:13100:10)\n    at Parser.parseStatementContent (/Users/malash/Projects/test-goji/node_modules/@babel/parser/lib/index.js:12683:23)\n    at Parser.parseStatementLike (/Users/malash/Projects/test-goji/node_modules/@babel/parser/lib/index.js:12588:17)\n    at Parser.parseModuleItem (/Users/malash/Projects/test-goji/node_modules/@babel/parser/lib/index.js:12565:17)\n    at Parser.parseBlockOrModuleBlockBody (/Users/malash/Projects/test-goji/node_modules/@babel/parser/lib/index.js:13189:36)\n    at Parser.parseBlockBody (/Users/malash/Projects/test-goji/node_modules/@babel/parser/lib/index.js:13182:10)\n    at Parser.parseProgram (/Users/malash/Projects/test-goji/node_modules/@babel/parser/lib/index.js:12464:10)\n    at Parser.parseTopLevel (/Users/malash/Projects/test-goji/node_modules/@babel/parser/lib/index.js:12454:25)\n    at Parser.parse (/Users/malash/Projects/test-goji/node_modules/@babel/parser/lib/index.js:14376:10)\n    at parse (/Users/malash/Projects/test-goji/node_modules/@babel/parser/lib/index.js:14417:38)\n    at parser (/Users/malash/Projects/test-goji/node_modules/@babel/core/lib/parser/index.js:41:34)\n    at parser.next (\u003canonymous\u003e)\n    at parse (/Users/malash/Projects/test-goji/node_modules/@babel/core/lib/parse.js:25:37)\n    at parse.next (\u003canonymous\u003e)\n    at evaluateSync (/Users/malash/Projects/test-goji/node_modules/gensync/index.js:251:28)\n    at sync (/Users/malash/Projects/test-goji/node_modules/gensync/index.js:89:14)\n    at stopHiding - secret - don't use this - v1 (/Users/malash/Projects/test-goji/node_modules/@babel/core/lib/errors/rewrite-stack-trace.js:47:12)\n    at Object.parseSync (/Users/malash/Projects/test-goji/node_modules/@babel/core/lib/parse.js:40:72)\n    at parseFile (/Users/malash/Projects/test-goji/node_modules/@linaria/babel-preset/lib/transform/Entrypoint.helpers.js:35:29)\n    at /Users/malash/Projects/test-goji/node_modules/@linaria/babel-preset/lib/transform/Entrypoint.helpers.js:129:48\n    at EventEmitter.perf (/Users/malash/Projects/test-goji/node_modules/@linaria/utils/lib/EventEmitter.js:45:20)\n    at getOrParse (/Users/malash/Projects/test-goji/node_modules/@linaria/babel-preset/lib/transform/Entrypoint.helpers.js:129:24)\n    at get ast [as ast] (/Users/malash/Projects/test-goji/node_modules/@linaria/babel-preset/lib/transform/Entrypoint.helpers.js:148:14)\n    at BaseAction.explodeReexports (/Users/malash/Projects/test-goji/node_modules/@linaria/babel-preset/lib/transform/generators/explodeReexports.js:39:68)\n    at explodeReexports.next (\u003canonymous\u003e)\n    at /Users/malash/Projects/test-goji/node_modules/@linaria/babel-preset/lib/transform/actions/BaseAction.js:66:78\n    at EventEmitter.action (/Users/malash/Projects/test-goji/node_modules/@linaria/utils/lib/EventEmitter.js:25:22)\n    at BaseAction.emitAction (/Users/malash/Projects/test-goji/node_modules/@linaria/babel-preset/lib/transform/actions/BaseAction.js:131:39)\n    at nextFn (/Users/malash/Projects/test-goji/node_modules/@linaria/babel-preset/lib/transform/actions/BaseAction.js:66:32)\n    at processNext (/Users/malash/Projects/test-goji/node_modules/@linaria/babel-preset/lib/transform/actions/BaseAction.js:111:28)\n    at Object.next (/Users/malash/Projects/test-goji/node_modules/@linaria/babel-preset/lib/transform/actions/BaseAction.js:120:9)\n    at syncActionRunner (/Users/malash/Projects/test-goji/node_modules/@linaria/babel-preset/lib/transform/actions/actionRunner.js:68:95)\n    at syncActionRunner (/Users/malash/Projects/test-goji/node_modules/@linaria/babel-preset/lib/transform/actions/actionRunner.js:75:22)\n    at syncActionRunner (/Users/malash/Projects/test-goji/node_modules/@linaria/babel-preset/lib/transform/actions/actionRunner.js:75:22)\n    at transformSync (/Users/malash/Projects/test-goji/node_modules/@linaria/babel-preset/lib/transform.js:51:55)\n    at PluginPass.pre (/Users/malash/Projects/test-goji/node_modules/@linaria/babel-preset/lib/plugins/babel-transform.js:42:36)\n    at transformFile (/Users/malash/Projects/test-goji/node_modules/@babel/core/lib/transformation/index.js:73:27)\n    at transformFile.next (\u003canonymous\u003e)\n    at run (/Users/malash/Projects/test-goji/node_modules/@babel/core/lib/transformation/index.js:24:12)\n    at run.next (\u003canonymous\u003e)\n    at Function.\u003canonymous\u003e (/Users/malash/Projects/test-goji/node_modules/@babel/core/lib/transform-file.js:27:33)\n    at Generator.next (\u003canonymous\u003e)\n    at step (/Users/malash/Projects/test-goji/node_modules/gensync/index.js:261:32)\n    at /Users/malash/Projects/test-goji/node_modules/gensync/index.js:273:13\n    at async.call.result.err.err (/Users/malash/Projects/test-goji/node_modules/gensync/index.js:223:11)\n    at /Users/malash/Projects/test-goji/node_modules/gensync/index.js:189:28\n    at FSReqCallback.readFileAfterClose [as oncomplete] (node:internal/fs/read_file_context:68:3) {\n  code: 'BABEL_PARSE_ERROR',\n  reasonCode: 'DeclarationMissingInitializer',\n  loc: Position { line: 1, column: 7, index: 7 },\n  pos: 7\n}\nerror Command failed with exit code 1.\ninfo Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.\n```\n\n## Good case\n\nIf you want to see the good case, you should checkout the `good-case` branch. The folder structure looks like this:\n\n```\n├── package.json\n|── babel.config.json\n├── src\n│   └── index.ts\n└── yarn.lock\n```\n\nAs you can see, the only difference is that I added a `babel.config.json` file with the following content:\n\n```json\n{\n  \"presets\": [\"@babel/typescript\", \"@linaria\"]\n}\n```\n\nand now the `yarn start` command will run `babel src/index.ts` and output will be:\n\n```\nyarn run v1.22.19\n$ babel src/index.ts\nconst a = 1;\n\n✨  Done in 0.26s.\n```\n\n## Linaria 2\n\nThis bug is not present in Linaria 2. If you want to see the good case, you should checkout the `linaria-2` branch.\n\n## Conclusion\n\nI have no idea why this is happening, but I think it's a bug in the `@linaria/babel-preset` package. As I understand it, the `@linaria/babel-preset` package should be able to work with the `babel.config.json` file or `babel --presets` option, but it doesn't.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmalash%2Flinaria-issue-1382","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmalash%2Flinaria-issue-1382","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmalash%2Flinaria-issue-1382/lists"}