包详细信息

@depack/bundle

dpck92MIT1.4.1

The Source Code For The Bundle Logic To Prepare Temp Files.

bundle, depack

自述文件

@depack/bundle

npm version

@depack/bundle is The Source Code For The Bundle Logic To Prepare Temp Files. Because Google Closure Compiler cannot import JSX files, we create a temp directory to put them in there, and also allow to update preact to @externs/preact in the temp as well, so that Preact can be referenced separately from the compiled code.

yarn add @depack/bundle

Table Of Contents

API

The package is available by importing its default function:

import generateTemp from '@depack/bundle'

async generateTemp(
  entry: string,
  config?: TempConfig,
): void

Generates a temp directory for the given entry file and transpiles JSX files that are references in it. Any JS files will also be placed in the TEMP dir if there is a single JSX file found. This is because references to JSX files need to be updated in JS files to point to the temp dir.

If the required file's path is higher than the current dir, the bundler will check if belongs to a linked package, and generate temp files in temp/node_modules dir rather than pollute the filesystem above CWD.

TempConfig: Options for generating the temp directory.

Name Type & Description Default
tempDir string depack-temp
The directory in which to place temp files.
preact boolean false
Whether to add import { h } from 'preact' automatically at the top of each JSX file.
preactExtern boolean false
Whether to add import { h } from '@externs/preact' automatically at the top of each JSX file, and rename preact imports into @externs/preact imports. See https://www.npmjs.com/package/@externs/preact.

Copyright

Art Deco © Art Deco for Depack 2019 Tech Nation Visa Tech Nation Visa Sucks

更新日志

14 September 2019

1.4.1

  • [deps] Update static-analysis for multiple entries detection.
  • [feature] Process all node_modules at once.

1.4.0

  • [feature] Handle linked packages.
  • [fix] Replace the final index.js and .js with an empty string.

12 September 2019

1.3.1

  • [doc] Update README.

1.3.0

  • [feature] Process anonymous JS/JSX imports.

17 August 2019

1.2.0

  • [feature] Generate JavaScript from CSS files calling depack/inject-css.

13 May 2019

1.1.1

  • [fix] Use fullwidth because GCC thinks that @externs in JSDoc is an indication of the file being an externs file.

1.1.0

  • [fix] Disable path expansions for packages (they will be analysed with static-analysis).
  • [feature] Allow to use @externs/preact by renaming preact import for external preact.
  • [externs] Add externs to the project.

18 April 2019

1.0.5

  • [fix] Process packages with paths, e.g., preact/src/preact.

4 April 2019

1.0.4

  • [deps] Unfix dependencies.

2 April 2019

1.0.3

  • [deps] Update dependencies.

2 March 2019

1.0.2

  • [deps] Update dependencies, including @a-la/jsx.

8 February 2019

1.0.1

  • [package] Add build.

1.0.0