Skip to content

Build output is different when building on Windows or Mac #4496

@mabramishvili

Description

@mabramishvili

Rollup Version

2.70.1

Operating System (or Browser)

Windows

Node Version (if applicable)

14.16.1

Link To Reproduction

not available

Expected Behaviour

Seems like on Windows, preserveModulesRoot: 'src' will only work on entry files (files defined in "input"). While on OSX it will work on all files.

I would expect it to be consistent between different environments.

Found this question but there is no working answer:
https://stackoverflow.com/questions/64570174/rollup-preservemodulesroot-not-working-as-expected

Actual Behaviour

I have a build output defined like:

{
  input: 'src/index.ts',
  output: [
    {
      dir: 'dist/cjs',
      format: 'cjs',
      preserveModules: true,
      preserveModulesRoot: 'src',
      sourcemap: true,
      exports: 'named',
    },
    {
      dir: 'dist/esm',
      format: 'esm',
      preserveModules: true,
      sourcemap: true,
      preserveModulesRoot: 'src',
      exports: 'named',
    },
  ],
}

When building on Windows, the output in dist is like:

dist
    -- esm
        --components
        --src
            --components
       index.d.ts
       index.js

esm/components will only include d.ts files and esm/src/components will actually include .js files

When building on OSX, the output in dist is like:

dist
    -- esm
        --components
       index.d.ts
       index.js

notice there is no "src" folder and all files are placed inside esm/components.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions