Webpack example


I wrote minimal example with webpack only (without gradle) and want to recive some feedback.

I have some questions about this example.

  1. Why it does not build with JDK 9 and how to find reason?
  2. Can i refuse fake main function?
  3. Why kotlin-webpack-plugin have no documentation?

  1. Could you provide more details? I was able to build your example with JDK9 set as default, but my environment might differ from yours. There are some issues with java 9 support at the moment (https://youtrack.jetbrains.com/issues/KT?q=tag:%20{java%209}), but I don’t think they should affect you.

  2. There is a flag -keep which could be used both from command line and from gradle to define the declarations that are used externally. Unfortunately I don’t see a way to pass anything to it using the KotlinWebpackPlugin API.

Regarding #2 and #3 a better option might be to either file a bug, or ask directly in the #react slack channel.

$ npm run build

> empty@0.0.1 build /Users/barlog/github/kotlin-js-webpack-example
> NODE_ENV=production webpack --progress --profile --bail --display-error-details

>>> Kotlin Plugin: >>> Initial compilation of Kotlin sources...
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by com.intellij.util.text.StringFactory to constructor java.lang.String(char[],boolean)
WARNING: Please consider reporting this to the maintainers of com.intellij.util.text.StringFactory
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release

npm ERR! errno 1
npm ERR! empty@0.0.1 build: `NODE_ENV=production webpack --progress --profile --bail --display-error-details`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the empty@0.0.1 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!     /Users/barlog/.npm/_logs/2018-01-16T15_16_46_960Z-debug.log

$ java -version
java version "9.0.1"
Java(TM) SE Runtime Environment (build 9.0.1+11)
Java HotSpot(TM) 64-Bit Server VM (build 9.0.1+11, mixed mode)

$ uname -a
Darwin tanelorn 17.3.0 Darwin Kernel Version 17.3.0: Thu Nov  9 18:09:22 PST 2017; root:xnu-4570.31.3~1/RELEASE_X86_64 x86_64

$ cat /Users/barlog/.npm/_logs/2018-01-16T15_16_46_960Z-debug.log
0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/Cellar/node/9.4.0/bin/node',
1 verbose cli   '/usr/local/bin/npm',
1 verbose cli   'run',
1 verbose cli   'build' ]
2 info using npm@5.6.0
3 info using node@v9.4.0
4 verbose run-script [ 'prebuild', 'build', 'postbuild' ]
5 info lifecycle empty@0.0.1~prebuild: empty@0.0.1
6 info lifecycle empty@0.0.1~build: empty@0.0.1
7 verbose lifecycle empty@0.0.1~build: unsafe-perm in lifecycle true
8 verbose lifecycle empty@0.0.1~build: PATH: /usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/Users/barlog/github/kotlin-js-webpack-example/node_modules/.bin:/Users/barlog/Library/Python/3.6/bin:/Users/barlog/.cargo/bin:/Users/barlog/bin:/bin:/usr/local/bin:/usr/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/opt/android-sdk/platform-tools:/usr/local/opt/android-sdk/tools
9 verbose lifecycle empty@0.0.1~build: CWD: /Users/barlog/github/kotlin-js-webpack-example
10 silly lifecycle empty@0.0.1~build: Args: [ '-c',
10 silly lifecycle   'NODE_ENV=production webpack --progress --profile --bail --display-error-details' ]
11 silly lifecycle empty@0.0.1~build: Returned: code: 1  signal: null
12 info lifecycle empty@0.0.1~build: Failed to exec build script
13 verbose stack Error: empty@0.0.1 build: `NODE_ENV=production webpack --progress --profile --bail --display-error-details`
13 verbose stack Exit status 1
13 verbose stack     at EventEmitter.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:285:16)
13 verbose stack     at EventEmitter.emit (events.js:160:13)
13 verbose stack     at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
13 verbose stack     at ChildProcess.emit (events.js:160:13)
13 verbose stack     at maybeClose (internal/child_process.js:943:16)
13 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:220:5)
14 verbose pkgid empty@0.0.1
15 verbose cwd /Users/barlog/github/kotlin-js-webpack-example
16 verbose Darwin 17.3.0
17 verbose argv "/usr/local/Cellar/node/9.4.0/bin/node" "/usr/local/bin/npm" "run" "build"
18 verbose node v9.4.0
19 verbose npm  v5.6.0
20 error code ELIFECYCLE
21 error errno 1
22 error empty@0.0.1 build: `NODE_ENV=production webpack --progress --profile --bail --display-error-details`
22 error Exit status 1
23 error Failed at the empty@0.0.1 build script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]


Looks like https://youtrack.jetbrains.com/issue/KT-19051
сс @udalov


@udalov confirmed this is indeed a problem with intellij-core library the compiler depends on.
Should be fixed in the next patch release (1.2.30)


Thank you for you attention.