- #435
014038b
Thanks @nicksrandall! - Added experimentalexports
flag. See the docs at theexports
section of https://preconstruct.tools/configuration.
3f202fd
Thanks @mitchellhamilton! - Imports to@babel/runtime/helpers/esm/*
will now be rewritten to@babel/runtime/helpers/*
for CommonJS outputs. This fixes the CommonJS output in case you have["@babel/plugin-transform-runtime", { "useESModules": true }]
) in your Babel config.
- #461
97e7ca0
Thanks @simonswiss! - Fixed grammar in CLI info message about errors
f6f2e60
Thanks @mitchellhamilton! - Fixed bigint usage causing an error
ad15ffa
Thanks @mitchellhamilton! - Fixed resolvingtypescript
package when using Yarn PnP and installingtypescript
at the root of a project
7c730bd
#415 Thanks @mitchellhamilton! - Fixed generating TypeScript declarations when a JSON file is imported from a TypeScript file.
-
ce31841
#411 Thanks @mitchellhamilton! - Fixed generating declaration maps with versions of TypeScript 4.3 and above.Errors are now also emitted when TypeScript fails to generate declarations because it needs to reference a type that isn't exported. Previously Preconstruct silently generated a broken declaration file when encountering inputs like the one shown below where TypeScript needs to be able to name the type
X
when generating thed.ts
file forindex.ts
but it isn't exported, now it will emit an error instead. To fix the error, you need to export the type.// @filename: index.ts import { getX } from "./x"; export const x = getX(); // @filename: x.ts type X = { x?: X; }; export const getX = (): X => ({});
Note that Preconstruct still does not run TypeScript's type checking, you should still do that in addition to running Preconstruct, Preconstruct will only emit these specific errors.
adcca78
Thanks @mitchellhamilton! - Fixed issues aroundERR_PACKAGE_PATH_NOT_EXPORTED
errors when resolving the location of dependencies' package.jsons with UMD builds
f798f04
#393 Thanks @with-heart! - Added support for thetsconfig.declarationMap
option.preconstruct
now outputs bothd.ts
andd.ts.map
files todist/declarations/src
when the option is enabled.
-
eee1b6e
#383 Thanks @mitchellhamilton! - AddkeepDynamicImportAsDynamicImportInCommonJS
experimental flag to allow importing Node ESM-only packages in Preconstruct packages. This can be used to ship a package that can be both imported and required and has a dependency that doesn't have a CommonJS distribution.Note that
import()
is asynchronous so it won't be possible to get access to such ESM-only dependency synchronously.
d1feb8e
#376 Thanks @Andarist! - Fixed thewatch
command not clearing dev links of additional entrypoints correctly and creating an infinite loop because of this.
3c30480
#372 Thanks @mitchellhamilton! - SetpreventAssignment
on@rollup/plugin-replace
to stop browser builds failing to build.
87e8713
#295 Thanks @Andarist! - Fixed destination paths of generated "local dependency".d.ts
files (for files other thansrc/index.ts
) in TypeScript projects on Windows.
a41034d
#366 Thanks @Andarist! - Fixed destination paths of generated.d.ts
files in TypeScript projects on Windows.
1451fc4
Thanks @mitchellhamilton! - Fix UMD builds where files contain typeof window/document and process.env.NODE_ENV
e3b4196
#358 Thanks @mitchellhamilton! - Improvements to Babel helper generation so that @babel/runtime(and the core-js versions) is automatically used when it is a dependency even without @babel/plugin-transform-runtime including using all of the available helpers in the version of @babel/runtime that is specified as a dependency(without Preconstruct, unless you specify the version of @babel/runtime that you use in @babel/plugin-transform-runtime, Babel helpers that aren't available in the oldest version of @babel/runtime will be inlined rather than imported from @babel/runtime).
1451fc4
Thanks @mitchellhamilton! - Fix UMD builds where external dependencies contain process.env.NODE_ENV
93acf0c
Thanks @mitchellhamilton! - Remove an unnecessary parse
fe57d4c
Thanks @mitchellhamilton! - Improve TypeScript declaration generation performance by only creating a single program per TS project rather than one per package
4afde4e
Thanks @mitchellhamilton! - AddtypeScriptProxyFileWithImportEqualsRequireAndExportEquals
experimental flag
c2a9918
Thanks @mitchellhamilton! - Fix entrypoint glob check on Windows
-
9ac1df4
Thanks @mitchellhamilton! - Change the way entrypoints are configured. Instead of the entrypoints option referring to the entrypoint directories, they new refer to entrypoint source files. They are resolved relative to thesrc
directory of the package. To get the entrypoint directory from a source file, the extension is removed from the path relative to thesrc
directory and if the last part isindex
, theindex
part is removed. For example, an entrypoint ofsomething.js
would create an entrypoint atpkg-name/something
andanother/index.js
would create an entrypoint atpkg-name/another
.preconstruct fix
will also now automatically create the entrypointpackage.json
s because it already knows where the source file is.For example, a package that looks like the following in
@preconstruct/cli@1
package.json
{ "name": "pkg", "main": "dist/pkg.cjs.js", "preconstruct": { "entrypoints": [".", "other"] } }
src/index.js
export const something = true;
src/other.js
export const other = true;
other/package.json
{ "main": "dist/pkg.cjs.js", "preconstruct": { "source": "../src/other.js" } }
Would need the following changes to work in
@preconstruct/cli@2
package.json
{ "name": "pkg", "main": "dist/pkg.cjs.js", "preconstruct": { - "entrypoints": [".", "other"] + "entrypoints": ["index.js", "other.js"] } }
other/package.json
{ "main": "dist/pkg.cjs.js", - "preconstruct": { - "source": "../src/other.js" - } }
9ac1df4
Thanks @mitchellhamilton! - Change the way thatprocess.env.NODE_ENV
is replaced in the production CJS bundle to search forprocess.env.NODE_ENV
in the AST and replace it rather than using Terser to replace it and also skip running Terser on the production CJS bundle and instead rely on Rollup's dead code elimination to improve build performance. It's extremely unlikely that this will break anything but this is being made in a major release just in case it does.
9ac1df4
Thanks @mitchellhamilton! - Change default dist filename strategy to include the scope and entrypoint path. For example, with an entrypoint accessible at@scope/pkg/entrypoint
, the CJS dist filename would bescope-pkg-entrypoint.cjs.js
. If you'd like to use the old dist filenames, you can set"distFilenameStrategy": "unscoped-package-name"
in your root Preconstruct config.
dd0f041
Thanks @mitchellhamilton! - Use fast-glob directly instead of globby. This shouldn't break anything but because using fast-glob directly instead of globby may have subtly different behaviour, this is being done in a major version.
027e44d
Thanks @mitchellhamilton! - Remove theuseSourceInsteadOfGeneratingTSDeclarations
anduseTSMorphToGenerateTSDeclarations
experimental flags as the TypeScript declaration generator no longer has the issues that these experimental flags tried to solve
20902dc
Thanks @mitchellhamilton! - Use symlinks instead of CJS re-export files for "module" and "browser" field when usingpreconstruct dev
.
620e71f
#344 Thanks @mitchellhamilton! - Makepreconstruct fix
automatically create entrypoint package.jsons rather than asking if it should create them with the new entrypoints experimental flag
620e71f
#344 Thanks @mitchellhamilton! - Renameonly-unscoped-package-name
tounscoped-package-name
in thedistFilenameStrategy
option(which is only enabled when the experimentalnewDistFilenames
flag is enabled)
3c031da
#343 Thanks @Andarist! - Respectpackage.json#browser
when bundling dependencies for the UMD build.
a198073
#340 Thanks @Andarist! - Allow to build UMD files for packages having dependencies with top-levelthis
in ESM files. This can often happen if a dependency package is transpiled down to ES5 using TypeScript.
be053e7
#337 Thanks @mitchellhamilton! - AddnewDistFilenames
experimental flag
cef98e9
Thanks @mitchellhamilton! - Revert change from globby to fast-glob because fast-glob doesn't directly support negations
3944e88
#333 Thanks @mitchellhamilton! - AddnewProcessEnvNodeEnvReplacementStrategyAndSkipTerserOnCJSProdBuild
experimental flag
b79bb61
Thanks @mitchellhamilton! - Skip unnecessary repeated module resolution when doing a build (this won't make a very noticable difference for projects with a small amount of packages and entrypoints but will for projects with a large amount of packages and entrypoint)
4e0d249
Thanks @mitchellhamilton! - Revert change in@preconstruct/cli@1.1.30
that skips unregistering the require hook in the code generated bypreconstruct dev
because not unregistering the hook caused some issues when using Preconstruct to build a Babel plugin.
b79bb61
Thanks @mitchellhamilton! - Only generate the Babel helpers that are used and not imported from@babel/runtime
along with only generating and parsing them once rather than per package (note that unused helpers were already removed from the bundles, this is just a performance improvement when doing a build)
47515cd
Thanks @mitchellhamilton! - Validate that the root dist directory of a package is included in the published files since common chunks may be written to it
cfda1c6
Thanks @mitchellhamilton! - Fix the error message shown when an entrypoint in a package has a given build type and another doesn't
cfe7d95
Thanks @mitchellhamilton! - Add no-op file to@preconstruct/hook
that will be imported by bundlers instead of the real require hook so that thepreconstruct dev
output will work in bundlers without a module build or bundler config changes(including for React Native's bundler, Metro)
9a64c4e
Thanks @mitchellhamilton! - Cache Acorn parse step so that modules are only parsed a single time with Acorn rather than a number of times equal to the number of build types for a given package
-
47515cd
Thanks @mitchellhamilton! - Improve error messages for invalid fields -
Updated dependencies [
cfe7d95
]:- @preconstruct/hook@0.4.0
77b6d2f
Thanks @mitchellhamilton! - Fix dist directory not being published in previous release
86d8d3d
#322 Thanks @mitchellhamilton! - Deduplicate Babel helpers when not using @babel/plugin-transform-runtime(note that we still recommend using @babel/plugin-transform-runtime, this is just stopping the duplication if you choose not to use it)
3b3cacb
Thanks @mitchellhamilton! - Disable usage of worker processes when running on CI to improve performance(Emotion's preconstruct build on CircleCI went from ~2 minutes to ~10 seconds when disabling the worker)
2d62357
#320 Thanks @mitchellhamilton! - Fix process.env.NODE_ENV reassignment throwing a syntax error
f4e9954
Thanks @mitchellhamilton! - Stop memoizing creation of TS programs for declaration generation when the tsconfig is in the package directory to allow garbage collection and prevent out of memory errors (Note that having a tsconfig per package will still be slower than having one at the root of the project since TS will be doing unnecessary repeated work)
8aaec07
Thanks @mitchellhamilton! - Correctly cache entrypoint source file resolution
99090cb
#312 Thanks @mitchellhamilton! - Upgrade dependencies
6b3f95e
Thanks @mitchellhamilton! - Fix bug in reading of TS config resulting in wrong type definitions being generated in some cases. This should remove the need for the experimentaluseTSMorphToGenerateTSDeclarations
anduseSourceInsteadOfGeneratingTSDeclarations
flags.
6727d9b
Thanks @mitchellhamilton! - AddlogCompiledFiles
experimental flag for logging when files are compiled with Babel
d56018d
Thanks @mitchellhamilton! - Skip double removing of package dist directory to attempt to fix EINVAL errors on build
-
5ad1c73
Thanks @mitchellhamilton! - Correctly only compile files within the package directory in the require hook forpreconstruct dev
-
Updated dependencies [
5ad1c73
]:- @preconstruct/hook@0.3.0
286d8fb
Thanks @mitchellhamilton! - Make check for default exports more reliable for preconstruct dev's.d.ts
redirect file generation
-
b8d1906
Thanks @mitchellhamilton! - Only compile files within the package directory in the require hook forpreconstruct dev
-
Updated dependencies [
b8d1906
]:- @preconstruct/hook@0.2.0
a723556
Thanks @mitchellhamilton! - Fix prompt for creating entrypoint package.jsons showing every entrypoint as the package name when usingnewEntrypoints
experimental flag
cae339b
Thanks @mitchellhamilton! - FixnewEntrypoints
experimental flag on Windows
68fdeeb
Thanks @mitchellhamilton! - Cache source module resolution
e3a5c0c
Thanks @mitchellhamilton! - Skip parsing modules with Babel to determine if they have default exports or not if we're sure they don't based on a regex when runningpreconstruct dev
933d831
Thanks @mitchellhamilton! - Fix the ts-morph declaration generator generating files outside of the package's directory
3c5743a
Thanks @mitchellhamilton! - Add experimentaluseTSMorphToGenerateTSDeclarations
flag
eeb0077
Thanks @mitchellhamilton! - Use relative paths inpreconstruct dev
files
0b1c19c
Thanks @mitchellhamilton! - Add experimentaluseSourceInsteadOfGeneratingTSDeclarations
flag. This flag should not be used and is intended to be a workaround for some TypeScript declaration bugs.
8e5c29d
#281 Thanks @mitchellhamilton! - Exclude package directories without package.jsons rather than prompting to delete them, this aligns with the behaviour of package managers.
5562440
#278 Thanks @evocateur! - Force emit when generating declaration files
1833512
Thanks @mitchellhamilton! - Remove a console.log
6698d62
#275 Thanks @mitchellhamilton! - Add experimental new entrypoints feature flag (note that this should not be used and will break in patch versions)
e2a8e9f
#272 Thanks @mitchellhamilton! - Fix TypeScript declaration generation with internal repo type dependencies
3292d97
#264 Thanks @NateRadebaugh! - Fix type import file paths when runningpreconstruct dev
to point to properly escaped paths.
e34148d
#266 Thanks @NateRadebaugh! - Normalize paths for declarations to fix TypeScript builds on Windows
5808f26
#258 Thanks @Andarist! - Fixed issue with temporarily created files (during validation) not being cleaned up correctly on validation error.
5acf0ea
#252 Thanks @mitchellhamilton! - Upgrade Rollup and related packages
a238788
Thanks @mitchellhamilton! - Fix source option not being written
-
e50769a
#239 Thanks @mrmartineau - Improve error message when attempting to create a TypeScript declaration file for a non-TypeScript file -
fd875bb
Thanks @mitchellhamilton! - Update npm-packlist to fix bug where npm-normalize-package-bin wasn't specified in the dependencies of npm-packlist
3098cfc
Thanks @mitchellhamilton! - Improve error when a package.json is invalid JSON
1e37a5d
#228 Thanks @mitchellhamilton! - Batch build errors together
c1cfc05
#226 Thanks @mitchellhamilton! - Fixed global prompt never showing up and get each global lazily so that peerDependencies which are never imported are not required to have a global
b2e1118
#224 Thanks @Andarist! - Rewrite references to @babel/runtime helpers when they are externalized in ESM builds.
37ff280
Thanks @mitchellhamilton! - Add README to package
887349e
Thanks @mitchellhamilton! - Replacerollup-plugin-alias
with@rollup/plugin-alias
androllup-plugin-replace
with@rollup/plugin-replace
c4886ea
#218 Thanks @mitchellhamilton! - Rename package to @preconstruct/cli
0ac7b7f
Thanks @mitchellhamilton! - Stop prompting to create browser build because people often don't want it/it isn't useful for most cases. Note that support for the field hasn't been removed, you can still add the field manually
c4886ea
#218 Thanks @mitchellhamilton! - Fix TypeScript declaration generation in TypeScript 3.7
7dd4014
Thanks @mitchellhamilton! - Improve error messages
8e5635d
Thanks @mitchellhamilton! - Mention errors page when an error occurs
21bbc08
#205 Thanks @Vultraz! - Fixed dist file check failing on Windows due to path separator mismatch
078886b
#171 Thanks @mitchellhamilton! - Prompt for entrypoint source when not the entrypoint is not at the root of the package
-
f02cce5
#163 Thanks @mitchellhamilton! - Remove automatic inclusion of@babel/plugin-transform-runtime
.Preconstruct no longer automatically includes
@babel/plugin-transform-runtime
to reduce confusion where code works when built with Preconstruct but fails if built using another tool which directly uses a project's Babel config. You should include@babel/plugin-transform-runtime
in your Babel config unless it is already included.{ "plugins": ["@babel/plugin-transform-runtime"] }
a24784a
Thanks @mitchellhamilton! - Update dependencies
-
11e0f62
#170 Thanks @mitchellhamilton! - Use detected indentation when writing package.json files -
Updated dependencies [
f02cce5
]:- @preconstruct/hook@0.1.0
- 72989b6 #106 Thanks @mitchellhamilton! - Prompt to create an entrypoint if a glob is a path and the directory doesn't exist
-
aefeb4f Thanks @mitchellhamilton! - Use TypeScript internally
-
Updated dependencies [aefeb4f]:
- @preconstruct/hook@undefined
- 13b79ea Thanks @mitchellhamilton! - Add v8-compile-cache
- 681537c Thanks @mitchellhamilton! - Remove unused dependencies
- 6dcfc40 Thanks @mitchellhamilton! - Improve error message for Babel parse errors
- f14c39e Thanks @mitchellhamilton! - Add a comment to the commonjs file for preconstruct dev explaining what it does
- 7c278d2 Thanks @mitchellhamilton! - Change redirect for flow in preconstruct dev to a file with export * because symlinks seem to be breaking
- 2f50306 #88 Thanks @mitchellhamilton! - Remove react-native field support(note: this doesn't mean you can't build libraries for react native with preconstruct, it just means preconstruct won't make a special build for react native)
- f1371f4 #84 Thanks @mitchellhamilton! - Check that all entrypoints and dist files will be included when published to npm
- b147abd - Fix TypeScript declaration generation in some cases with resolving
- ba73086 - Fix typescript declaration generation in some cases
- 470de81 #77 Thanks @bholloway! - support windows paths
- cec3b9f #75 Thanks @mitchellhamilton! - Fix TypeScript declaration file generation where a file only exports types
- a71a4f4 - Move an internal file
- ee8278f #71 Thanks @mitchellhamilton! - Allow importing JSON (only as a default export)
- e6f0b03 #70 Thanks @mitchellhamilton! - Prompt to delete package directories that do not contain package.jsons
- 1e851be #69 Thanks @mitchellhamilton! - Switch symlinks in
preconstruct dev
to CommonJS re-exports to avoid issues when using Node's--preserve-symlinks
option.
- 99f1549 - Remove dependency on some emotion packages that caused preconstruct to break when building emotion
- ccc162f #64 Thanks @mitchellhamilton! - Refactor logging and include package name in uncaught build errors
- 9cab2d1 #65 Thanks @mitchellhamilton! - Replace internal Babel runtime helpers CJS transform from an AST transform to regex
- df58a43 #68 Thanks @mitchellhamilton! - Add validation to disallow transitive peerDependencies where the peerDep is not specified in the direct parent
- ff49a6d #66 Thanks @mitchellhamilton! - Create rollup externals from dependencies and peerDependencies without checking nested deps. If you get an error saying that a dependency is missing when it previously worked, you should add that package as a dependency or peerDependency.
- 525137a - Remove erroneous console.log
- Updated dependencies [9efd990]:
- @preconstruct/hook@0.0.3
- Updated dependencies [aea0c36]:
- @preconstruct/hook@0.0.2
- ce8909b - Add file redirect instead of symlink redirect for TS in dev
- 7bade91 - Improve TypeScript declaration generation performance
- f79b195 - Change import path generated in TypeScript declarations
- 2e01590 #60 Thanks @mitchellhamilton! - Stop adding a postinstall script with preconstruct dev in preconstruct init. This was causing problems with single package repos so it's being removing for now.
- cd0979f - Change TS declaration filename
- ac2eb8a #59 Thanks @mitchellhamilton! - Add typescript declaration generation
- 423a8b6 #56 Thanks @mitchellhamilton! - Add checks that imported modules in a package are inside of the package's directory
- 8b6e051 #58 Thanks @mitchellhamilton! - Fix entrypoints package.json creation
- 4a9de88 #57 Thanks @mitchellhamilton! - Add .d.ts file so that TS types can be found when built
- 802fec0 #54 Thanks @mitchellhamilton! - Replace flow file that re-exports source contents with a symlink in dev command. This fixes the problem where if you added or removed the default export of an entrypoint source file, you would have to run
preconstruct dev
again. - b351218 #55 Thanks @mitchellhamilton! - Add support for TypeScript resolving types with dev command
- 9022265 - Set fields in a better order
- b22d4e1 - Fix init command prompting incorrectly for UMD builds
- 0a9b9d7 - Remove aliases export, this is now replaced with the dev command
- 698fe38 #53 Thanks @mitchellhamilton! - Move require hook into a package