rsnext/test
Shu Ding b4a5663c5f
optimize_barrel SWC transform and new optimizePackageImports config (#54572)
## Implementation

Base on #54530, we're implementing a `optimize_barrel` transform to
optimize barrel files to only export the names we need. If the
transformed file isn't a "barrel file", we just re-export the names from
it without any transformation.

Take `lucide-react` as an example, with #54530 we are able to transform

```js
import { IceCream } from 'lucide-react'
```

to 

```js
import { IceCream } from '__barrel_optimize__?names=IceCream!=!lucide-react?__barrel_optimize_noop__=IceCream'
```

And then, we apply that new request with a new Webpack module rule to
use the SWC loader with option `optimizeBarrelExports: ['IceCream']`,
which eventually got passed to this new `optimize_barrel` transform and
does the optimization.

## Notes

We'll have to add a new `getModularizeImportAliases` alias list to map
`lucide-react` to the ESM version, as we have the `['main', 'module']`
resolve order for the server compiler. Otherwise this optimization
doesn't work in that compiler.

There's no e2e test added because it's already covered by the
`modularize-imports` test as we removed the default `lucide-react`
transform rules and it still works.

We'll need to test other libs before migrating them to the new
`optimizePackageImports` option.

---

Closes #54571, closes #53605, closes #53789, closes #53894, closes
#54063.
2023-08-25 22:29:39 +02:00
..
.stats-app fix: minimum node version 16.14.0 (#54331) 2023-08-22 08:58:53 +00:00
__mocks__ [edge] bump @edge-runtime/* package suite (#49092) 2023-05-31 08:03:20 +00:00
development optimize_barrel SWC transform and new optimizePackageImports config (#54572) 2023-08-25 22:29:39 +02:00
e2e fix(DX): More precise error messages for export const config deprecation (#54492) 2023-08-25 16:25:15 +00:00
examples feat(cli): introduce --tailwind flag (#46927) 2023-03-16 16:06:27 +01:00
integration fix resolve routes behavior when matching a dynamic segment (#54539) 2023-08-25 02:14:09 +00:00
lib fix: improve error message when output: export in app router (#54202) 2023-08-21 14:45:00 +00:00
production Fix failing TS test from new release (#54523) 2023-08-24 11:36:38 -07:00
unit Upgrade precompiled ua-parser-js (#54404) 2023-08-22 23:56:05 +00:00
.gitignore ci(workflow): enable test trace upload (#51107) 2023-06-12 17:14:13 +00:00
jest-setup-after-env.ts type check tests (and convert next-test-utils.js to ts) (#51071) 2023-06-23 17:42:50 +00:00
jest.d.ts refactor smooth scroll bailout logic in app navigations (#53186) 2023-07-27 14:39:51 +00:00
readme.md refactor: split up CONTRIBUTING.md (#40515) 2022-09-16 14:54:58 -07:00
test-file.txt
turbopack-tests-manifest.js enable more test cases for next.rs api (#53670) 2023-08-07 15:17:23 +02:00

See Testing for more information on how you can run/write/debug tests for Next.js.