-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #760 from open-formulieren/chore/npm-package-to-vite
Configure Vite to build the SDK
- Loading branch information
Showing
8 changed files
with
128 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,8 +17,8 @@ | |
|
||
# production | ||
/storybook-static | ||
/build | ||
/dist | ||
/dist-vite | ||
/lib | ||
/esm | ||
*.tgz | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import lodashTemplate from 'lodash/template'; | ||
|
||
// inspired on https://dev.to/koistya/using-ejs-with-vite-48id and | ||
// https://github.com/difelice/ejs-loader/blob/master/index.js | ||
export const ejsPlugin = () => ({ | ||
name: 'compile-ejs', | ||
async transform(src: string, id: string) { | ||
const options = { | ||
variable: 'ctx', | ||
evaluate: /\{%([\s\S]+?)%\}/g, | ||
interpolate: /\{\{([\s\S]+?)\}\}/g, | ||
escape: /\{\{\{([\s\S]+?)\}\}\}/g, | ||
}; | ||
if (id.endsWith('.ejs')) { | ||
// @ts-ignore | ||
const code = lodashTemplate(src, options); | ||
return {code: `export default ${code}`, map: null}; | ||
} | ||
}, | ||
}); | ||
|
||
export const cjsTokens = () => ({ | ||
name: 'process-cjs-tokens', | ||
async transform(src, id) { | ||
if ( | ||
id.endsWith('/design-tokens/dist/tokens.js') || | ||
id.endsWith('node_modules/@utrecht/design-tokens/dist/tokens.cjs') | ||
) { | ||
return { | ||
code: src.replace('module.exports = ', 'export default '), | ||
map: null, | ||
}; | ||
} | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import {dependencies, peerDependencies} from '../package.json'; | ||
|
||
const externalPackages = [ | ||
...Object.keys(dependencies || {}), | ||
...Object.keys(peerDependencies || {}), | ||
'formiojs', | ||
'lodash', | ||
'@formio/vanilla-text-mask', | ||
'@babel/runtime', | ||
'@utrecht/component-library-react', | ||
]; | ||
|
||
// Creating regexes of the packages to make sure subpaths of the | ||
// packages are also treated as external | ||
export const packageRegexes = externalPackages.map(packageName => new RegExp(`^${packageName}(/.*)?`)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import {isEmpty} from 'lodash'; | ||
import isEmpty from 'lodash/isEmpty'; | ||
|
||
import {post} from '../../api'; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters