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

<script> tags of type application/json are breaking production builds #1230

Closed
thescientist13 opened this issue May 17, 2024 · 0 comments · Fixed by #1231
Closed

<script> tags of type application/json are breaking production builds #1230

thescientist13 opened this issue May 17, 2024 · 0 comments · Fixed by #1231
Assignees
Labels
bug Something isn't working CLI v0.29.4
Milestone

Comments

@thescientist13
Copy link
Member

thescientist13 commented May 17, 2024

Summary

This was brought up in Slack, in that if you add a script tag of type="application/json"

<html>
  <head>
    <script type="application/json">
      {"message": "calmer than you are"}
     </script>
  </head>
  <!-- ... --->
</html>

it will cause a build failure for Rollup / acorn, and was able to reproduce in one of the basic Greenwood test cases

  SyntaxError: Unexpected token (2:16)
    at pp$4.raise (file:///Users/owenbuckley/Workspace/project-evergreen/greenwood/node_modules/rollup/dist/es/shared/rollup.js:19420:13)
    at pp$9.unexpected (file:///Users/owenbuckley/Workspace/project-evergreen/greenwood/node_modules/rollup/dist/es/shared/rollup.js:16714:8)
    at pp$9.semicolon (file:///Users/owenbuckley/Workspace/project-evergreen/greenwood/node_modules/rollup/dist/es/shared/rollup.js:16691:66)
    at pp$8.parseExpressionStatement (file:///Users/owenbuckley/Workspace/project-evergreen/greenwood/node_modules/rollup/dist/es/shared/rollup.js:17174:8)
    at pp$8.parseStatement (file:///Users/owenbuckley/Workspace/project-evergreen/greenwood/node_modules/rollup/dist/es/shared/rollup.js:16907:24)
    at pp$8.parseBlock (file:///Users/owenbuckley/Workspace/project-evergreen/greenwood/node_modules/rollup/dist/es/shared/rollup.js:17190:21)
    at pp$8.parseStatement (file:///Users/owenbuckley/Workspace/project-evergreen/greenwood/node_modules/rollup/dist/es/shared/rollup.js:16872:36)
    at pp$8.parseTopLevel (file:///Users/owenbuckley/Workspace/project-evergreen/greenwood/node_modules/rollup/dist/es/shared/rollup.js:16771:21)
    at Parser.parse (file:///Users/owenbuckley/Workspace/project-evergreen/greenwood/node_modules/rollup/dist/es/shared/rollup.js:16543:15)
    at Function.parse (file:///Users/owenbuckley/Workspace/project-evergreen/greenwood/node_modules/rollup/dist/es/shared/rollup.js:16593:35) {
  pos: 17,
  loc: Position { line: 2, column: 16 },
  raisedAt: 18,
  code: 'PLUGIN_ERROR',
  plugin: 'greenwood-import-meta-url',
  hook: 'transform',
  id: '/Users/owenbuckley/Workspace/project-evergreen/greenwood/packages/cli/test/cases/build.default.workspace-javascript-css/.greenwood/1911554461.js',
  watchFiles: [
    '/Users/owenbuckley/Workspace/project-evergreen/greenwood/packages/cli/test/cases/build.default.workspace-javascript-css/.greenwood/481423853.js',
    '/Users/owenbuckley/Workspace/project-evergreen/greenwood/packages/cli/test/cases/build.default.workspace-javascript-css/.greenwood/1165792367.js',
    '/Users/owenbuckley/Workspace/project-evergreen/greenwood/packages/cli/test/cases/build.default.workspace-javascript-css/.greenwood/439078047.js',
    '/Users/owenbuckley/Workspace/project-evergreen/greenwood/packages/cli/test/cases/build.default.workspace-javascript-css/.greenwood/2110337203.js',
    '/Users/owenbuckley/Workspace/project-evergreen/greenwood/packages/cli/test/cases/build.default.workspace-javascript-css/.greenwood/1911554461.js',
    '/Users/owenbuckley/Workspace/project-evergreen/greenwood/packages/cli/test/cases/build.default.workspace-javascript-css/.greenwood/758806547.js',
    '/Users/owenbuckley/Workspace/project-evergreen/greenwood/packages/cli/test/cases/build.default.workspace-javascript-css/src/scripts/other.js',
    '/Users/owenbuckley/Workspace/project-evergreen/greenwood/packages/cli/test/cases/build.default.workspace-javascript-css/src/scripts/non-module.js',
    '/Users/owenbuckley/Workspace/project-evergreen/greenwood/packages/cli/test/cases/build.default.workspace-javascript-css/src/scripts/popup.js'
  ]
}
  

Details

Irony is, this is actually solved on the v0.30.0-alpha.0 line but I snuck it into 82460ea#diff-1db487262eefc65529b67d5d3b1b1c040f9f0cb880d281965d61b11c5acaba4b (I got greedy and should have really made it its own bug) but since that release line is still a WIP with a couple heavy breaking changes, I think we should backport it. (and I didn't write any test cases, shame on me 😭 )

@thescientist13 thescientist13 added bug Something isn't working CLI labels May 17, 2024
@thescientist13 thescientist13 added this to the 1.0 milestone May 17, 2024
@thescientist13 thescientist13 self-assigned this May 17, 2024
@thescientist13 thescientist13 changed the title script tags of application/json type are breaking production builds <script> tags of type application/json are breaking production builds May 17, 2024
@github-project-automation github-project-automation bot moved this from 🏗 In progress to ✅ Done in [Greenwood] Phase 9 - Standards and Conventions May 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working CLI v0.29.4
Projects
No open projects
Development

Successfully merging a pull request may close this issue.

1 participant