Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Support browser field spec -- node-resolve plugin should be first #67

Closed
katyo opened this issue Mar 19, 2018 · 2 comments
Closed

Support browser field spec -- node-resolve plugin should be first #67

katyo opened this issue Mar 19, 2018 · 2 comments
Labels
kind: support Asking for support with something or a specific use case problem: plugin order The plugin order in this issue seems incompatible. See the "Compatibility" section in the README problem: stale Issue has not been responded to in some time scope: integration Related to an integration, not necessarily to core (but could influence core) solution: out-of-scope This is out of scope for this project

Comments

@katyo
Copy link

katyo commented Mar 19, 2018

What happens and why it is wrong

I imported a module which has different typing for NodeJS and browsers.
It uses this specification to select right js. It works fine for .js but not for .d.ts.
I cannot compile my code for browser because the server-side typings still is used.
I don't sure what the issue is related to this plugin.
May be actually this problem sits in rollup-plugin-node-resolve.

Versions

  • typescript: 2.6.2
  • rollup: 0.57.1
  • rollup-plugin-typescript2: 0.12.0

rollup.config.js

import { join } from 'path';
import nodeResolve from 'rollup-plugin-node-resolve';
import sourceMaps from 'rollup-plugin-sourcemaps';
import typescript from 'rollup-plugin-typescript2';

export default {
    input: `src/client.ts`,
    output: {
        file: 'dist/client.js',
        format: 'cjs',
        sourcemap: true
    },
    plugins: [
        typescript({
            tsconfigOverride: {
                compilerOptions: {
                    module: 'es6'
                }
            }
        }),
        nodeResolve({
            browser: true // use browser field of package.json to resolve
        }),
        sourceMaps(),
    ],
}

tsconfig.json

{
  "compilerOptions": {
    "target": "es5",
    "module": "commonjs",
    "moduleResolution": "node",
    "noImplicitAny": true,
    "sourceMap": true,
    "strictNullChecks": true,
    "declaration": false,
    "removeComments": false,
    "noUnusedLocals": true,
    "importHelpers": true,
    "lib": [
      "dom",
      "es5",
      "es2015.core"
    ]
  }
}
@ezolenko
Copy link
Owner

Which package did you import? How does it specify different typings for different targets? (didn't find anything about typings in the spec)

@ezolenko
Copy link
Owner

ezolenko commented Apr 4, 2018

See #66, you probably have the same problem -- put nodeResolve before typescript.

@ezolenko ezolenko closed this as completed Apr 4, 2018
@agilgur5 agilgur5 added problem: stale Issue has not been responded to in some time problem: plugin order The plugin order in this issue seems incompatible. See the "Compatibility" section in the README labels May 22, 2022
@agilgur5 agilgur5 changed the title The support of browser field spec Support browser field spec -- node-resolve plugin should be first May 22, 2022
@agilgur5 agilgur5 added kind: support Asking for support with something or a specific use case solution: out-of-scope This is out of scope for this project labels May 22, 2022
Repository owner locked as resolved and limited conversation to collaborators May 22, 2022
@agilgur5 agilgur5 added the scope: integration Related to an integration, not necessarily to core (but could influence core) label May 22, 2022
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
kind: support Asking for support with something or a specific use case problem: plugin order The plugin order in this issue seems incompatible. See the "Compatibility" section in the README problem: stale Issue has not been responded to in some time scope: integration Related to an integration, not necessarily to core (but could influence core) solution: out-of-scope This is out of scope for this project
Projects
None yet
Development

No branches or pull requests

3 participants