Skip to content

[!] Error: Unexpected token (Note that you need plugins to import files that are not JavaScript) #1626

@East-Apollo

Description

@East-Apollo
  • Rollup Plugin Name: @rollup/plugin-typescript
  • Rollup Plugin Version: 8.5.0
  • Rollup Version: 2.79.1
  • Operating System (or Browser): macOsx
  • Node Version: 14.16.0
  • Link to reproduction (⚠️ read below):

Expected Behavior

There are two sub projects in my project
/packages/A/src/**
/packages/shared/src/**

I referenced the shared project packages.json configuration in Project A as follows:
"devDependencies": {
"B": "workspace:*",
}

Project A refers to a method from Project shared, and I hope to build it normally

/projects/A/src/A.ts
/projects/A/rollup.config.js

/projects/shared/src/somemod.ts

// A.ts
import {theAnswer} from "shared/src/somemod";
console.log(theAnswer);

When I run the build in /projects/A/, the build failes with the described error.
[!] Error: Unexpected token (Note that you need plugins to import files that are not JavaScript)

Actual Behavior

During the actual process of building and packaging, I was constantly prompted:
[!] Error: Unexpected token (Note that you need plugins to import files that are not JavaScript)

I have already configured the relevant plugins and it is normal to directly include this method in project A. However, I envision a directory for storing public methods.

How can I solve this problem

Additional Information

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions