Skip to content

Commit

Permalink
Merge pull request #23 from unstubbable/internal-condtional-exports
Browse files Browse the repository at this point in the history
Build without the need to compile
  • Loading branch information
unstubbable authored Nov 12, 2023
2 parents 0d575c9 + e6395c8 commit 474fd5d
Show file tree
Hide file tree
Showing 17 changed files with 505 additions and 43 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 18
node-version-file: '.node-version'
cache: 'npm'
- name: Install
run: npm i
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/deployment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 18
node-version-file: '.node-version'
cache: 'npm'
- name: Install
run: npm i
Expand Down
2 changes: 1 addition & 1 deletion .node-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
18
20
9 changes: 5 additions & 4 deletions apps/cloudflare-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
"author": "Hendrik Liebau <[email protected]>",
"type": "module",
"scripts": {
"build": "webpack --mode production",
"build:dev": "webpack --mode development",
"build": "NODE_OPTIONS='--import=tsx --conditions=@mfng:internal' webpack --mode production",
"build:dev": "NODE_OPTIONS='--import=tsx --conditions=@mfng:internal' webpack --mode development",
"deploy": "wrangler publish -c src/worker/wrangler.toml",
"dev": "npm run start",
"start": "wrangler dev -c src/worker/wrangler.toml -l",
"watch": "webpack --mode production --watch",
"watch:dev": "webpack --mode development --watch"
"watch": "NODE_OPTIONS='--import=tsx --conditions=@mfng:internal' webpack --mode production --watch",
"watch:dev": "NODE_OPTIONS='--import=tsx --conditions=@mfng:internal' webpack --mode development --watch"
},
"dependencies": {
"@cloudflare/kv-asset-handler": "^0.3.0",
Expand Down Expand Up @@ -40,6 +40,7 @@
"source-map-loader": "^4.0.1",
"swc-loader": "^0.2.3",
"tailwindcss": "^3.2.7",
"tsx": "^4.1.0",
"webpack": "^5.77.0",
"webpack-cli": "^5.0.1",
"webpack-manifest-plugin": "^5.0.0",
Expand Down
2 changes: 1 addition & 1 deletion apps/cloudflare-app/tailwind.config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ const config = require(`@mfng/shared-app/tailwind.config.cjs`);
/** @type {import('tailwindcss').Config} */
module.exports = {
...config,
content: [`./src/**/*.{ts,tsx}`, `../shared-app/lib/**/*.js`],
content: [`./src/**/*.{ts,tsx}`, `../shared-app/src/**/*.{ts,tsx}`],
};
13 changes: 10 additions & 3 deletions apps/cloudflare-app/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,20 +95,26 @@ export default function createConfigs(_env, argv) {
},
resolve: {
plugins: [new ResolveTypeScriptPlugin()],
conditionNames: [`workerd`, `node`, `...`],
conditionNames: [
`@mfng:internal:node`,
`@mfng:internal`,
`workerd`,
`node`,
`...`,
],
},
module: {
rules: [
{
resource: (value) =>
/core\/lib\/server\/rsc\.js$/.test(value) ||
/core\/src\/server\/rsc\.ts$/.test(value) ||
/create-rsc-app\.tsx$/.test(value),
layer: webpackRscLayerName,
},
{
// AsyncLocalStorage module instances must be in a shared layer.
layer: `shared`,
test: /(router-location-async-local-storage|core\/lib\/server\/use-router-location\.js)/,
test: /(router-location-async-local-storage|use-router-location)/,
},
{
issuerLayer: webpackRscLayerName,
Expand Down Expand Up @@ -169,6 +175,7 @@ export default function createConfigs(_env, argv) {
},
resolve: {
plugins: [new ResolveTypeScriptPlugin()],
conditionNames: [`@mfng:internal`, `...`],
},
module: {
rules: [
Expand Down
14 changes: 10 additions & 4 deletions apps/shared-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,17 @@
"author": "Hendrik Liebau <[email protected]>",
"type": "module",
"exports": {
"./app.js": "./lib/src/server/app.js",
"./location-server-context.js": "./lib/src/shared/location-server-context.js",
"./navigation-context.js": "./lib/src/client/navigation-context.js",
"./app.js": {
"@mfng:internal": "./src/server/app.tsx",
"types": "./lib/src/server/app.d.ts",
"default": "./lib/src/server/app.js"
},
"./package.json": "./package.json",
"./tailwind.config.cjs": "./lib/tailwind.config.cjs"
"./tailwind.config.cjs": {
"@mfng:internal": "./tailwind.config.cjs",
"types": "./lib/tailwind.config.d.cts",
"default": "./lib/tailwind.config.cjs"
}
},
"files": [
"lib",
Expand Down
10 changes: 6 additions & 4 deletions apps/vercel-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@
"author": "Hendrik Liebau <[email protected]>",
"type": "module",
"scripts": {
"build": "webpack --mode production",
"build:dev": "webpack --mode development",
"build": "NODE_OPTIONS='--import=tsx --conditions=@mfng:internal' webpack --mode production",
"build:dev": "NODE_OPTIONS='--import=tsx --conditions=@mfng:internal' webpack --mode development",
"build:node18": "NODE_OPTIONS='--loader=tsx --conditions=@mfng:internal' webpack --mode production",
"deploy": "vercel deploy --prebuilt",
"dev": "npm run start",
"start": "node dev-server/run.js",
"watch": "webpack --mode production --watch",
"watch:dev": "webpack --mode development --watch"
"watch": "NODE_OPTIONS='--import=tsx --conditions=@mfng:internal' webpack --mode production --watch",
"watch:dev": "NODE_OPTIONS='--import=tsx --conditions=@mfng:internal' webpack --mode development --watch"
},
"dependencies": {
"@mfng/core": "*",
Expand Down Expand Up @@ -44,6 +45,7 @@
"source-map-loader": "^4.0.1",
"swc-loader": "^0.2.3",
"tailwindcss": "^3.2.7",
"tsx": "^4.1.0",
"vercel": "^28.18.3",
"webpack": "^5.77.0",
"webpack-cli": "^5.0.1",
Expand Down
2 changes: 1 addition & 1 deletion apps/vercel-app/tailwind.config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ const config = require(`@mfng/shared-app/tailwind.config.cjs`);
/** @type {import('tailwindcss').Config} */
module.exports = {
...config,
content: [`./src/**/*.{ts,tsx}`, `../shared-app/lib/**/*.js`],
content: [`./src/**/*.{ts,tsx}`, `../shared-app/src/**/*.{ts,tsx}`],
};
9 changes: 9 additions & 0 deletions apps/vercel-app/turbo.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,15 @@
],
"outputs": ["dist/**", ".vercel/output/**"]
},
"build:node18": {
"inputs": [
"src/**/*",
"package.json",
"tailwind.config.cjs",
"webpack.config.js"
],
"outputs": ["dist/**", ".vercel/output/**"]
},
"build:dev": {
"inputs": [
"src/**/*",
Expand Down
13 changes: 10 additions & 3 deletions apps/vercel-app/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,20 +122,26 @@ export default function createConfigs(_env, argv) {
},
resolve: {
plugins: [new ResolveTypeScriptPlugin()],
conditionNames: [`workerd`, `node`, `...`],
conditionNames: [
`@mfng:internal:node`,
`@mfng:internal`,
`workerd`,
`node`,
`...`,
],
},
module: {
rules: [
{
resource: (value) =>
/core\/lib\/server\/rsc\.js$/.test(value) ||
/core\/src\/server\/rsc\.ts$/.test(value) ||
/create-rsc-app\.tsx$/.test(value),
layer: webpackRscLayerName,
},
{
// AsyncLocalStorage module instances must be in a shared layer.
layer: `shared`,
test: /(router-location-async-local-storage|core\/lib\/server\/use-router-location\.js)/,
test: /(router-location-async-local-storage|use-router-location)/,
},
{
issuerLayer: webpackRscLayerName,
Expand Down Expand Up @@ -210,6 +216,7 @@ export default function createConfigs(_env, argv) {
},
resolve: {
plugins: [new ResolveTypeScriptPlugin()],
conditionNames: [`@mfng:internal`, `...`],
},
module: {
rules: [
Expand Down
2 changes: 2 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ export default {
moduleFileExtensions: [...defaults.moduleFileExtensions, `cts`],
moduleNameMapper: {
'^(\\.{1,2}/.*)\\.c?js$': `$1`,
'@mfng/core/client': `<rootDir>/packages/core/src/client/index.ts`,
'@mfng/core/(.*)': `<rootDir>/packages/core/src/$1.ts`,
},
restoreMocks: true,
testMatch: [`**/src/**/*.test.{ts,tsx}`],
Expand Down
Loading

1 comment on commit 474fd5d

@vercel
Copy link

@vercel vercel bot commented on 474fd5d Nov 12, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

mfng – ./

mfng-git-main-unstubbable.vercel.app
mfng.vercel.app
mfng-unstubbable.vercel.app

Please sign in to comment.