Skip to content
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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parcel 2.0.1 Building TS library failed #7411

Closed
christopanayotovvia opened this issue Dec 6, 2021 · 3 comments
Closed

Parcel 2.0.1 Building TS library failed #7411

christopanayotovvia opened this issue Dec 6, 2021 · 3 comments

Comments

@christopanayotovvia
Copy link

christopanayotovvia commented Dec 6, 2021

馃悰 bug report

Following https://parceljs.org/getting-started/library/ to building TS library with types. Simple TS file in src/index.ts. and following package.json config ( see below ). Parcel 2.0.1, Node v16.13.0 , NPM 8.1.0

馃帥 Configuration (.babelrc, package.json, cli command)

// src/index.ts
export function add(a: number, b: number) {
  return a + b;
}
// package.json
{
  "name": "test-library",
  "version": "1.0.0",
  "source": "src/index.ts",
  "main": "dist/main.js",
  "module": "dist/module.js",
  "types": "dist/types.d.ts",
  "scripts": {
    "watch": "parcel watch",
    "build": "parcel build"
  },
  "devDependencies": {
    "@parcel/transformer-typescript-types": "^2.0.1",
    "parcel": "^2.0.1"
  }
}

馃 Expected Behavior

Build proper dist/main.js, dist/module.js and dist/types.d.ts files

馃槸 Current Behavior

Cleans package.json and installs @parcel/transformer-typescript-types as dev dependency. When reverting the package.json file and manually add @parcel/transformer-typescript-types v 2.0.1, it fails with the following error:

parcel build

馃毃 Build failed.

Error: Could not resolve module "wrap-ansi" from "/Users/USER/Desktop/PROJECT_FOLDER/node_modules/@parcel/reporter-cli/lib/CLIReporter.js"

Installing wrap-ansi as dependency or dev dependency does not fix the isse.

馃敠 Context

Currently parcel v 2.0.1 cannot be used to build / distribute library

馃捇 Code Sample

{
  "name": "test-library",
  "version": "1.0.0",
  "source": "src/index.ts",
  "main": "dist/main.js",
  "module": "dist/module.js",
  "types": "dist/types.d.ts",
  "scripts": {
    "watch": "parcel watch",
    "build": "parcel build"
  },
  "devDependencies": {
    "@parcel/transformer-typescript-types": "^2.0.1",
    "parcel": "^2.0.1"
  }
}

And literally any file in src/index.ts

馃實 Your Environment

Software Version(s)
Parcel 2.0.1
Node v16.13.0
npm/Yarn 8.1.0
Operating System OS X
@fattslug
Copy link

fattslug commented Dec 9, 2021

Similar issue, but with the built-in fs module.

$ parcel build
馃毃 Build failed.

@parcel/core: Failed to resolve 'fs' from './PROJECT/src/generator.ts'

  /Users/USER/Development/PROJECT/src/generator.ts:1:16
  > 1 | import fs from 'fs';
  >   |                ^^^^
    2 | 
    3 | import config from '../../config.json';

@parcel/resolver-default: External dependency "fs" is not declared in package.json.

  /Users/USER/Development/PROJECT/package.json:1:1
  > 1 | {
  >   | ^
    2 |   "name": "visualizer-assemble",
    3 |   "version": "10.45.3",

@astegmaier
Copy link
Contributor

I can't repro this with the exact same parcel/node/npm/OS. @christopanayotovvia - can you provide a github repo where you get a consistent repro?

@mischnic
Copy link
Member

Will be fixed in the next release: #7348

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants