GithubHelp home page GithubHelp logo

boboben1 / parcel-plugin-typescript-paths Goto Github PK

View Code? Open in Web Editor NEW
1.0 3.0 3.0 646 KB

This plugin enabled Parcel to automatically use module aliases defined in tsconfig.json's compilerOptions.paths without any additional configuration.

License: MIT License

TypeScript 80.93% JavaScript 19.07%

parcel-plugin-typescript-paths's Introduction

parcel-plugin-typescript-paths

This plugin enabled parcel to be aware of typescript module paths (module aliasing).

pipeline status CodeFactor

Installation

npm install --save-dev parcel-plugin-typescript-paths

WARNING

This project is in heavy development and will change. Please don't use on production.

Feel free to contribute.

Known Limitations

This plugin uses regular expressions to perform a search and replace in your code. To avoid collisions, it is recommended to only use unique names as your paths. For example, if you have the following in your tsconfig:

"paths": {
    "upload": ["src/upload"],
}

and you have the following content string in your code:

Students, import your work for review 
by clicking the button "upload".

then "upload" will get replaced with "src/upload".

The following would be a better configuration since "@upload" is probably less likely to be used as a content string in your app:

"paths": {
    "@upload": ["src/upload"],
}

parcel-plugin-typescript-paths's People

Contributors

boboben1 avatar code-factor avatar jpray avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

parcel-plugin-typescript-paths's Issues

Support .TSX files

I'm using TypeScript to build a react application and would like to use your plugin with tsx files.
With the default ts files it works great.

Seems the only change necessary would be an additional tsx asset type in the index.ts.

bundler.addAssetType('.tsx', require.resolve('./asset.js'));

Parcel-bundler does not install by default with the plugin ?

Hi, when i install your plugin parcel-bundler is not install by default and your plugin return me this error.

You can fix this by install parcel-bundler. by default i install parcel.. its why i got this error but parcel and parcel-bundler is the same. Maybe you can make a "fix" for this problem. (Your plugin help me so much for my project thanks you.)

Node version: 12.10.0
NPM version: 6.14.3
Computre: Windows
Used with Laragons.

‼  Parser "parcel-plugin-typescript-paths\dist\asset.js" failed to initialize when processing asset "src\index.ts". Threw the following error:
Error: Cannot find module 'parcel-bundler/src/assets/TypeScriptAsset.js'
Require stack:
- C:\native\srv\try\node_modules\parcel-plugin-typescript-paths\dist\asset.js
- C:\native\srv\try\node_modules\parcel\src\Parser.js
- C:\native\srv\try\node_modules\parcel\src\Bundler.js
- C:\native\srv\try\node_modules\parcel\index.js
- C:\native\srv\try\node_modules\parcel\src\cli.js
- C:\native\srv\try\node_modules\parcel\bin\cli.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:772:15)
    at Function.Module._load (internal/modules/cjs/loader.js:677:27)
    at Module.require (internal/modules/cjs/loader.js:830:19)
    at require (C:\native\srv\try\node_modules\v8-compile-cache\v8-compile-cache.js:161:20)
    at Object.<anonymous> (C:\native\srv\try\node_modules\parcel-plugin-typescript-paths\dist\asset.js:2:25)
    at Module._compile (C:\native\srv\try\node_modules\v8-compile-cache\v8-compile-cache.js:194:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:947:10)
    at Module.load (internal/modules/cjs/loader.js:790:32)
    at Function.Module._load (internal/modules/cjs/loader.js:703:12)
    at Module.require (internal/modules/cjs/loader.js:830:19) falling back to RawAsset
‼  Parser "parcel-plugin-typescript-paths\dist\asset.js" failed to initialize when processing asset "src\index.ts". Threw the following error:
Error: Cannot find module 'parcel-bundler/src/assets/TypeScriptAsset.js'
Require stack:
- C:\native\srv\try\node_modules\parcel-plugin-typescript-paths\dist\asset.js
- C:\native\srv\try\node_modules\parcel\src\Parser.js
- C:\native\srv\try\node_modules\parcel\src\Bundler.js
- C:\native\srv\try\node_modules\parcel\index.js
- C:\native\srv\try\node_modules\parcel\src\cli.js
- C:\native\srv\try\node_modules\parcel\bin\cli.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:772:15)
    at Function.Module._load (internal/modules/cjs/loader.js:677:27)
    at Module.require (internal/modules/cjs/loader.js:830:19)
    at require (C:\native\srv\try\node_modules\v8-compile-cache\v8-compile-cache.js:161:20)
    at Object.<anonymous> (C:\native\srv\try\node_modules\parcel-plugin-typescript-paths\dist\asset.js:2:25)
    at Module._compile (C:\native\srv\try\node_modules\v8-compile-cache\v8-compile-cache.js:194:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:947:10)
    at Module.load (internal/modules/cjs/loader.js:790:32)
    at Function.Module._load (internal/modules/cjs/loader.js:703:12)
    at Module.require (internal/modules/cjs/loader.js:830:19) falling back to RawAsset
‼  Parser "parcel-plugin-typescript-paths\dist\asset.js" failed to initialize when processing asset "src\index.ts". Threw the following error:
Error: Cannot find module 'parcel-bundler/src/assets/TypeScriptAsset.js'
Require stack:
- C:\native\srv\try\node_modules\parcel-plugin-typescript-paths\dist\asset.js
- C:\native\srv\try\node_modules\parcel\src\Parser.js
- C:\native\srv\try\node_modules\parcel\src\Pipeline.js
- C:\native\srv\try\node_modules\parcel\src\worker.js
- C:\native\srv\try\node_modules\@parcel\workers\src\child.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:772:15)
    at Function.Module._load (internal/modules/cjs/loader.js:677:27)
    at Module.require (internal/modules/cjs/loader.js:830:19)
    at require (C:\native\srv\try\node_modules\v8-compile-cache\v8-compile-cache.js:161:20)
    at Object.<anonymous> (C:\native\srv\try\node_modules\parcel-plugin-typescript-paths\dist\asset.js:2:25)
    at Module._compile (C:\native\srv\try\node_modules\v8-compile-cache\v8-compile-cache.js:194:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:947:10)
    at Module.load (internal/modules/cjs/loader.js:790:32)
    at Function.Module._load (internal/modules/cjs/loader.js:703:12)
    at Module.require (internal/modules/cjs/loader.js:830:19) falling back to RawAsset

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.