Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Partial files for better modularization #5085

Closed
kripod opened this issue Oct 2, 2015 · 2 comments
Closed

Partial files for better modularization #5085

kripod opened this issue Oct 2, 2015 · 2 comments
Labels
Duplicate An existing issue was already created

Comments

@kripod
Copy link

kripod commented Oct 2, 2015

Inspired by the @import function of SASS.

I would like to propose a mechanism for creating partial files, which are not compiled by default, but embedded into files which reference them. It's just like bundling, but with less hassle and in a more unified approach.

As a brief example, suppose that we have 4 files:

  • index.ts
  • user.ts
  • _auth.ts
  • _position.ts

The index.ts and user.ts files can reference contents of a partial file by using simple imports. For example, if we want index.ts to reference _auth.ts and _position.ts, use the following code in the non-partial index.ts file:

import auth = require('auth');
import position = require('position');

The content of partial files should be copied and instantly evaluated in their container file. For instance, whether we would also like to use the _position.ts partial file in user.ts, use an import just like above:

import position = require('position');

Although this may seem like a regular import, it's basically an include function which copies the partial file's full content at the place desired. That means, partial files should not be reused in multiple containers, but should be used for code organisation purposes. When both index.ts and user.ts are referenced in a HTML file, the content of _position.ts will be duplicated and inserted into the 2 containers separately.

@mhegazy
Copy link
Contributor

mhegazy commented Oct 2, 2015

looks like a duplicate of #17

@mhegazy mhegazy closed this as completed Oct 2, 2015
@mhegazy mhegazy added the Duplicate An existing issue was already created label Oct 2, 2015
@kripod
Copy link
Author

kripod commented Oct 3, 2015

@mhegazy I think that I've defined a proposal for #17, then. :) It should only be implemented now...

@microsoft microsoft locked and limited conversation to collaborators Jun 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Duplicate An existing issue was already created
Projects
None yet
Development

No branches or pull requests

2 participants