huozhi / rollup-preserve-directives

This is a rollup plugin that helps preserve shebang and string directives.
https://npmjs.com/package/rollup-preserve-directives
34 stars 4 forks source link

Should follow the original directives order #6

Closed huozhi closed 1 year ago

huozhi commented 1 year ago

if you have two directives

"use strict"

"use client"

Expected

should output as

"use strict"
"use client"

Observed

"use client"
"use strict"
SukkaW commented 1 year ago

@huozhi What happens with this?

// client/foo.tsx
'use client';
'use strict';

// client/bar.tsx
'use strict';
'use client';

// client/index.tsx
export * from './foo';
export * from './bar';

What should the order of directives in the final bundle be?

huozhi commented 1 year ago

Good example, it’s not doable after multi files bundling. Found it in one file bundling thought could be the snapshot consistent.

But if you’re using bundle everything strategy now usually you only put one directive at entry file cause there’s no code splitting.