rsnext/packages
Donny/강동윤 82639520d3
feat: Pass module: "unknown" to SWC minfiier (#66817)
### What?

Pass `module: "unknown"` to the minifier.

### Why?

It can minify both a module and a script. `module: "unknown"` lets the
parser to detect the type of the program.

The problematic library is `react-pdf` and next.js currently errors with

```
Failed to compile.

static/media/pdf.worker.1f09ce21.mjs from Terser
  x 'import', and 'export' cannot be used outside of module code
       ,-[56104:1]
 56104 | const pdfjsBuild = "0cec64437";
 56105 | 
 56106 | var __webpack_exports__WorkerMessageHandler = __webpack_exports__.WorkerMessageHandler;
 56107 | export { __webpack_exports__WorkerMessageHandler as WorkerMessageHandler };
       : ^^^^^^
 56108 | 
 56109 | //# sourceMappingURL=pdf.worker.mjs.map
       `----

Caused by:
    0: failed to parse input file
    1: Syntax Error
Error: 
  x 'import', and 'export' cannot be used outside of module code
       ,-[56104:1]
```

### How?

Related:
https://github.com/vercel/next.js/discussions/30237#discussioncomment-9735075
2024-07-03 09:57:30 +09:00
..
create-next-app v15.0.0-canary.52 2024-07-02 23:22:46 +00:00
eslint-config-next v15.0.0-canary.52 2024-07-02 23:22:46 +00:00
eslint-plugin-next v15.0.0-canary.52 2024-07-02 23:22:46 +00:00
font v15.0.0-canary.52 2024-07-02 23:22:46 +00:00
next feat: Pass module: "unknown" to SWC minfiier (#66817) 2024-07-03 09:57:30 +09:00
next-bundle-analyzer v15.0.0-canary.52 2024-07-02 23:22:46 +00:00
next-codemod v15.0.0-canary.52 2024-07-02 23:22:46 +00:00
next-env v15.0.0-canary.52 2024-07-02 23:22:46 +00:00
next-mdx v15.0.0-canary.52 2024-07-02 23:22:46 +00:00
next-plugin-storybook v15.0.0-canary.52 2024-07-02 23:22:46 +00:00
next-polyfill-module v15.0.0-canary.52 2024-07-02 23:22:46 +00:00
next-polyfill-nomodule v15.0.0-canary.52 2024-07-02 23:22:46 +00:00
next-swc v15.0.0-canary.52 2024-07-02 23:22:46 +00:00
react-refresh-utils v15.0.0-canary.52 2024-07-02 23:22:46 +00:00
third-parties v15.0.0-canary.52 2024-07-02 23:22:46 +00:00