microsoft / microsoft/TypeScript-Sublime-Plugin

Importing modules with require doesn't work with plugins

Open
#190 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

TypeScript/TS Services Issue
Dominant language
JavaScript
Stars
1.7k
Forks
236
Avg merge
21d 13h
Merged PRs (30d)
1

Description

Using custom requirejs plugins is not supported. This results in an error, even if the './MyModule' path is valid:

import MyModule = require('someplugin!./MyModule');

Obviously tsc can't know what the plugin does so one may argue reporting an error is the right thing to do, however some plugins preprocess (or load using alternative methods) resources matching the local file system hierarchy (in my case I use a plugin which uses an alternative way to load code).

Unless there are better ideas I suggest to skip the plugin prefix (someplugin!) and validate the local path, as usual. If there was a compiler flag (either a command line option or a source-code-level magic statement) controlling this behaviour that would surely make everyone happy.

For completeness: requiring in the class body is not a solution as such statements don't validate the path.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The issue names no source file, test, or entry point. Start by reproducing the error for import MyModule = require('someplugin!./MyModule') and trace the existing module-path validation; done means the agreed behavior for plugin-prefixed local paths is implemented and covered by tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, typescript
Domain
devtools, tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.