Skip to content
This repository has been archived by the owner on Dec 6, 2021. It is now read-only.

poi 10 trying to load poi.config.ts as a json file #419

Closed
cj opened this issue Apr 18, 2018 · 18 comments
Closed

poi 10 trying to load poi.config.ts as a json file #419

cj opened this issue Apr 18, 2018 · 18 comments

Comments

@cj
Copy link

cj commented Apr 18, 2018

Do you want to request a feature or report a bug?
bug

What is the current behavior?
poi is trying to parse poi.config.ts as json.

17:49 ◯ : npx poi --require ts-node/register --config poi.config.ts
JSONError: Unexpected token 'i' at 1:1 in poi.config.ts
import { Options } from 'poi'
^
import { Options } from 'poi'
^
    at module.exports (/Users/cj/apps/vodr/poi/node_modules/parse-json/index.js:27:17)
        at parse (/Users/cj/apps/vodr/poi/node_modules/load-json-file/index.js:8:29)
            at pify.then.data (/Users/cj/apps/vodr/poi/node_modules/load-json-file/index.js:10:67)
                at <anonymous>

If the current behavior is a bug, please provide the steps to reproduce.

https://gist.github.com/cj/3465de10e69d7eaf2b171a9b73d27480

npx poi --require ts-node/register --config poi.config.ts

What is the expected behavior?

It should run poi :)

Please mention other relevant information such as the browser version, Node.js version, Poi version and Operating System.

poi: 10.0.3

@cj
Copy link
Author

cj commented Apr 18, 2018

Looks like the issue is with https://github.com/egoist/use-config/blob/master/src/index.js#L30. @egoist do you want me to open up a ticket there?

@egoist
Copy link
Owner

egoist commented Apr 19, 2018

I will fix it in Poi (and update the d.ts file)

@egoist
Copy link
Owner

egoist commented Apr 19, 2018

10.1.0 should work. you don't need --require ts-node/register flag now.

@cj
Copy link
Author

cj commented Apr 19, 2018

@egoist works, thank you!

One other thing I just noticed. It now says TypeScript is supported by default, no need to require ts-node/register, if that's the case, it might be nice to look for poi.config.ts by default to get rid of the need for --config poi.config.ts, thoughts?

@egoist
Copy link
Owner

egoist commented Apr 19, 2018

Good idea, try 10.1.1

Doc has been updated too https://poi.js.org/guide/transforms.html#typescript

@egoist egoist closed this as completed Apr 19, 2018
@cj
Copy link
Author

cj commented Apr 19, 2018

@egoist you are truly a legend!

@cj
Copy link
Author

cj commented Apr 19, 2018

@egoist looks like there's one caveat, I don't think it's picking up the tsconfig.json. I created https://glitch.com/edit/#!/poi-typescript to play around with.

@cj
Copy link
Author

cj commented Apr 19, 2018

ah, I think it's actually the ts-loader

@cj
Copy link
Author

cj commented Apr 19, 2018

Module build failed: TypeError: Cannot read property 'ts' of undefined
    at getLoaderOptions (/Users/cj/apps/vodr/poi/node_modules/ts-loader/dist/index.js:70:44)
        at Object.loader (/Users/cj/apps/vodr/poi/node_modules/ts-loader/dist/index.js:23:19)

looks like the error above is to do with TypeStrong/ts-loader#726 (comment). Upgrading to "ts-loader": "^4.2.0" fixes that error, but leads to another.

Module build failed: Error: Could not find file: '/Users/cj/apps/vodr/poi/client/App.vue'.
at getValidSourceFile (/Users/cj/apps/vodr/poi/node_modules/typescript/lib/typescript.js:103059:23)
at Object.getEmitOutput (/Users/cj/apps/vodr/poi/node_modules/typescript/lib/typescript.js:103402:30)
at Object.getEmitOutput (/Users/cj/apps/vodr/poi/node_modules/ts-loader/dist/instances.js:184:41)
at getEmit (/Users/cj/apps/vodr/poi/node_modules/ts-loader/dist/index.js:188:37)
at successLoader (/Users/cj/apps/vodr/poi/node_modules/ts-loader/dist/index.js:34:11)
at Object.loader (/Users/cj/apps/vodr/poi/node_modules/ts-loader/dist/index.js:21:12)

Cannot import file "./router" from "/Users/cj/apps/vodr/poi/client"! Are you sure it exists?

@egoist
Copy link
Owner

egoist commented Apr 19, 2018

for paths in tsconfig.json seems we still need to add tsconfig-paths-webpack-plugin

@cj
Copy link
Author

cj commented Apr 19, 2018

@egoist even without using paths it has an issue https://glitch.com/edit/#!/poi-typescript

@egoist
Copy link
Owner

egoist commented Apr 19, 2018

try updating @poi/plugin-typescript, baseUrl also requires tsconfig-paths-webpack-plugin

@cj
Copy link
Author

cj commented Apr 19, 2018

looks like it's still an issue https://glitch.com/edit/#!/poi-typescript

@egoist
Copy link
Owner

egoist commented Apr 19, 2018

Not sure what's going on there, it works fine locally.

@cj
Copy link
Author

cj commented Apr 19, 2018

I have the same issue locally as on glitch, I tried a clean install too.

@egoist
Copy link
Owner

egoist commented Apr 19, 2018

Hopefully fixed now.

@egoist
Copy link
Owner

egoist commented Apr 19, 2018

👌 now, I've updated https://github.com/poi-examples/vue-ts-example too

@cj
Copy link
Author

cj commented Apr 19, 2018

@egoist works like a charm now -- thank you again!

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

No branches or pull requests

2 participants