-
-
Notifications
You must be signed in to change notification settings - Fork 40
Do not set process to undefined #921
Comments
Hi @edusperoni, Thanks for the feedback! If we do not define In other words, the NativeScript app is not a NodeJs environment and for this reason, we are removing this NodeJs specific object. As a workaround, when using P.S. We are thinking about a way of extending the webpack.config in the plugins. When we add this feature in some of the future NativeScript versions, this could be directly handled in the |
Hi @DimitarTachev! Thanks for the time for reviewing this. There are some npm packages that work by checking |
@DimitarTachev - I just actually ran into this myself and this ends up being a breaking change from plain NativeScript (w/o webpack) in one of my plugins. I just tested this, and this worked for me -- instead do this: This actually does work; and does allow other plugins to pollyfil the |
@NathanaelA I suggested the polyfill for "safety" but I actually did not need it ¯\(ツ)/¯ Simply commenting the line That line makes sure webpack will always evaluate |
If you output the keys on However; it does break polyfills like you ran into... After trying multiple things; what actually worked for me was the |
That's really weird behavior, I assumed process was already pointing to |
Hi @NathanaelA, Thanks for your feedback. Setting I've opened a pull request with this change. |
@edusperoni - in an app w/o webpack; But because webpack rewrites all places it sees So what my "hack" does is make webpack rewrite all |
I'm having problems with this in one of my projects that uses typeorm, when I import and use typeorm somewhere I get the error: ReferenceError: process is not defined
System.err:
System.err: StackTrace:
System.err: java.lang.RuntimeException: Unable to create application com.tns.NativeScriptApplication: com.tns.NativeScriptException: Error calling module function
System.err: ReferenceError: process is not defined
System.err: File: (file: node_modules/supports-color/index.js:5:0)
System.err:
System.err: StackTrace:
System.err: ../node_modules/supports-color/index.js(file: node_modules/supports-color/index.js:5:0)
System.err: at __webpack_require__(file: src/webpack/bootstrap:74:0)
System.err: at ../node_modules/chalk/index.js(file: node_modules/chalk/index.js:4:20)
System.err: at __webpack_require__(file: src/webpack/bootstrap:74:0)
System.err: at (file: node_modules/typeorm/browser/platform/PlatformTools.js:1:0)
System.err: at ../node_modules/typeorm/browser/platform/PlatformTools.js(file:///data/data/org.nativescript.ambulanciasbomberos/files/app/vendor.js:327248:30)
System.err: at __webpack_require__(file: src/webpack/bootstrap:74:0)
System.err: at (file: node_modules/typeorm/browser/driver/sqlserver/SqlServerDriver.js:1:0)
System.err: at ../node_modules/typeorm/browser/driver/sqlserver/SqlServerDriver.js(file:///data/data/org.nativescript.ambulanciasbomberos/files/app/vendor.js:311455:30)
System.err: at __webpack_require__(file: src/webpack/bootstrap:74:0)
System.err: at ../node_modules/typeorm/browser/migration/MigrationExecutor.js(file: node_modules/typeorm/browser/migration/MigrationExecutor.js:1:0)
System.err: at __webpack_require__(file: src/webpack/bootstrap:74:0)
System.err: at ../node_modules/typeorm/browser/connection/Connection.js(file: node_modules/typeorm/browser/connection/Connection.js:1:0)
System.err: at __webpack_require__(file: src/webpack/bootstrap:74:0)
System.err: at ../node_modules/typeorm/browser/connection/ConnectionManager.js(file: node_modules/typeorm/browser/connection/ConnectionManager.js:1:0)
System.err: at __webpack_require__(file: src/webpack/bootstrap:74:0)
System.err: at ../node_modules/typeorm/browser/index.js(file: node_modules/typeorm/browser/index.js:1:0)
System.err: at __webpack_require__(file: src/webpack/bootstrap:74:0)
System.err: at (file: src/main.ts:2:106)
System.err: at ./main.ts(file:///data/data/org.nativescript.ambulanciasbomberos/files/app/bundle.js:691:30)
System.err: at __webpack_require__(file: src/webpack/bootstrap:74:0)
System.err: at checkDeferredModules(file: src/webpack/bootstrap:43:0)
System.err: at webpackJsonpCallback(file: src/webpack/bootstrap:30:0)
System.err: at (file:///data/data/org.nativescript.ambulanciasbomberos/files/app/bundle.js:2:57)
System.err: at require(:1:266) |
|
Thank you for your response, my webpack config is the latest and it already has that line. The line in the |
Was my bad, in some of my entities' files I was using |
@darkyelox can u check again as I am facing the same issue even though I have used import {...} from "typeorm/browser" in all entities. |
You should use typeorm version 0.2.24 or 0.2.23 as they are the only versions that are working with latest nativescript, assure to use |
Is your feature request related to a problem? Please describe.
Currently, webpack sets
process
to undefinedwhich breaks plugins like
nativescript-nodeify
that use browser versions of library in NS.Describe the solution you'd like
Remove
"process": undefined,
or explain the reasoning behind it.Describe alternatives you've considered
Manually disabling it, but I don't know what are the reasons it was set like that in the first place.
In my tests, commenting the line had no side effects besides making everything that was broken work.
Additional context
I'm developing a remote abstraction for
@ngrx/store-devtools
. This means using browser libs that do checks onprocess.browser
and libs that userequire('ws')
. I managed to replacerequire('ws')
withnativescript-websockets
, but there isn't a way to useprocess
without changing the default webpack behavior, and the reason for it doesn't seem to be listed anywhere besides "process
is node specific" (NativeScript/NativeScript#3080 (comment))The text was updated successfully, but these errors were encountered: