New issue

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

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

Already on GitHub? Sign in to your account

`interface` is a reserved word in node_modules #9306

Open
DrogoNevets opened this Issue Jan 9, 2019 · 10 comments

Comments

Projects
None yet
3 participants
@DrogoNevets
Copy link

DrogoNevets commented Jan 9, 2019

Bug Report

Current Behavior
Babel works fine with all files in the src/ directory and I can use the keyword interface

however when i try importing a ts class from node_modules I get the following error

ERROR in ./node_modules/workflow-engine/src/models/Document.ts
Module build failed (from ./node_modules/babel-loader/lib/index.js):
SyntaxError: C:\projects\app-fixed-assets-disposal\node_modules\workflow-engine\src\models\Document.ts: interface is a reserved word in strict mode (8:0)

Input Code

interface DocumentWorkflowCurrentState {
    position: number;
    name: string;
}

Expected behavior/code
It should transpile nicely and allow me to import the class and extend it

Babel Configuration (.babelrc, package.json, cli command)

{
  "presets": [
    "@babel/typescript",
    [
      "@babel/env",
      {
        "modules": false
      }
    ]
  ],
  "plugins": [
    "@babel/plugin-proposal-class-properties"
  ]
}

Environment

  • Babel version(s): [e.g. v6.0.0, v7.0.0-beta.34]
  • Node/npm version: 8.12.0
  • How you are using Babel:webpack-loader
@babel-bot

This comment has been minimized.

Copy link
Collaborator

babel-bot commented Jan 9, 2019

Hey @DrogoNevets! We really appreciate you taking the time to report an issue. The collaborators
on this project attempt to help as many people as possible, but we're a limited number of volunteers,
so it's possible this won't be addressed swiftly.

If you need any help, or just have general Babel or JavaScript questions, we have a vibrant Slack
community
that typically always has someone willing to help. You can sign-up here
for an invite.

@cameron-martin

This comment has been minimized.

Copy link
Contributor

cameron-martin commented Jan 9, 2019

Most likely you have webpack configured to not run files in node_modules through babel-loader. Posting your webpack config would help.

@DrogoNevets

This comment has been minimized.

Copy link

DrogoNevets commented Jan 10, 2019

hi @cameron-martin sure thing, see below.
Though I thought the same so I removed the exclude, still same issue though

const path = require('path'),
    CaseSensitivePathsPlugin = require('case-sensitive-paths-webpack-plugin');

module.exports = {
    entry: './server.ts',
    mode: 'development',
    target: 'node',
    devtool: 'source-map',
    output: {
        filename: 'server.js',
        path: path.resolve(__dirname, 'dist')
    },
    plugins: [
        new CaseSensitivePathsPlugin()
    ],
    module: {
        rules: [
            {
                test: /\.ts?$/,
                use: ['babel-loader']
            },
        ]
    },
    resolve: {
        extensions: ['.tsx', '.ts', '.js']
    },
    optimization: {
        usedExports: true
    }
};
@cameron-martin

This comment has been minimized.

Copy link
Contributor

cameron-martin commented Jan 10, 2019

Do you have a babelrc file in ./node_modules/workflow-engine?

@DrogoNevets

This comment has been minimized.

Copy link

DrogoNevets commented Jan 11, 2019

oooo interesting.....yes i do, but the workflow-engine project compiles fine

@cameron-martin

This comment has been minimized.

Copy link
Contributor

cameron-martin commented Jan 11, 2019

I'm wondering whether it's an issue with the new behaviour of merging config files in Babel 7.

@DrogoNevets

This comment has been minimized.

Copy link

DrogoNevets commented Jan 11, 2019

anyway to test it? I had that theory vaguely and tried writing a babel.config.js file but kinda completely broke the world!

@cameron-martin

This comment has been minimized.

Copy link
Contributor

cameron-martin commented Jan 11, 2019

Try removing the babelrc file in ./node_modules/workflow-engine/ then build?

@DrogoNevets

This comment has been minimized.

Copy link

DrogoNevets commented Jan 14, 2019

Sorry for delay, left laptop in the office. I have tried and alas, same issue......

@cameron-martin

This comment has been minimized.

Copy link
Contributor

cameron-martin commented Jan 14, 2019

I don't have any other ideas with the available information. If it's possible to create a repo which reproduces it and link it here then that would be of great help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment