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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Empty bundle generated - transformer-typescript #5049

Closed
aminya opened this issue Aug 22, 2020 · 5 comments · Fixed by #5053
Closed

Empty bundle generated - transformer-typescript #5049

aminya opened this issue Aug 22, 2020 · 5 comments · Fixed by #5053

Comments

@aminya
Copy link
Contributor

aminya commented Aug 22, 2020

🐛 bug report

I am trying to bundle a simple Atom package using parcel and typescript-transformer. However, the resulting bundle is just an empty JavaScript file.

This is the console output using parcel@next

console: (node:53616) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 17 error listeners added to [WriteStream]. Use emitter.setMaxListeners() to increase limit
(Use `node --trace-warnings ...` to show where the warning was created)
console: (node:53616) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 17 close listeners added to [WriteStream]. Use emitter.setMaxListeners() to increase limit
 Built in 4.90s

dist\main.js    34 B    734ms

Using the parcel@nightly a different error is thrown. (atom-package-deps is just a simple cjs package that is imported using dynamic import.)

× Build failed.
@parcel/packager-js: No reachable bundle found containing node_modulesatom-package-depslibindex.js
Error: No reachable bundle found containing node_modules\atom-package-deps\lib\index.js
    at addBundleImport (C:\Users\aminy\Documents\GitHub\JavaScript\@atom-ide-community\atom-ide-template\node_modules\@parcel\scope-hoisting\lib\link.js:346:13)
    at CallExpression (C:\Users\aminy\Documents\GitHub\JavaScript\@atom-ide-community\atom-ide-template\node_modules\@parcel\scope-hoisting\lib\link.js:437:20)
    at NodePath._call (C:\Users\aminy\Documents\GitHub\JavaScript\@atom-ide-community\atom-ide-template\node_modules\@babel\traverse\lib\path\context.js:55:20)
    at NodePath.call (C:\Users\aminy\Documents\GitHub\JavaScript\@atom-ide-community\atom-ide-template\node_modules\@babel\traverse\lib\path\context.js:42:17)
    at NodePath.visit (C:\Users\aminy\Documents\GitHub\JavaScript\@atom-ide-community\atom-ide-template\node_modules\@babel\traverse\lib\path\context.js:92:31)
    at TraversalContext.visitQueue (C:\Users\aminy\Documents\GitHub\JavaScript\@atom-ide-community\atom-ide-template\node_modules\@babel\traverse\lib\context.js:112:16)
    at TraversalContext.visitSingle (C:\Users\aminy\Documents\GitHub\JavaScript\@atom-ide-community\atom-ide-template\node_modules\@babel\traverse\lib\context.js:84:19)
    at TraversalContext.visit (C:\Users\aminy\Documents\GitHub\JavaScript\@atom-ide-community\atom-ide-template\node_modules\@babel\traverse\lib\context.js:140:19)
    at Function.traverse.node (C:\Users\aminy\Documents\GitHub\JavaScript\@atom-ide-community\atom-ide-template\node_modules\@babel\traverse\lib\index.js:82:17)
    at NodePath.visit (C:\Users\aminy\Documents\GitHub\JavaScript\@atom-ide-community\atom-ide-template\node_modules\@babel\traverse\lib\path\context.js:99:18)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! atom-ide-template@0.1.0 build: `cross-env NODE_ENV=production parcel build --target main src/main.ts`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the atom-ide-template@0.1.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\aminy\AppData\Roaming\npm-cache\_logs\2020-08-22T08_56_35_181Z-debug.log

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

The full example is already uploaded here for you to try: https://github.com/atom-ide-community/atom-ide-template/tree/parcel

but if you prefer making your own project

.parcelrc

{
  "extends": "@parcel/config-default",
  "transformers": {
    "*.{ts,tsx}": ["@parcel/transformer-typescript-tsc"]
  }
}

package.json -> targets:

  "targets": {
    "main": {
      "context": "electron-renderer",
      "engines": {
        "electron": ">=5.x"
      },
      "includeNodeModules": {
        "atom": false,
        "electron": false,
        "coffee-script": false
      },
      "outputFormat": "commonjs",
      "isLibrary": true
    }
  },

build script:

    "build": "cross-env NODE_ENV=production parcel build --target main src/main.ts",

tsconfig

{
  "compilerOptions": {
    "strict": true,
    "strictNullChecks": true,
    "noUnusedLocals": true,
    "noUnusedParameters": true,
    "noImplicitReturns": true,
    "noImplicitAny": true,
    "noImplicitThis": true,
    "noFallthroughCasesInSwitch": true,
    "declaration": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "incremental": true,
    "inlineSourceMap": true,
    "inlineSources": true,
    "preserveSymlinks": true,
    "removeComments": true,
    "jsx": "react",
    "jsxFactory": "etch.dom",
    "lib": ["ES2018", "dom"],
    "target": "ES2018",
    "allowJs": true,
    "esModuleInterop": true,
    "module": "commonjs",
    "moduleResolution": "node",
    "importHelpers": false,
    "outDir": "../dist"
  },
  "compileOnSave": false
}

🤔 Expected Behavior

Bundle the package.

😯 Current Behavior

See the above bug-report description.

💁 Possible Solution

🔦 Context

💻 Code Sample

https://github.com/atom-ide-community/atom-ide-template/tree/parcel

🌍 Your Environment

Software Version(s)
Parcel ^2.0.0-beta.1 or 2.0.0-nightly.377
@parcel/transformer-typescript-tsc ^2.0.0-beta.1 or 2.0.0-nightly.379
Node 14.8.0
npm/Yarn 6.14.7
Operating System Win 10
@aminya
Copy link
Contributor Author

aminya commented Aug 23, 2020

Building with --no-scope-hoist solves the issue! I think this is an edge case in which scope hoisting does not work.

cc: @mischnic @DeMoorJasper

@mischnic
Copy link
Member

mischnic commented Aug 23, 2020

I've just opened a PR: #5053. It's not really related to scope hoisting.

You can also try this already by adding these changes to your .parcelrc: https://github.com/parcel-bundler/parcel/pull/5053/files#diff-89039bac63e920d9ab1ea1bdf8d794ba (so adding a runtime: key with these two electron lines)

@MaffooBristol
Copy link

I've had this issue but outside of Electron. It just randomly doesn't like one file...!

@aminya
Copy link
Contributor Author

aminya commented Feb 3, 2021

Have you tried the last nightly?

There was also an issue with the cache.
#5656

@MaffooBristol
Copy link

MaffooBristol commented Feb 3, 2021

Hello!

I have opened a specific issue ticket for it: #5770

Unfortunately I can't really test the nightly because it forces postcss@^8 and I have a load of other dependencies that are all stuck at postcss@^7

Edit: re cache, I've been blitzing the .cache and dist folders continuously

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

Successfully merging a pull request may close this issue.

4 participants